Process Hacker
basesup.c File Reference
#include <phbase.h>
#include <phintrnl.h>
#include <math.h>

Go to the source code of this file.

Macros

#define PH_VECTOR_LEVEL_NONE   0
 
#define PH_VECTOR_LEVEL_SSE2   1
 
#define PH_VECTOR_LEVEL_AVX   2
 

Typedefs

typedef struct
_PHP_BASE_THREAD_CONTEXT 
PHP_BASE_THREAD_CONTEXT
 
typedef struct
_PHP_BASE_THREAD_CONTEXT * 
PPHP_BASE_THREAD_CONTEXT
 

Functions

VOID NTAPI PhpListDeleteProcedure (_In_ PVOID Object, _In_ ULONG Flags)
 
VOID NTAPI PhpPointerListDeleteProcedure (_In_ PVOID Object, _In_ ULONG Flags)
 
VOID NTAPI PhpQueueDeleteProcedure (_In_ PVOID Object, _In_ ULONG Flags)
 
VOID NTAPI PhpHashtableDeleteProcedure (_In_ PVOID Object, _In_ ULONG Flags)
 
BOOLEAN PhInitializeBase (_In_ ULONG Flags)
 Initializes the base support module.
 
NTSTATUS PhpBaseThreadStart (_In_ PVOID Parameter)
 
HANDLE PhCreateThread (_In_opt_ SIZE_T StackSize, _In_ PUSER_THREAD_START_ROUTINE StartAddress, _In_opt_ PVOID Parameter)
 Creates a thread.
 
VOID PhQuerySystemTime (_Out_ PLARGE_INTEGER SystemTime)
 Gets the current system time (UTC).
 
VOID PhQueryTimeZoneBias (_Out_ PLARGE_INTEGER TimeZoneBias)
 Gets the offset of the current time zone from UTC.
 
VOID PhSystemTimeToLocalTime (_In_ PLARGE_INTEGER SystemTime, _Out_ PLARGE_INTEGER LocalTime)
 Converts system time to local time.
 
VOID PhLocalTimeToSystemTime (_In_ PLARGE_INTEGER LocalTime, _Out_ PLARGE_INTEGER SystemTime)
 Converts local time to system time.
 
_May_raise_ _Check_return_
_Ret_notnull_ 
_Post_writable_byte_size_ (Size)
 Allocates a block of memory.
 
PVOID PhAllocateSafe (_In_ SIZE_T Size)
 Allocates a block of memory.
 
PVOID PhAllocateExSafe (_In_ SIZE_T Size, _In_ ULONG Flags)
 Allocates a block of memory.
 
VOID PhFree (_Frees_ptr_opt_ PVOID Memory)
 Frees a block of memory allocated with PhAllocate().
 
PVOID PhReAllocateSafe (_In_ PVOID Memory, _In_ SIZE_T Size)
 Re-allocates a block of memory originally allocated with PhAllocate().
 
_Check_return_ _Ret_maybenull_
PVOID 
PhAllocatePage (_In_ SIZE_T Size, _Out_opt_ PSIZE_T NewSize)
 Allocates pages of memory.
 
VOID PhFreePage (_Frees_ptr_opt_ PVOID Memory)
 Frees pages of memory allocated with PhAllocatePage().
 
SIZE_T PhCountStringZ (_In_ PWSTR String)
 Determines the length of the specified string, in characters.
 
PSTR PhDuplicateBytesZ (_In_ PSTR String)
 Allocates space for and copies a byte string.
 
PSTR PhDuplicateBytesZSafe (_In_ PSTR String)
 Allocates space for and copies a byte string.
 
PWSTR PhDuplicateStringZ (_In_ PWSTR String)
 Allocates space for and copies a 16-bit string.
 
BOOLEAN PhCopyBytesZ (_In_ PSTR InputBuffer, _In_ SIZE_T InputCount, _Out_writes_opt_z_(OutputCount) PSTR OutputBuffer, _In_ SIZE_T OutputCount, _Out_opt_ PSIZE_T ReturnCount)
 Copies a string with optional null termination and a maximum number of characters.
 
BOOLEAN PhCopyStringZ (_In_ PWSTR InputBuffer, _In_ SIZE_T InputCount, _Out_writes_opt_z_(OutputCount) PWSTR OutputBuffer, _In_ SIZE_T OutputCount, _Out_opt_ PSIZE_T ReturnCount)
 Copies a string with optional null termination and a maximum number of characters.
 
BOOLEAN PhCopyStringZFromBytes (_In_ PSTR InputBuffer, _In_ SIZE_T InputCount, _Out_writes_opt_z_(OutputCount) PWSTR OutputBuffer, _In_ SIZE_T OutputCount, _Out_opt_ PSIZE_T ReturnCount)
 Copies a string with optional null termination and a maximum number of characters.
 
BOOLEAN PhCopyStringZFromMultiByte (_In_ PSTR InputBuffer, _In_ SIZE_T InputCount, _Out_writes_opt_z_(OutputCount) PWSTR OutputBuffer, _In_ SIZE_T OutputCount, _Out_opt_ PSIZE_T ReturnCount)
 Copies a string with optional null termination and a maximum number of characters.
 
FORCEINLINE LONG PhpCompareRightNatural (_In_ PWSTR A, _In_ PWSTR B)
 
FORCEINLINE LONG PhpCompareLeftNatural (_In_ PWSTR A, _In_ PWSTR B)
 
FORCEINLINE LONG PhpCompareStringZNatural (_In_ PWSTR A, _In_ PWSTR B, _In_ BOOLEAN IgnoreCase)
 
LONG PhCompareStringZNatural (_In_ PWSTR A, _In_ PWSTR B, _In_ BOOLEAN IgnoreCase)
 Compares two strings in natural sort order.
 
LONG PhCompareStringRef (_In_ PPH_STRINGREF String1, _In_ PPH_STRINGREF String2, _In_ BOOLEAN IgnoreCase)
 Compares two strings.
 
BOOLEAN PhEqualStringRef (_In_ PPH_STRINGREF String1, _In_ PPH_STRINGREF String2, _In_ BOOLEAN IgnoreCase)
 Determines if two strings are equal.
 
ULONG_PTR PhFindCharInStringRef (_In_ PPH_STRINGREF String, _In_ WCHAR Character, _In_ BOOLEAN IgnoreCase)
 Locates a character in a string.
 
ULONG_PTR PhFindLastCharInStringRef (_In_ PPH_STRINGREF String, _In_ WCHAR Character, _In_ BOOLEAN IgnoreCase)
 Locates a character in a string, searching backwards.
 
ULONG_PTR PhFindStringInStringRef (_In_ PPH_STRINGREF String, _In_ PPH_STRINGREF SubString, _In_ BOOLEAN IgnoreCase)
 Locates a string in a string.
 
BOOLEAN PhSplitStringRefAtChar (_In_ PPH_STRINGREF Input, _In_ WCHAR Separator, _Out_ PPH_STRINGREF FirstPart, _Out_ PPH_STRINGREF SecondPart)
 Splits a string.
 
BOOLEAN PhSplitStringRefAtLastChar (_In_ PPH_STRINGREF Input, _In_ WCHAR Separator, _Out_ PPH_STRINGREF FirstPart, _Out_ PPH_STRINGREF SecondPart)
 Splits a string at the last occurrence of a character.
 
BOOLEAN PhSplitStringRefAtString (_In_ PPH_STRINGREF Input, _In_ PPH_STRINGREF Separator, _In_ BOOLEAN IgnoreCase, _Out_ PPH_STRINGREF FirstPart, _Out_ PPH_STRINGREF SecondPart)
 Splits a string.
 
BOOLEAN PhSplitStringRefEx (_In_ PPH_STRINGREF Input, _In_ PPH_STRINGREF Separator, _In_ ULONG Flags, _Out_ PPH_STRINGREF FirstPart, _Out_ PPH_STRINGREF SecondPart, _Out_opt_ PPH_STRINGREF SeparatorPart)
 Splits a string.
 
VOID PhTrimStringRef (_Inout_ PPH_STRINGREF String, _In_ PPH_STRINGREF CharSet, _In_ ULONG Flags)
 
PPH_STRING PhCreateString (_In_ PWSTR Buffer)
 Creates a string object from an existing null-terminated string.
 
PPH_STRING PhCreateStringEx (_In_opt_ PWCHAR Buffer, _In_ SIZE_T Length)
 Creates a string object using a specified length.
 
PPH_STRING PhReferenceEmptyString (VOID)
 Obtains a reference to a zero-length string.
 
PPH_STRING PhConcatStrings (_In_ ULONG Count,...)
 Concatenates multiple strings.
 
PPH_STRING PhConcatStrings_V (_In_ ULONG Count, _In_ va_list ArgPtr)
 Concatenates multiple strings.
 
PPH_STRING PhConcatStrings2 (_In_ PWSTR String1, _In_ PWSTR String2)
 Concatenates two strings.
 
PPH_STRING PhConcatStringRef2 (_In_ PPH_STRINGREF String1, _In_ PPH_STRINGREF String2)
 Concatenates two strings.
 
PPH_STRING PhConcatStringRef3 (_In_ PPH_STRINGREF String1, _In_ PPH_STRINGREF String2, _In_ PPH_STRINGREF String3)
 Concatenates three strings.
 
PPH_STRING PhFormatString (_In_ _Printf_format_string_ PWSTR Format,...)
 Creates a string using format specifiers.
 
PPH_STRING PhFormatString_V (_In_ _Printf_format_string_ PWSTR Format, _In_ va_list ArgPtr)
 Creates a string using format specifiers.
 
PPH_BYTES PhCreateBytes (_In_ PSTR Buffer)
 Creates a bytes object from an existing null-terminated string of bytes.
 
PPH_BYTES PhCreateBytesEx (_In_opt_ PCHAR Buffer, _In_ SIZE_T Length)
 Creates a bytes object.
 
BOOLEAN PhWriteUnicodeDecoder (_Inout_ PPH_UNICODE_DECODER Decoder, _In_ ULONG CodeUnit)
 
BOOLEAN PhpReadUnicodeDecoder (_Inout_ PPH_UNICODE_DECODER Decoder, _Out_ PULONG CodeUnit)
 
VOID PhpUnreadUnicodeDecoder (_Inout_ PPH_UNICODE_DECODER Decoder, _In_ ULONG CodeUnit)
 
BOOLEAN PhpDecodeUtf8Error (_Inout_ PPH_UNICODE_DECODER Decoder, _Out_ PULONG CodePoint, _In_ ULONG Which)
 
BOOLEAN PhDecodeUnicodeDecoder (_Inout_ PPH_UNICODE_DECODER Decoder, _Out_ PULONG CodePoint)
 
BOOLEAN PhEncodeUnicode (_In_ UCHAR Encoding, _In_ ULONG CodePoint, _Out_opt_ PVOID CodeUnits, _Out_ PULONG NumberOfCodeUnits)
 
VOID PhZeroExtendToUtf16Buffer (_In_reads_bytes_(InputLength) PSTR Input, _In_ SIZE_T InputLength, _Out_writes_bytes_(InputLength *sizeof(WCHAR)) PWSTR Output)
 Converts an ASCII string to a UTF-16 string by zero-extending each byte.
 
PPH_STRING PhZeroExtendToUtf16Ex (_In_reads_bytes_(InputLength) PCH Input, _In_ SIZE_T InputLength)
 
PPH_BYTES PhConvertUtf16ToAsciiEx (_In_ PWCH Buffer, _In_ SIZE_T Length, _In_opt_ CHAR Replacement)
 
PPH_STRING PhConvertMultiByteToUtf16 (_In_ PSTR Buffer)
 Creates a string object from an existing null-terminated multi-byte string.
 
PPH_STRING PhConvertMultiByteToUtf16Ex (_In_ PCHAR Buffer, _In_ SIZE_T Length)
 Creates a string object from an existing null-terminated multi-byte string.
 
PPH_BYTES PhConvertUtf16ToMultiByte (_In_ PWSTR Buffer)
 Creates a multi-byte string from an existing null-terminated UTF-16 string.
 
PPH_BYTES PhConvertUtf16ToMultiByteEx (_In_ PWCHAR Buffer, _In_ SIZE_T Length)
 Creates a multi-byte string from an existing null-terminated UTF-16 string.
 
BOOLEAN PhConvertUtf8ToUtf16Size (_Out_ PSIZE_T BytesInUtf16String, _In_reads_bytes_(BytesInUtf8String) PCH Utf8String, _In_ SIZE_T BytesInUtf8String)
 
BOOLEAN PhConvertUtf8ToUtf16Buffer (_Out_writes_bytes_to_(MaxBytesInUtf16String,*BytesInUtf16String) PWCH Utf16String, _In_ SIZE_T MaxBytesInUtf16String, _Out_opt_ PSIZE_T BytesInUtf16String, _In_reads_bytes_(BytesInUtf8String) PCH Utf8String, _In_ SIZE_T BytesInUtf8String)
 
PPH_STRING PhConvertUtf8ToUtf16 (_In_ PSTR Buffer)
 
PPH_STRING PhConvertUtf8ToUtf16Ex (_In_ PCHAR Buffer, _In_ SIZE_T Length)
 
BOOLEAN PhConvertUtf16ToUtf8Size (_Out_ PSIZE_T BytesInUtf8String, _In_reads_bytes_(BytesInUtf16String) PWCH Utf16String, _In_ SIZE_T BytesInUtf16String)
 
BOOLEAN PhConvertUtf16ToUtf8Buffer (_Out_writes_bytes_to_(MaxBytesInUtf8String,*BytesInUtf8String) PCH Utf8String, _In_ SIZE_T MaxBytesInUtf8String, _Out_opt_ PSIZE_T BytesInUtf8String, _In_reads_bytes_(BytesInUtf16String) PWCH Utf16String, _In_ SIZE_T BytesInUtf16String)
 
PPH_BYTES PhConvertUtf16ToUtf8 (_In_ PWSTR Buffer)
 
PPH_BYTES PhConvertUtf16ToUtf8Ex (_In_ PWCHAR Buffer, _In_ SIZE_T Length)
 
VOID PhInitializeStringBuilder (_Out_ PPH_STRING_BUILDER StringBuilder, _In_ SIZE_T InitialCapacity)
 Initializes a string builder object.
 
VOID PhDeleteStringBuilder (_Inout_ PPH_STRING_BUILDER StringBuilder)
 Frees resources used by a string builder object.
 
PPH_STRING PhFinalStringBuilderString (_Inout_ PPH_STRING_BUILDER StringBuilder)
 Obtains a reference to the string constructed by a string builder object and frees resources used by the object.
 
VOID PhpResizeStringBuilder (_In_ PPH_STRING_BUILDER StringBuilder, _In_ SIZE_T NewCapacity)
 
FORCEINLINE VOID PhpWriteNullTerminatorStringBuilder (_In_ PPH_STRING_BUILDER StringBuilder)
 
VOID PhAppendStringBuilder (_Inout_ PPH_STRING_BUILDER StringBuilder, _In_ PPH_STRINGREF String)
 Appends a string to the end of a string builder string.
 
VOID PhAppendStringBuilder2 (_Inout_ PPH_STRING_BUILDER StringBuilder, _In_ PWSTR String)
 Appends a string to the end of a string builder string.
 
VOID PhAppendStringBuilderEx (_Inout_ PPH_STRING_BUILDER StringBuilder, _In_opt_ PWCHAR String, _In_ SIZE_T Length)
 Appends a string to the end of a string builder string.
 
VOID PhAppendCharStringBuilder (_Inout_ PPH_STRING_BUILDER StringBuilder, _In_ WCHAR Character)
 Appends a character to the end of a string builder string.
 
VOID PhAppendCharStringBuilder2 (_Inout_ PPH_STRING_BUILDER StringBuilder, _In_ WCHAR Character, _In_ SIZE_T Count)
 Appends a number of characters to the end of a string builder string.
 
VOID PhAppendFormatStringBuilder (_Inout_ PPH_STRING_BUILDER StringBuilder, _In_ _Printf_format_string_ PWSTR Format,...)
 Appends a formatted string to the end of a string builder string.
 
VOID PhAppendFormatStringBuilder_V (_Inout_ PPH_STRING_BUILDER StringBuilder, _In_ _Printf_format_string_ PWSTR Format, _In_ va_list ArgPtr)
 
VOID PhInsertStringBuilder (_Inout_ PPH_STRING_BUILDER StringBuilder, _In_ SIZE_T Index, _In_ PPH_STRINGREF String)
 Inserts a string into a string builder string.
 
VOID PhInsertStringBuilder2 (_Inout_ PPH_STRING_BUILDER StringBuilder, _In_ SIZE_T Index, _In_ PWSTR String)
 Inserts a string into a string builder string.
 
VOID PhInsertStringBuilderEx (_Inout_ PPH_STRING_BUILDER StringBuilder, _In_ SIZE_T Index, _In_opt_ PWCHAR String, _In_ SIZE_T Length)
 Inserts a string into a string builder string.
 
VOID PhRemoveStringBuilder (_Inout_ PPH_STRING_BUILDER StringBuilder, _In_ SIZE_T StartIndex, _In_ SIZE_T Count)
 Removes characters from a string builder string.
 
VOID PhInitializeBytesBuilder (_Out_ PPH_BYTES_BUILDER BytesBuilder, _In_ SIZE_T InitialCapacity)
 Initializes a byte string builder object.
 
VOID PhDeleteBytesBuilder (_Inout_ PPH_BYTES_BUILDER BytesBuilder)
 Frees resources used by a byte string builder object.
 
PPH_BYTES PhFinalBytesBuilderBytes (_Inout_ PPH_BYTES_BUILDER BytesBuilder)
 Obtains a reference to the byte string constructed by a byte string builder object and frees resources used by the object.
 
VOID PhpResizeBytesBuilder (_In_ PPH_BYTES_BUILDER BytesBuilder, _In_ SIZE_T NewCapacity)
 
FORCEINLINE VOID PhpWriteNullTerminatorBytesBuilder (_In_ PPH_BYTES_BUILDER BytesBuilder)
 
VOID PhAppendBytesBuilder (_Inout_ PPH_BYTES_BUILDER BytesBuilder, _In_ PPH_BYTESREF Bytes)
 Appends a byte string to the end of a byte string builder string.
 
VOID PhAppendBytesBuilder2 (_Inout_ PPH_BYTES_BUILDER BytesBuilder, _In_ PCHAR Bytes)
 Appends a byte string to the end of a byte string builder string.
 
PVOID PhAppendBytesBuilderEx (_Inout_ PPH_BYTES_BUILDER BytesBuilder, _In_opt_ PVOID Buffer, _In_ SIZE_T Length, _In_opt_ SIZE_T Alignment, _Out_opt_ PSIZE_T Offset)
 Appends a byte string to the end of a byte string builder string.
 
PPH_LIST PhCreateList (_In_ ULONG InitialCapacity)
 Creates a list object.
 
VOID PhResizeList (_Inout_ PPH_LIST List, _In_ ULONG NewCapacity)
 Resizes a list.
 
VOID PhAddItemList (_Inout_ PPH_LIST List, _In_ PVOID Item)
 Adds an item to a list.
 
VOID PhAddItemsList (_Inout_ PPH_LIST List, _In_ PVOID *Items, _In_ ULONG Count)
 Adds items to a list.
 
VOID PhClearList (_Inout_ PPH_LIST List)
 Clears a list.
 
 _Success_ (return!=-1)
 
VOID PhInsertItemList (_Inout_ PPH_LIST List, _In_ ULONG Index, _In_ PVOID Item)
 Inserts an item into a list.
 
VOID PhInsertItemsList (_Inout_ PPH_LIST List, _In_ ULONG Index, _In_ PVOID *Items, _In_ ULONG Count)
 Inserts items into a list.
 
VOID PhRemoveItemList (_Inout_ PPH_LIST List, _In_ ULONG Index)
 Removes an item from a list.
 
VOID PhRemoveItemsList (_Inout_ PPH_LIST List, _In_ ULONG StartIndex, _In_ ULONG Count)
 Removes items from a list.
 
PPH_POINTER_LIST PhCreatePointerList (_In_ ULONG InitialCapacity)
 Creates a pointer list object.
 
FORCEINLINE ULONG PhpDecodePointerListIndex (_In_ PVOID Index)
 Decodes an index stored in a free entry.
 
FORCEINLINE PVOID PhpEncodePointerListIndex (_In_ ULONG Index)
 Encodes an index for storage in a free entry.
 
FORCEINLINE HANDLE PhpPointerListIndexToHandle (_In_ ULONG Index)
 
FORCEINLINE ULONG PhpPointerListHandleToIndex (_In_ HANDLE Handle)
 
HANDLE PhAddItemPointerList (_Inout_ PPH_POINTER_LIST PointerList, _In_ PVOID Pointer)
 Adds a pointer to a pointer list.
 
BOOLEAN PhEnumPointerListEx (_In_ PPH_POINTER_LIST PointerList, _Inout_ PULONG EnumerationKey, _Out_ PVOID *Pointer, _Out_ PHANDLE PointerHandle)
 
HANDLE PhFindItemPointerList (_In_ PPH_POINTER_LIST PointerList, _In_ PVOID Pointer)
 Locates a pointer in a pointer list.
 
VOID PhRemoveItemPointerList (_Inout_ PPH_POINTER_LIST PointerList, _In_ HANDLE PointerHandle)
 Removes a pointer from a pointer list.
 
FORCEINLINE ULONG PhpValidateHash (_In_ ULONG Hash)
 
FORCEINLINE ULONG PhpIndexFromHash (_In_ PPH_HASHTABLE Hashtable, _In_ ULONG Hash)
 
FORCEINLINE ULONG PhpGetNumberOfBuckets (_In_ ULONG Capacity)
 
PPH_HASHTABLE PhCreateHashtable (_In_ ULONG EntrySize, _In_ PPH_HASHTABLE_COMPARE_FUNCTION CompareFunction, _In_ PPH_HASHTABLE_HASH_FUNCTION HashFunction, _In_ ULONG InitialCapacity)
 Creates a hashtable object.
 
VOID PhpResizeHashtable (_Inout_ PPH_HASHTABLE Hashtable, _In_ ULONG NewCapacity)
 
FORCEINLINE PVOID PhpAddEntryHashtable (_Inout_ PPH_HASHTABLE Hashtable, _In_ PVOID Entry, _In_ BOOLEAN CheckForDuplicate, _Out_opt_ PBOOLEAN Added)
 
PVOID PhAddEntryHashtable (_Inout_ PPH_HASHTABLE Hashtable, _In_ PVOID Entry)
 Adds an entry to a hashtable.
 
PVOID PhAddEntryHashtableEx (_Inout_ PPH_HASHTABLE Hashtable, _In_ PVOID Entry, _Out_opt_ PBOOLEAN Added)
 Adds an entry to a hashtable or returns an existing one.
 
VOID PhClearHashtable (_Inout_ PPH_HASHTABLE Hashtable)
 Clears a hashtable.
 
BOOLEAN PhEnumHashtable (_In_ PPH_HASHTABLE Hashtable, _Out_ PVOID *Entry, _Inout_ PULONG EnumerationKey)
 Enumerates the entries in a hashtable.
 
PVOID PhFindEntryHashtable (_In_ PPH_HASHTABLE Hashtable, _In_ PVOID Entry)
 Locates an entry in a hashtable.
 
BOOLEAN PhRemoveEntryHashtable (_Inout_ PPH_HASHTABLE Hashtable, _In_ PVOID Entry)
 Removes an entry from a hashtable.
 
ULONG PhHashBytes (_In_reads_(Length) PUCHAR Bytes, _In_ SIZE_T Length)
 Generates a hash code for a sequence of bytes.
 
ULONG PhHashStringRef (_In_ PPH_STRINGREF String, _In_ BOOLEAN IgnoreCase)
 Generates a hash code for a string.
 
BOOLEAN NTAPI PhpSimpleHashtableCompareFunction (_In_ PVOID Entry1, _In_ PVOID Entry2)
 
ULONG NTAPI PhpSimpleHashtableHashFunction (_In_ PVOID Entry)
 
PPH_HASHTABLE PhCreateSimpleHashtable (_In_ ULONG InitialCapacity)
 
PVOID PhAddItemSimpleHashtable (_Inout_ PPH_HASHTABLE SimpleHashtable, _In_opt_ PVOID Key, _In_opt_ PVOID Value)
 
PVOID * PhFindItemSimpleHashtable (_In_ PPH_HASHTABLE SimpleHashtable, _In_opt_ PVOID Key)
 
BOOLEAN PhRemoveItemSimpleHashtable (_Inout_ PPH_HASHTABLE SimpleHashtable, _In_opt_ PVOID Key)
 
VOID PhInitializeFreeList (_Out_ PPH_FREE_LIST FreeList, _In_ SIZE_T Size, _In_ ULONG MaximumCount)
 Initializes a free list object.
 
VOID PhDeleteFreeList (_Inout_ PPH_FREE_LIST FreeList)
 Frees resources used by a free list object.
 
PVOID PhAllocateFromFreeList (_Inout_ PPH_FREE_LIST FreeList)
 Allocates a block of memory from a free list.
 
VOID PhFreeToFreeList (_Inout_ PPH_FREE_LIST FreeList, _In_ PVOID Memory)
 Frees a block of memory to a free list.
 
VOID PhInitializeCallback (_Out_ PPH_CALLBACK Callback)
 Initializes a callback object.
 
VOID PhDeleteCallback (_Inout_ PPH_CALLBACK Callback)
 Frees resources used by a callback object.
 
VOID PhRegisterCallback (_Inout_ PPH_CALLBACK Callback, _In_ PPH_CALLBACK_FUNCTION Function, _In_opt_ PVOID Context, _Out_ PPH_CALLBACK_REGISTRATION Registration)
 Registers a callback function to be notified.
 
VOID PhRegisterCallbackEx (_Inout_ PPH_CALLBACK Callback, _In_ PPH_CALLBACK_FUNCTION Function, _In_opt_ PVOID Context, _In_ USHORT Flags, _Out_ PPH_CALLBACK_REGISTRATION Registration)
 Registers a callback function to be notified.
 
VOID PhUnregisterCallback (_Inout_ PPH_CALLBACK Callback, _Inout_ PPH_CALLBACK_REGISTRATION Registration)
 Unregisters a callback function.
 
VOID PhInvokeCallback (_In_ PPH_CALLBACK Callback, _In_opt_ PVOID Parameter)
 Notifies all registered callback functions.
 
ULONG PhGetPrimeNumber (_In_ ULONG Minimum)
 Retrieves a prime number bigger than or equal to the specified number.
 
ULONG PhRoundUpToPowerOfTwo (_In_ ULONG Number)
 Rounds up a number to the next power of two.
 
ULONG PhExponentiate (_In_ ULONG Base, _In_ ULONG Exponent)
 Performs exponentiation.
 
ULONG64 PhExponentiate64 (_In_ ULONG64 Base, _In_ ULONG Exponent)
 Performs 64-bit exponentiation.
 
BOOLEAN PhHexStringToBuffer (_In_ PPH_STRINGREF String, _Out_writes_bytes_(String->Length/sizeof(WCHAR)/2) PUCHAR Buffer)
 Converts a sequence of hexadecimal digits into a byte array.
 
PPH_STRING PhBufferToHexString (_In_reads_bytes_(Length) PUCHAR Buffer, _In_ ULONG Length)
 Converts a byte array into a sequence of hexadecimal digits.
 
PPH_STRING PhBufferToHexStringEx (_In_reads_bytes_(Length) PUCHAR Buffer, _In_ ULONG Length, _In_ BOOLEAN UpperCase)
 Converts a byte array into a sequence of hexadecimal digits.
 
BOOLEAN PhpStringToInteger64 (_In_ PPH_STRINGREF String, _In_ ULONG Base, _Out_ PULONG64 Integer)
 Converts a string to an integer.
 
BOOLEAN PhStringToInteger64 (_In_ PPH_STRINGREF String, _In_opt_ ULONG Base, _Out_opt_ PLONG64 Integer)
 Converts a string to an integer.
 
PPH_STRING PhIntegerToString64 (_In_ LONG64 Integer, _In_opt_ ULONG Base, _In_ BOOLEAN Signed)
 Converts an integer to a string.
 
VOID PhPrintTimeSpan (_Out_writes_(PH_TIMESPAN_STR_LEN_1) PWSTR Destination, _In_ ULONG64 Ticks, _In_opt_ ULONG Mode)
 
VOID PhFillMemoryUlong (_Inout_updates_(Count) _Needs_align_(4) PULONG Memory, _In_ ULONG Value, _In_ SIZE_T Count)
 Fills a memory block with a ULONG pattern.
 
VOID FASTCALL PhxfFillMemoryUlong (PULONG Memory, ULONG Value, ULONG Count)
 Deprecated.
 
VOID PhDivideSinglesBySingle (_Inout_updates_(Count) PFLOAT A, _In_ FLOAT B, _In_ SIZE_T Count)
 Divides an array of numbers by a number.
 
VOID FASTCALL PhxfDivideSingle2U (PFLOAT A, FLOAT B, ULONG Count)
 Deprecated.
 

Variables

PPH_OBJECT_TYPE PhStringType
 
PPH_OBJECT_TYPE PhBytesType
 
PPH_OBJECT_TYPE PhListType
 
PPH_OBJECT_TYPE PhPointerListType
 
PPH_OBJECT_TYPE PhHashtableType
 

Macro Definition Documentation

#define PH_VECTOR_LEVEL_AVX   2

Definition at line 71 of file basesup.c.

#define PH_VECTOR_LEVEL_NONE   0

Definition at line 69 of file basesup.c.

#define PH_VECTOR_LEVEL_SSE2   1

Definition at line 70 of file basesup.c.

Typedef Documentation

typedef struct _PHP_BASE_THREAD_CONTEXT PHP_BASE_THREAD_CONTEXT
typedef struct _PHP_BASE_THREAD_CONTEXT * PPHP_BASE_THREAD_CONTEXT

Function Documentation

_May_raise_ _Post_writable_byte_size_ ( Size  )

Allocates a block of memory.

Re-allocates a block of memory originally allocated with PhAllocate().

Parameters
SizeThe number of bytes to allocate.
Returns
A pointer to the allocated block of memory.
Remarks
If the function fails to allocate the block of memory, it raises an exception. The block is guaranteed to be aligned at MEMORY_ALLOCATION_ALIGNMENT bytes.
Parameters
MemoryA pointer to a block of memory.
SizeThe new size of the memory block, in bytes.
Returns
A pointer to the new block of memory. The existing contents of the memory block are copied to the new block.
Remarks
If the function fails to allocate the block of memory, it raises an exception.

Definition at line 360 of file basesup.c.

_Success_ ( return!  = -1)

Definition at line 4109 of file basesup.c.

PVOID PhAddEntryHashtable ( _Inout_ PPH_HASHTABLE  Hashtable,
_In_ PVOID  Entry 
)

Adds an entry to a hashtable.

Parameters
HashtableA hashtable object.
EntryThe entry to add.
Returns
A pointer to the entry as stored in the hashtable. This pointer is valid until the hashtable is modified. If the hashtable already contained an equal entry, NULL is returned.
Remarks
Entries are only guaranteed to be 8 byte aligned, even on 64-bit systems.

Definition at line 4668 of file basesup.c.

PVOID PhAddEntryHashtableEx ( _Inout_ PPH_HASHTABLE  Hashtable,
_In_ PVOID  Entry,
_Out_opt_ PBOOLEAN  Added 
)

Adds an entry to a hashtable or returns an existing one.

Parameters
HashtableA hashtable object.
EntryThe entry to add.
AddedA variable which receives TRUE if a new entry was created, and FALSE if an existing entry was returned.
Returns
A pointer to the entry as stored in the hashtable. This pointer is valid until the hashtable is modified. If the hashtable already contained an equal entry, the existing entry is returned. Check the value of Added to determine whether the returned entry is new or existing.
Remarks
Entries are only guaranteed to be 8 byte aligned, even on 64-bit systems.

Definition at line 4703 of file basesup.c.

VOID PhAddItemList ( _Inout_ PPH_LIST  List,
_In_ PVOID  Item 
)

Adds an item to a list.

Parameters
ListA list object.
ItemThe item to add.

Definition at line 4049 of file basesup.c.

HANDLE PhAddItemPointerList ( _Inout_ PPH_POINTER_LIST  PointerList,
_In_ PVOID  Pointer 
)

Adds a pointer to a pointer list.

Parameters
PointerListA pointer list object.
PointerThe pointer to add. The pointer must be at least 2 byte aligned.
Returns
A handle to the pointer, valid until the pointer is removed from the pointer list.

Definition at line 4322 of file basesup.c.

PVOID PhAddItemSimpleHashtable ( _Inout_ PPH_HASHTABLE  SimpleHashtable,
_In_opt_ PVOID  Key,
_In_opt_ PVOID  Value 
)

Definition at line 4972 of file basesup.c.

VOID PhAddItemsList ( _Inout_ PPH_LIST  List,
_In_ PVOID *  Items,
_In_ ULONG  Count 
)

Adds items to a list.

Parameters
ListA list object.
ItemsAn array containing the items to add.
CountThe number of items to add.

Definition at line 4071 of file basesup.c.

PVOID PhAllocateExSafe ( _In_ SIZE_T  Size,
_In_ ULONG  Flags 
)

Allocates a block of memory.

Parameters
SizeThe number of bytes to allocate.
FlagsFlags controlling the allocation.
Returns
A pointer to the allocated block of memory, or NULL if the block could not be allocated.

Definition at line 392 of file basesup.c.

PVOID PhAllocateFromFreeList ( _Inout_ PPH_FREE_LIST  FreeList)

Allocates a block of memory from a free list.

Parameters
FreeListA pointer to a free list object.
Returns
A pointer to the allocated block of memory. The memory must be freed using PhFreeToFreeList(). The block is guaranteed to be aligned at MEMORY_ALLOCATION_ALIGNMENT bytes.

Definition at line 5070 of file basesup.c.

_Check_return_ _Ret_maybenull_ PVOID PhAllocatePage ( _In_ SIZE_T  Size,
_Out_opt_ PSIZE_T  NewSize 
)

Allocates pages of memory.

Parameters
SizeThe number of bytes to allocate. The number of pages allocated will be large enough to contain Size bytes.
NewSizeThe number of bytes actually allocated. This is Size rounded up to the next multiple of PAGE_SIZE.
Returns
A pointer to the allocated block of memory, or NULL if the block could not be allocated.

Definition at line 472 of file basesup.c.

PVOID PhAllocateSafe ( _In_ SIZE_T  Size)

Allocates a block of memory.

Parameters
SizeThe number of bytes to allocate.
Returns
A pointer to the allocated block of memory, or NULL if the block could not be allocated.

Definition at line 376 of file basesup.c.

VOID PhAppendBytesBuilder ( _Inout_ PPH_BYTES_BUILDER  BytesBuilder,
_In_ PPH_BYTESREF  Bytes 
)

Appends a byte string to the end of a byte string builder string.

Parameters
BytesBuilderA byte string builder object.
BytesThe byte string to append.

Definition at line 3905 of file basesup.c.

VOID PhAppendBytesBuilder2 ( _Inout_ PPH_BYTES_BUILDER  BytesBuilder,
_In_ PCHAR  Bytes 
)

Appends a byte string to the end of a byte string builder string.

Parameters
BytesBuilderA byte string builder object.
BytesThe byte string to append.

Definition at line 3925 of file basesup.c.

PVOID PhAppendBytesBuilderEx ( _Inout_ PPH_BYTES_BUILDER  BytesBuilder,
_In_opt_ PVOID  Buffer,
_In_ SIZE_T  Length,
_In_opt_ SIZE_T  Alignment,
_Out_opt_ PSIZE_T  Offset 
)

Appends a byte string to the end of a byte string builder string.

Parameters
BytesBuilderA byte string builder object.
BufferThe byte string to append. Specify NULL to simply reserve Length bytes.
LengthThe number of bytes to append.
AlignmentThe required alignment. This should not be greater than 8.
OffsetA variable which receives the byte offset of the appended or reserved bytes in the byte string builder string.
Returns
A pointer to the appended or reserved bytes.

Definition at line 3951 of file basesup.c.

VOID PhAppendCharStringBuilder ( _Inout_ PPH_STRING_BUILDER  StringBuilder,
_In_ WCHAR  Character 
)

Appends a character to the end of a string builder string.

Parameters
StringBuilderA string builder object.
CharacterThe character to append.

Definition at line 3597 of file basesup.c.

VOID PhAppendCharStringBuilder2 ( _Inout_ PPH_STRING_BUILDER  StringBuilder,
_In_ WCHAR  Character,
_In_ SIZE_T  Count 
)

Appends a number of characters to the end of a string builder string.

Parameters
StringBuilderA string builder object.
CharacterThe character to append.
CountThe number of times to append the character.

Definition at line 3620 of file basesup.c.

VOID PhAppendFormatStringBuilder ( _Inout_ PPH_STRING_BUILDER  StringBuilder,
_In_ _Printf_format_string_ PWSTR  Format,
  ... 
)

Appends a formatted string to the end of a string builder string.

Parameters
StringBuilderA string builder object.
FormatThe format-control string.

Definition at line 3652 of file basesup.c.

VOID PhAppendFormatStringBuilder_V ( _Inout_ PPH_STRING_BUILDER  StringBuilder,
_In_ _Printf_format_string_ PWSTR  Format,
_In_ va_list  ArgPtr 
)

Definition at line 3664 of file basesup.c.

VOID PhAppendStringBuilder ( _Inout_ PPH_STRING_BUILDER  StringBuilder,
_In_ PPH_STRINGREF  String 
)

Appends a string to the end of a string builder string.

Parameters
StringBuilderA string builder object.
StringThe string to append.

Definition at line 3523 of file basesup.c.

VOID PhAppendStringBuilder2 ( _Inout_ PPH_STRING_BUILDER  StringBuilder,
_In_ PWSTR  String 
)

Appends a string to the end of a string builder string.

Parameters
StringBuilderA string builder object.
StringThe string to append.

Definition at line 3541 of file basesup.c.

VOID PhAppendStringBuilderEx ( _Inout_ PPH_STRING_BUILDER  StringBuilder,
_In_opt_ PWCHAR  String,
_In_ SIZE_T  Length 
)

Appends a string to the end of a string builder string.

Parameters
StringBuilderA string builder object.
StringThe string to append. Specify NULL to simply reserve Length bytes.
LengthThe number of bytes to append.

Definition at line 3560 of file basesup.c.

PPH_STRING PhBufferToHexString ( _In_reads_bytes_(Length) PUCHAR  Buffer,
_In_ ULONG  Length 
)

Converts a byte array into a sequence of hexadecimal digits.

Parameters
BufferThe input buffer.
LengthThe number of bytes to convert.
Returns
A string containing a sequence of hexadecimal digits.

Definition at line 5437 of file basesup.c.

PPH_STRING PhBufferToHexStringEx ( _In_reads_bytes_(Length) PUCHAR  Buffer,
_In_ ULONG  Length,
_In_ BOOLEAN  UpperCase 
)

Converts a byte array into a sequence of hexadecimal digits.

Parameters
BufferThe input buffer.
LengthThe number of bytes to convert.
UpperCaseTRUE to use uppercase characters, otherwise FALSE.
Returns
A string containing a sequence of hexadecimal digits.

Definition at line 5454 of file basesup.c.

VOID PhClearHashtable ( _Inout_ PPH_HASHTABLE  Hashtable)

Clears a hashtable.

Parameters
HashtableA hashtable object.

Definition at line 4717 of file basesup.c.

VOID PhClearList ( _Inout_ PPH_LIST  List)

Clears a list.

Parameters
ListA list object.

Definition at line 4102 of file basesup.c.

LONG PhCompareStringRef ( _In_ PPH_STRINGREF  String1,
_In_ PPH_STRINGREF  String2,
_In_ BOOLEAN  IgnoreCase 
)

Compares two strings.

Parameters
String1The first string.
String2The second string.
IgnoreCaseTRUE to perform a case-insensitive comparison, otherwise FALSE.

Definition at line 1145 of file basesup.c.

LONG PhCompareStringZNatural ( _In_ PWSTR  A,
_In_ PWSTR  B,
_In_ BOOLEAN  IgnoreCase 
)

Compares two strings in natural sort order.

Parameters
AThe first string.
BThe second string.
IgnoreCaseWhether to ignore character cases.

Definition at line 1125 of file basesup.c.

PPH_STRING PhConcatStringRef2 ( _In_ PPH_STRINGREF  String1,
_In_ PPH_STRINGREF  String2 
)

Concatenates two strings.

Parameters
String1The first string.
String2The second string.

Definition at line 2344 of file basesup.c.

PPH_STRING PhConcatStringRef3 ( _In_ PPH_STRINGREF  String1,
_In_ PPH_STRINGREF  String2,
_In_ PPH_STRINGREF  String3 
)

Concatenates three strings.

Parameters
String1The first string.
String2The second string.
String3The third string.

Definition at line 2368 of file basesup.c.

PPH_STRING PhConcatStrings ( _In_ ULONG  Count,
  ... 
)

Concatenates multiple strings.

Parameters
CountThe number of strings to concatenate.

Definition at line 2232 of file basesup.c.

PPH_STRING PhConcatStrings2 ( _In_ PWSTR  String1,
_In_ PWSTR  String2 
)

Concatenates two strings.

Parameters
String1The first string.
String2The second string.

Definition at line 2312 of file basesup.c.

PPH_STRING PhConcatStrings_V ( _In_ ULONG  Count,
_In_ va_list  ArgPtr 
)

Concatenates multiple strings.

Parameters
CountThe number of strings to concatenate.
ArgPtrA pointer to an array of strings.

Definition at line 2250 of file basesup.c.

PPH_STRING PhConvertMultiByteToUtf16 ( _In_ PSTR  Buffer)

Creates a string object from an existing null-terminated multi-byte string.

Parameters
BufferA null-terminated multi-byte string.

Definition at line 2998 of file basesup.c.

PPH_STRING PhConvertMultiByteToUtf16Ex ( _In_ PCHAR  Buffer,
_In_ SIZE_T  Length 
)

Creates a string object from an existing null-terminated multi-byte string.

Parameters
BufferA null-terminated multi-byte string.
LengthThe number of bytes to use.

Definition at line 3014 of file basesup.c.

PPH_BYTES PhConvertUtf16ToAsciiEx ( _In_ PWCH  Buffer,
_In_ SIZE_T  Length,
_In_opt_ CHAR  Replacement 
)

Definition at line 2945 of file basesup.c.

PPH_BYTES PhConvertUtf16ToMultiByte ( _In_ PWSTR  Buffer)

Creates a multi-byte string from an existing null-terminated UTF-16 string.

Parameters
BufferA null-terminated UTF-16 string.

Definition at line 3055 of file basesup.c.

PPH_BYTES PhConvertUtf16ToMultiByteEx ( _In_ PWCHAR  Buffer,
_In_ SIZE_T  Length 
)

Creates a multi-byte string from an existing null-terminated UTF-16 string.

Parameters
BufferA null-terminated UTF-16 string.
LengthThe number of bytes to use.

Definition at line 3071 of file basesup.c.

PPH_BYTES PhConvertUtf16ToUtf8 ( _In_ PWSTR  Buffer)

Definition at line 3367 of file basesup.c.

BOOLEAN PhConvertUtf16ToUtf8Buffer ( _Out_writes_bytes_to_(MaxBytesInUtf8String,*BytesInUtf8String) PCH  Utf8String,
_In_ SIZE_T  MaxBytesInUtf8String,
_Out_opt_ PSIZE_T  BytesInUtf8String,
_In_reads_bytes_(BytesInUtf16String) PWCH  Utf16String,
_In_ SIZE_T  BytesInUtf16String 
)

Definition at line 3297 of file basesup.c.

PPH_BYTES PhConvertUtf16ToUtf8Ex ( _In_ PWCHAR  Buffer,
_In_ SIZE_T  Length 
)

Definition at line 3377 of file basesup.c.

BOOLEAN PhConvertUtf16ToUtf8Size ( _Out_ PSIZE_T  BytesInUtf8String,
_In_reads_bytes_(BytesInUtf16String) PWCH  Utf16String,
_In_ SIZE_T  BytesInUtf16String 
)

Definition at line 3257 of file basesup.c.

PPH_STRING PhConvertUtf8ToUtf16 ( _In_ PSTR  Buffer)

Definition at line 3213 of file basesup.c.

BOOLEAN PhConvertUtf8ToUtf16Buffer ( _Out_writes_bytes_to_(MaxBytesInUtf16String,*BytesInUtf16String) PWCH  Utf16String,
_In_ SIZE_T  MaxBytesInUtf16String,
_Out_opt_ PSIZE_T  BytesInUtf16String,
_In_reads_bytes_(BytesInUtf8String) PCH  Utf8String,
_In_ SIZE_T  BytesInUtf8String 
)

Definition at line 3147 of file basesup.c.

PPH_STRING PhConvertUtf8ToUtf16Ex ( _In_ PCHAR  Buffer,
_In_ SIZE_T  Length 
)

Definition at line 3223 of file basesup.c.

BOOLEAN PhConvertUtf8ToUtf16Size ( _Out_ PSIZE_T  BytesInUtf16String,
_In_reads_bytes_(BytesInUtf8String) PCH  Utf8String,
_In_ SIZE_T  BytesInUtf8String 
)

Definition at line 3107 of file basesup.c.

BOOLEAN PhCopyBytesZ ( _In_ PSTR  InputBuffer,
_In_ SIZE_T  InputCount,
_Out_writes_opt_z_(OutputCount) PSTR  OutputBuffer,
_In_ SIZE_T  OutputCount,
_Out_opt_ PSIZE_T  ReturnCount 
)

Copies a string with optional null termination and a maximum number of characters.

Parameters
InputBufferA pointer to the input string.
InputCountThe maximum number of characters to copy, not including the null terminator. Specify -1 for no limit.
OutputBufferA pointer to the output buffer.
OutputCountThe number of characters in the output buffer, including the null terminator.
ReturnCountA variable which receives the number of characters required to contain the input string, including the null terminator. If the function returns TRUE, this variable contains the number of characters written to the output buffer.
Returns
TRUE if the input string was copied to the output string, otherwise FALSE.
Remarks
The function stops copying when it encounters the first null character in the input string. It will also stop copying when it reaches the character count specified in InputCount, if InputCount is not -1.

Definition at line 671 of file basesup.c.

BOOLEAN PhCopyStringZ ( _In_ PWSTR  InputBuffer,
_In_ SIZE_T  InputCount,
_Out_writes_opt_z_(OutputCount) PWSTR  OutputBuffer,
_In_ SIZE_T  OutputCount,
_Out_opt_ PSIZE_T  ReturnCount 
)

Copies a string with optional null termination and a maximum number of characters.

Parameters
InputBufferA pointer to the input string.
InputCountThe maximum number of characters to copy, not including the null terminator. Specify -1 for no limit.
OutputBufferA pointer to the output buffer.
OutputCountThe number of characters in the output buffer, including the null terminator.
ReturnCountA variable which receives the number of characters required to contain the input string, including the null terminator. If the function returns TRUE, this variable contains the number of characters written to the output buffer.
Returns
TRUE if the input string was copied to the output string, otherwise FALSE.
Remarks
The function stops copying when it encounters the first null character in the input string. It will also stop copying when it reaches the character count specified in InputCount, if InputCount is not -1.

Definition at line 741 of file basesup.c.

BOOLEAN PhCopyStringZFromBytes ( _In_ PSTR  InputBuffer,
_In_ SIZE_T  InputCount,
_Out_writes_opt_z_(OutputCount) PWSTR  OutputBuffer,
_In_ SIZE_T  OutputCount,
_Out_opt_ PSIZE_T  ReturnCount 
)

Copies a string with optional null termination and a maximum number of characters.

Parameters
InputBufferA pointer to the input string.
InputCountThe maximum number of characters to copy, not including the null terminator. Specify -1 for no limit.
OutputBufferA pointer to the output buffer.
OutputCountThe number of characters in the output buffer, including the null terminator.
ReturnCountA variable which receives the number of characters required to contain the input string, including the null terminator. If the function returns TRUE, this variable contains the number of characters written to the output buffer.
Returns
TRUE if the input string was copied to the output string, otherwise FALSE.
Remarks
The function stops copying when it encounters the first null character in the input string. It will also stop copying when it reaches the character count specified in InputCount, if InputCount is not -1.

Definition at line 811 of file basesup.c.

BOOLEAN PhCopyStringZFromMultiByte ( _In_ PSTR  InputBuffer,
_In_ SIZE_T  InputCount,
_Out_writes_opt_z_(OutputCount) PWSTR  OutputBuffer,
_In_ SIZE_T  OutputCount,
_Out_opt_ PSIZE_T  ReturnCount 
)

Copies a string with optional null termination and a maximum number of characters.

Parameters
InputBufferA pointer to the input string.
InputCountThe maximum number of characters to copy, not including the null terminator. Specify -1 for no limit.
OutputBufferA pointer to the output buffer.
OutputCountThe number of characters in the output buffer, including the null terminator.
ReturnCountA variable which receives the number of characters required to contain the input string, including the null terminator. If the function returns TRUE, this variable contains the number of characters written to the output buffer.
Returns
TRUE if the input string was copied to the output string, otherwise FALSE.
Remarks
The function stops copying when it encounters the first null character in the input string. It will also stop copying when it reaches the character count specified in InputCount, if InputCount is not -1.

Definition at line 881 of file basesup.c.

SIZE_T PhCountStringZ ( _In_ PWSTR  String)

Determines the length of the specified string, in characters.

Parameters
StringThe string.

Definition at line 527 of file basesup.c.

PPH_BYTES PhCreateBytes ( _In_ PSTR  Buffer)

Creates a bytes object from an existing null-terminated string of bytes.

Parameters
BufferA null-terminated byte string.

Definition at line 2443 of file basesup.c.

PPH_BYTES PhCreateBytesEx ( _In_opt_ PCHAR  Buffer,
_In_ SIZE_T  Length 
)

Creates a bytes object.

Parameters
BufferAn array of bytes.
LengthThe length of Buffer, in bytes.

Definition at line 2456 of file basesup.c.

PPH_HASHTABLE PhCreateHashtable ( _In_ ULONG  EntrySize,
_In_ PPH_HASHTABLE_COMPARE_FUNCTION  CompareFunction,
_In_ PPH_HASHTABLE_HASH_FUNCTION  HashFunction,
_In_ ULONG  InitialCapacity 
)

Creates a hashtable object.

Parameters
EntrySizeThe size of each hashtable entry, in bytes.
CompareFunctionA comparison function that is executed to compare two hashtable entries.
HashFunctionA hash function that is executed to generate a hash code for a hashtable entry.
InitialCapacityThe number of entries to allocate storage for initially.

Definition at line 4495 of file basesup.c.

PPH_LIST PhCreateList ( _In_ ULONG  InitialCapacity)

Creates a list object.

Parameters
InitialCapacityThe number of elements to allocate storage for initially.

Definition at line 3994 of file basesup.c.

PPH_POINTER_LIST PhCreatePointerList ( _In_ ULONG  InitialCapacity)

Creates a pointer list object.

Parameters
InitialCapacityThe number of elements to allocate storage for initially.

Definition at line 4241 of file basesup.c.

PPH_HASHTABLE PhCreateSimpleHashtable ( _In_ ULONG  InitialCapacity)

Definition at line 4960 of file basesup.c.

PPH_STRING PhCreateString ( _In_ PWSTR  Buffer)

Creates a string object from an existing null-terminated string.

Parameters
BufferA null-terminated Unicode string.

Definition at line 2154 of file basesup.c.

PPH_STRING PhCreateStringEx ( _In_opt_ PWCHAR  Buffer,
_In_ SIZE_T  Length 
)

Creates a string object using a specified length.

Parameters
BufferA null-terminated Unicode string.
LengthThe length, in bytes, of the string.

Definition at line 2167 of file basesup.c.

HANDLE PhCreateThread ( _In_opt_ SIZE_T  StackSize,
_In_ PUSER_THREAD_START_ROUTINE  StartAddress,
_In_opt_ PVOID  Parameter 
)

Creates a thread.

Parameters
StackSizeThe initial stack size of the thread.
StartAddressThe function to execute in the thread.
ParameterA user-defined value to pass to the function.

Definition at line 236 of file basesup.c.

BOOLEAN PhDecodeUnicodeDecoder ( _Inout_ PPH_UNICODE_DECODER  Decoder,
_Out_ PULONG  CodePoint 
)

Definition at line 2597 of file basesup.c.

VOID PhDeleteBytesBuilder ( _Inout_ PPH_BYTES_BUILDER  BytesBuilder)

Frees resources used by a byte string builder object.

Parameters
BytesBuilderA byte string builder object.

Definition at line 3836 of file basesup.c.

VOID PhDeleteCallback ( _Inout_ PPH_CALLBACK  Callback)

Frees resources used by a callback object.

Parameters
CallbackA pointer to a callback object.

Definition at line 5139 of file basesup.c.

VOID PhDeleteFreeList ( _Inout_ PPH_FREE_LIST  FreeList)

Frees resources used by a free list object.

Parameters
FreeListA pointer to the free list object.

Definition at line 5043 of file basesup.c.

VOID PhDeleteStringBuilder ( _Inout_ PPH_STRING_BUILDER  StringBuilder)

Frees resources used by a string builder object.

Parameters
StringBuilderA string builder object.

Definition at line 3451 of file basesup.c.

VOID PhDivideSinglesBySingle ( _Inout_updates_(Count) PFLOAT  A,
_In_ FLOAT  B,
_In_ SIZE_T  Count 
)

Divides an array of numbers by a number.

Parameters
AThe destination array, divided by B.
BThe number.
CountThe number of elements.

Definition at line 5805 of file basesup.c.

PSTR PhDuplicateBytesZ ( _In_ PSTR  String)

Allocates space for and copies a byte string.

Parameters
StringThe string to duplicate.
Returns
The new string, which can be freed using PhFree().

Definition at line 581 of file basesup.c.

PSTR PhDuplicateBytesZSafe ( _In_ PSTR  String)

Allocates space for and copies a byte string.

Parameters
StringThe string to duplicate.
Returns
The new string, which can be freed using PhFree(), or NULL if storage could not be allocated.

Definition at line 604 of file basesup.c.

PWSTR PhDuplicateStringZ ( _In_ PWSTR  String)

Allocates space for and copies a 16-bit string.

Parameters
StringThe string to duplicate.
Returns
The new string, which can be freed using PhFree().

Definition at line 630 of file basesup.c.

BOOLEAN PhEncodeUnicode ( _In_ UCHAR  Encoding,
_In_ ULONG  CodePoint,
_Out_opt_ PVOID  CodeUnits,
_Out_ PULONG  NumberOfCodeUnits 
)

Definition at line 2794 of file basesup.c.

BOOLEAN PhEnumHashtable ( _In_ PPH_HASHTABLE  Hashtable,
_Out_ PVOID *  Entry,
_Inout_ PULONG  EnumerationKey 
)

Enumerates the entries in a hashtable.

Parameters
HashtableA hashtable object.
EntryA variable which receives a pointer to the hashtable entry. The pointer is valid until the hashtable is modified.
EnumerationKeyA variable which is initialized to 0 before first calling this function.
Returns
TRUE if an entry pointer was stored in Entry, FALSE if there are no more entries.
Remarks
Do not modify the hashtable while the hashtable is being enumerated (between calls to this function). Otherwise, the function may behave unexpectedly. You may reset the EnumerationKey variable to 0 if you wish to restart the enumeration.

Definition at line 4751 of file basesup.c.

BOOLEAN PhEnumPointerListEx ( _In_ PPH_POINTER_LIST  PointerList,
_Inout_ PULONG  EnumerationKey,
_Out_ PVOID *  Pointer,
_Out_ PHANDLE  PointerHandle 
)

Definition at line 4359 of file basesup.c.

BOOLEAN PhEqualStringRef ( _In_ PPH_STRINGREF  String1,
_In_ PPH_STRINGREF  String2,
_In_ BOOLEAN  IgnoreCase 
)

Determines if two strings are equal.

Parameters
String1The first string.
String2The second string.
IgnoreCaseTRUE to perform a case-insensitive comparison, otherwise FALSE.

Definition at line 1217 of file basesup.c.

ULONG PhExponentiate ( _In_ ULONG  Base,
_In_ ULONG  Exponent 
)

Performs exponentiation.

Definition at line 5354 of file basesup.c.

ULONG64 PhExponentiate64 ( _In_ ULONG64  Base,
_In_ ULONG  Exponent 
)

Performs 64-bit exponentiation.

Definition at line 5376 of file basesup.c.

VOID PhFillMemoryUlong ( _Inout_updates_(Count) _Needs_align_(4) PULONG  Memory,
_In_ ULONG  Value,
_In_ SIZE_T  Count 
)

Fills a memory block with a ULONG pattern.

Parameters
MemoryThe memory block. The block must be 4 byte aligned.
ValueThe ULONG pattern.
CountThe number of elements.

Definition at line 5717 of file basesup.c.

PPH_BYTES PhFinalBytesBuilderBytes ( _Inout_ PPH_BYTES_BUILDER  BytesBuilder)

Obtains a reference to the byte string constructed by a byte string builder object and frees resources used by the object.

Parameters
BytesBuilderA byte string builder object.
Returns
A pointer to a byte string. You must free the byte string using PhDereferenceObject() when you no longer need it.

Definition at line 3854 of file basesup.c.

PPH_STRING PhFinalStringBuilderString ( _Inout_ PPH_STRING_BUILDER  StringBuilder)

Obtains a reference to the string constructed by a string builder object and frees resources used by the object.

Parameters
StringBuilderA string builder object.
Returns
A pointer to a string. You must free the string using PhDereferenceObject() when you no longer need it.

Definition at line 3469 of file basesup.c.

ULONG_PTR PhFindCharInStringRef ( _In_ PPH_STRINGREF  String,
_In_ WCHAR  Character,
_In_ BOOLEAN  IgnoreCase 
)

Locates a character in a string.

Parameters
StringThe string to search.
CharacterThe character to search for.
IgnoreCaseTRUE to perform a case-insensitive search, otherwise FALSE.
Returns
The index, in characters, of the first occurrence of Character in String1. If Character was not found, -1 is returned.

Definition at line 1366 of file basesup.c.

PVOID PhFindEntryHashtable ( _In_ PPH_HASHTABLE  Hashtable,
_In_ PVOID  Entry 
)

Locates an entry in a hashtable.

Parameters
HashtableA hashtable object.
EntryAn entry representing the entry to find.
Returns
A pointer to the entry as stored in the hashtable. This pointer is valid until the hashtable is modified. If the entry could not be found, NULL is returned.
Remarks
The entry specified in Entry can be a partial entry that is filled in enough so that the comparison and hash functions can work with them.

Definition at line 4790 of file basesup.c.

HANDLE PhFindItemPointerList ( _In_ PPH_POINTER_LIST  PointerList,
_In_ PVOID  Pointer 
)

Locates a pointer in a pointer list.

Parameters
PointerListA pointer list object.
PointerThe pointer to find. The pointer must be at least 2 byte aligned.
Returns
A handle to the pointer, valid until the pointer is removed from the pointer list. If the pointer is not contained in the pointer list, NULL is returned.

Definition at line 4398 of file basesup.c.

PVOID* PhFindItemSimpleHashtable ( _In_ PPH_HASHTABLE  SimpleHashtable,
_In_opt_ PVOID  Key 
)

Definition at line 4989 of file basesup.c.

ULONG_PTR PhFindLastCharInStringRef ( _In_ PPH_STRINGREF  String,
_In_ WCHAR  Character,
_In_ BOOLEAN  IgnoreCase 
)

Locates a character in a string, searching backwards.

Parameters
StringThe string to search.
CharacterThe character to search for.
IgnoreCaseTRUE to perform a case-insensitive search, otherwise FALSE.
Returns
The index, in characters, of the last occurrence of Character in String1. If Character was not found, -1 is returned.

Definition at line 1452 of file basesup.c.

ULONG_PTR PhFindStringInStringRef ( _In_ PPH_STRINGREF  String,
_In_ PPH_STRINGREF  SubString,
_In_ BOOLEAN  IgnoreCase 
)

Locates a string in a string.

Parameters
StringThe string to search.
SubStringThe string to search for.
IgnoreCaseTRUE to perform a case-insensitive search, otherwise FALSE.
Returns
The index, in characters, of the first occurrence of SubString in String. If SubString was not found, -1 is returned.

Definition at line 1545 of file basesup.c.

PPH_STRING PhFormatString ( _In_ _Printf_format_string_ PWSTR  Format,
  ... 
)

Creates a string using format specifiers.

Parameters
FormatThe format-control string.

Definition at line 2400 of file basesup.c.

PPH_STRING PhFormatString_V ( _In_ _Printf_format_string_ PWSTR  Format,
_In_ va_list  ArgPtr 
)

Creates a string using format specifiers.

Parameters
FormatThe format-control string.
ArgPtrA pointer to the list of arguments.

Definition at line 2418 of file basesup.c.

VOID PhFree ( _Frees_ptr_opt_ PVOID  Memory)

Frees a block of memory allocated with PhAllocate().

Parameters
MemoryA pointer to a block of memory.

Definition at line 406 of file basesup.c.

VOID PhFreePage ( _Frees_ptr_opt_ PVOID  Memory)

Frees pages of memory allocated with PhAllocatePage().

Parameters
MemoryA pointer to a block of memory.

Definition at line 506 of file basesup.c.

VOID PhFreeToFreeList ( _Inout_ PPH_FREE_LIST  FreeList,
_In_ PVOID  Memory 
)

Frees a block of memory to a free list.

Parameters
FreeListA pointer to a free list object.
MemoryA pointer to a block of memory.

Definition at line 5098 of file basesup.c.

ULONG PhGetPrimeNumber ( _In_ ULONG  Minimum)

Retrieves a prime number bigger than or equal to the specified number.

Definition at line 5299 of file basesup.c.

ULONG PhHashBytes ( _In_reads_(Length) PUCHAR  Bytes,
_In_ SIZE_T  Length 
)

Generates a hash code for a sequence of bytes.

Parameters
BytesA pointer to a byte array.
LengthThe number of bytes to hash.

Definition at line 4882 of file basesup.c.

ULONG PhHashStringRef ( _In_ PPH_STRINGREF  String,
_In_ BOOLEAN  IgnoreCase 
)

Generates a hash code for a string.

Parameters
StringThe string to hash.
IgnoreCaseTRUE for a case-insensitive hash function, otherwise FALSE.

Definition at line 4909 of file basesup.c.

BOOLEAN PhHexStringToBuffer ( _In_ PPH_STRINGREF  String,
_Out_writes_bytes_(String->Length/sizeof(WCHAR)/2) PUCHAR  Buffer 
)

Converts a sequence of hexadecimal digits into a byte array.

Parameters
StringA string containing hexadecimal digits to convert. The string must have an even number of digits, because each pair of hexadecimal digits represents one byte. Example: "129a2eff5c0b".
BufferThe output buffer.
Returns
TRUE if the string was successfully converted, otherwise FALSE.

Definition at line 5405 of file basesup.c.

BOOLEAN PhInitializeBase ( _In_ ULONG  Flags)

Initializes the base support module.

Definition at line 138 of file basesup.c.

VOID PhInitializeBytesBuilder ( _Out_ PPH_BYTES_BUILDER  BytesBuilder,
_In_ SIZE_T  InitialCapacity 
)

Initializes a byte string builder object.

Parameters
BytesBuilderA byte string builder object.
InitialCapacityThe number of bytes to allocate initially.

Definition at line 3820 of file basesup.c.

VOID PhInitializeCallback ( _Out_ PPH_CALLBACK  Callback)

Initializes a callback object.

Parameters
CallbackA pointer to a callback object.

Definition at line 5125 of file basesup.c.

VOID PhInitializeFreeList ( _Out_ PPH_FREE_LIST  FreeList,
_In_ SIZE_T  Size,
_In_ ULONG  MaximumCount 
)

Initializes a free list object.

Parameters
FreeListA pointer to the free list object.
SizeThe number of bytes in each allocation.
MaximumCountThe number of unused allocations to store.

Definition at line 5026 of file basesup.c.

VOID PhInitializeStringBuilder ( _Out_ PPH_STRING_BUILDER  StringBuilder,
_In_ SIZE_T  InitialCapacity 
)

Initializes a string builder object.

Parameters
StringBuilderA string builder object.
InitialCapacityThe number of bytes to allocate initially.

Definition at line 3418 of file basesup.c.

VOID PhInsertItemList ( _Inout_ PPH_LIST  List,
_In_ ULONG  Index,
_In_ PVOID  Item 
)

Inserts an item into a list.

Parameters
ListA list object.
IndexThe index at which to insert the item.
ItemThe item to add.

Definition at line 4142 of file basesup.c.

VOID PhInsertItemsList ( _Inout_ PPH_LIST  List,
_In_ ULONG  Index,
_In_ PVOID *  Items,
_In_ ULONG  Count 
)

Inserts items into a list.

Parameters
ListA list object.
IndexThe index at which to insert the items.
ItemsAn array containing the items to add.
CountThe number of items to add.

Definition at line 4159 of file basesup.c.

VOID PhInsertStringBuilder ( _Inout_ PPH_STRING_BUILDER  StringBuilder,
_In_ SIZE_T  Index,
_In_ PPH_STRINGREF  String 
)

Inserts a string into a string builder string.

Parameters
StringBuilderA string builder object.
IndexThe index, in characters, at which to insert the string.
StringThe string to insert.

Definition at line 3702 of file basesup.c.

VOID PhInsertStringBuilder2 ( _Inout_ PPH_STRING_BUILDER  StringBuilder,
_In_ SIZE_T  Index,
_In_ PWSTR  String 
)

Inserts a string into a string builder string.

Parameters
StringBuilderA string builder object.
IndexThe index, in characters, at which to insert the string.
StringThe string to insert.

Definition at line 3724 of file basesup.c.

VOID PhInsertStringBuilderEx ( _Inout_ PPH_STRING_BUILDER  StringBuilder,
_In_ SIZE_T  Index,
_In_opt_ PWCHAR  String,
_In_ SIZE_T  Length 
)

Inserts a string into a string builder string.

Parameters
StringBuilderA string builder object.
IndexThe index, in characters, at which to insert the string.
StringThe string to insert. Specify NULL to simply reserve Length bytes at Index.
LengthThe number of bytes to insert.

Definition at line 3748 of file basesup.c.

PPH_STRING PhIntegerToString64 ( _In_ LONG64  Integer,
_In_opt_ ULONG  Base,
_In_ BOOLEAN  Signed 
)

Converts an integer to a string.

Parameters
IntegerThe integer to process.
BaseThe base which the integer is represented with. The maximum value is
  1. The base cannot be 1. If the parameter is 0, the base used is 10.
SignedTRUE if Integer is a signed value, otherwise FALSE.
Returns
The resulting string, or NULL if an error occurred.

Definition at line 5642 of file basesup.c.

VOID PhInvokeCallback ( _In_ PPH_CALLBACK  Callback,
_In_opt_ PVOID  Parameter 
)

Notifies all registered callback functions.

Parameters
CallbackA pointer to a callback object.
ParameterA value to pass to all callback functions.

Definition at line 5246 of file basesup.c.

VOID PhLocalTimeToSystemTime ( _In_ PLARGE_INTEGER  LocalTime,
_Out_ PLARGE_INTEGER  SystemTime 
)

Converts local time to system time.

Parameters
LocalTimeA local time value.
SystemTimeA variable which receives the UTC time value. This may be the same variable as LocalTime.
Remarks
Use this function instead of RtlLocalTimeToSystemTime() because no system calls are involved.

Definition at line 333 of file basesup.c.

FORCEINLINE PVOID PhpAddEntryHashtable ( _Inout_ PPH_HASHTABLE  Hashtable,
_In_ PVOID  Entry,
_In_ BOOLEAN  CheckForDuplicate,
_Out_opt_ PBOOLEAN  Added 
)

Definition at line 4584 of file basesup.c.

NTSTATUS PhpBaseThreadStart ( _In_ PVOID  Parameter)

Definition at line 180 of file basesup.c.

FORCEINLINE LONG PhpCompareLeftNatural ( _In_ PWSTR  A,
_In_ PWSTR  B 
)

Definition at line 998 of file basesup.c.

FORCEINLINE LONG PhpCompareRightNatural ( _In_ PWSTR  A,
_In_ PWSTR  B 
)

Definition at line 958 of file basesup.c.

FORCEINLINE LONG PhpCompareStringZNatural ( _In_ PWSTR  A,
_In_ PWSTR  B,
_In_ BOOLEAN  IgnoreCase 
)

Definition at line 1030 of file basesup.c.

FORCEINLINE ULONG PhpDecodePointerListIndex ( _In_ PVOID  Index)

Decodes an index stored in a free entry.

Definition at line 4275 of file basesup.c.

BOOLEAN PhpDecodeUtf8Error ( _Inout_ PPH_UNICODE_DECODER  Decoder,
_Out_ PULONG  CodePoint,
_In_ ULONG  Which 
)

Definition at line 2578 of file basesup.c.

FORCEINLINE PVOID PhpEncodePointerListIndex ( _In_ ULONG  Index)

Encodes an index for storage in a free entry.

Definition at line 4289 of file basesup.c.

FORCEINLINE ULONG PhpGetNumberOfBuckets ( _In_ ULONG  Capacity)

Definition at line 4472 of file basesup.c.

VOID PhpHashtableDeleteProcedure ( _In_ PVOID  Object,
_In_ ULONG  Flags 
)

Definition at line 4531 of file basesup.c.

FORCEINLINE ULONG PhpIndexFromHash ( _In_ PPH_HASHTABLE  Hashtable,
_In_ ULONG  Hash 
)

Definition at line 4460 of file basesup.c.

VOID PhpListDeleteProcedure ( _In_ PVOID  Object,
_In_ ULONG  Flags 
)

Definition at line 4013 of file basesup.c.

VOID NTAPI PhpPointerListDeleteProcedure ( _In_ PVOID  Object,
_In_ ULONG  Flags 
)

Definition at line 4262 of file basesup.c.

FORCEINLINE ULONG PhpPointerListHandleToIndex ( _In_ HANDLE  Handle)

Definition at line 4305 of file basesup.c.

FORCEINLINE HANDLE PhpPointerListIndexToHandle ( _In_ ULONG  Index)

Definition at line 4296 of file basesup.c.

VOID NTAPI PhpQueueDeleteProcedure ( _In_ PVOID  Object,
_In_ ULONG  Flags 
)
BOOLEAN PhpReadUnicodeDecoder ( _Inout_ PPH_UNICODE_DECODER  Decoder,
_Out_ PULONG  CodeUnit 
)

Definition at line 2510 of file basesup.c.

VOID PhpResizeBytesBuilder ( _In_ PPH_BYTES_BUILDER  BytesBuilder,
_In_ SIZE_T  NewCapacity 
)

Definition at line 3861 of file basesup.c.

VOID PhpResizeHashtable ( _Inout_ PPH_HASHTABLE  Hashtable,
_In_ ULONG  NewCapacity 
)

Definition at line 4542 of file basesup.c.

VOID PhpResizeStringBuilder ( _In_ PPH_STRING_BUILDER  StringBuilder,
_In_ SIZE_T  NewCapacity 
)

Definition at line 3476 of file basesup.c.

VOID PhPrintTimeSpan ( _Out_writes_(PH_TIMESPAN_STR_LEN_1) PWSTR  Destination,
_In_ ULONG64  Ticks,
_In_opt_ ULONG  Mode 
)

Definition at line 5667 of file basesup.c.

BOOLEAN NTAPI PhpSimpleHashtableCompareFunction ( _In_ PVOID  Entry1,
_In_ PVOID  Entry2 
)

Definition at line 4940 of file basesup.c.

ULONG NTAPI PhpSimpleHashtableHashFunction ( _In_ PVOID  Entry)

Definition at line 4951 of file basesup.c.

BOOLEAN PhpStringToInteger64 ( _In_ PPH_STRINGREF  String,
_In_ ULONG  Base,
_Out_ PULONG64  Integer 
)

Converts a string to an integer.

Parameters
StringThe string to process.
BaseThe base which the string uses to represent the integer. The maximum value is 69.
IntegerThe resulting integer.

Definition at line 5489 of file basesup.c.

VOID PhpUnreadUnicodeDecoder ( _Inout_ PPH_UNICODE_DECODER  Decoder,
_In_ ULONG  CodeUnit 
)

Definition at line 2544 of file basesup.c.

FORCEINLINE ULONG PhpValidateHash ( _In_ ULONG  Hash)

Definition at line 4444 of file basesup.c.

FORCEINLINE VOID PhpWriteNullTerminatorBytesBuilder ( _In_ PPH_BYTES_BUILDER  BytesBuilder)

Definition at line 3892 of file basesup.c.

FORCEINLINE VOID PhpWriteNullTerminatorStringBuilder ( _In_ PPH_STRING_BUILDER  StringBuilder)

Definition at line 3509 of file basesup.c.

VOID PhQuerySystemTime ( _Out_ PLARGE_INTEGER  SystemTime)

Gets the current system time (UTC).

Remarks
Use this function instead of NtQuerySystemTime() because no system calls are involved.

Definition at line 277 of file basesup.c.

VOID PhQueryTimeZoneBias ( _Out_ PLARGE_INTEGER  TimeZoneBias)

Gets the offset of the current time zone from UTC.

Definition at line 291 of file basesup.c.

PVOID PhReAllocateSafe ( _In_ PVOID  Memory,
_In_ SIZE_T  Size 
)

Re-allocates a block of memory originally allocated with PhAllocate().

Parameters
MemoryA pointer to a block of memory.
SizeThe new size of the memory block, in bytes.
Returns
A pointer to the new block of memory, or NULL if the block could not be allocated. The existing contents of the memory block are copied to the new block.

Definition at line 451 of file basesup.c.

PPH_STRING PhReferenceEmptyString ( VOID  )

Obtains a reference to a zero-length string.

Definition at line 2195 of file basesup.c.

VOID PhRegisterCallback ( _Inout_ PPH_CALLBACK  Callback,
_In_ PPH_CALLBACK_FUNCTION  Function,
_In_opt_ PVOID  Context,
_Out_ PPH_CALLBACK_REGISTRATION  Registration 
)

Registers a callback function to be notified.

Parameters
CallbackA pointer to a callback object.
FunctionThe callback function.
ContextA user-defined value to pass to the callback function.
RegistrationA variable which receives registration information for the callback. Do not modify the contents of this structure and do not free the storage for this structure until you have unregistered the callback.

Definition at line 5159 of file basesup.c.

VOID PhRegisterCallbackEx ( _Inout_ PPH_CALLBACK  Callback,
_In_ PPH_CALLBACK_FUNCTION  Function,
_In_opt_ PVOID  Context,
_In_ USHORT  Flags,
_Out_ PPH_CALLBACK_REGISTRATION  Registration 
)

Registers a callback function to be notified.

Parameters
CallbackA pointer to a callback object.
FunctionThe callback function.
ContextA user-defined value to pass to the callback function.
FlagsA combination of flags controlling the callback. Set this parameter to 0.
RegistrationA variable which receives registration information for the callback. Do not modify the contents of this structure and do not free the storage for this structure until you have unregistered the callback.

Definition at line 5190 of file basesup.c.

BOOLEAN PhRemoveEntryHashtable ( _Inout_ PPH_HASHTABLE  Hashtable,
_In_ PVOID  Entry 
)

Removes an entry from a hashtable.

Parameters
HashtableA hashtable object.
EntryThe entry to remove.
Returns
TRUE if the entry was removed, FALSE if the entry could not be found.
Remarks
The entry specified in Entry can be an actual entry pointer returned by PhFindEntryHashtable, or a partial entry.

Definition at line 4830 of file basesup.c.

VOID PhRemoveItemList ( _Inout_ PPH_LIST  List,
_In_ ULONG  Index 
)

Removes an item from a list.

Parameters
ListA list object.
IndexThe index of the item.

Definition at line 4203 of file basesup.c.

VOID PhRemoveItemPointerList ( _Inout_ PPH_POINTER_LIST  PointerList,
_In_ HANDLE  PointerHandle 
)

Removes a pointer from a pointer list.

Parameters
PointerListA pointer list object.
PointerHandleA handle to the pointer to remove.
Remarks
No checking is performed on the pointer handle. Make sure the handle is valid before calling the function.

Definition at line 4427 of file basesup.c.

BOOLEAN PhRemoveItemSimpleHashtable ( _Inout_ PPH_HASHTABLE  SimpleHashtable,
_In_opt_ PVOID  Key 
)

Definition at line 5006 of file basesup.c.

VOID PhRemoveItemsList ( _Inout_ PPH_LIST  List,
_In_ ULONG  StartIndex,
_In_ ULONG  Count 
)

Removes items from a list.

Parameters
ListA list object.
StartIndexThe index at which to begin removing items.
CountThe number of items to remove.

Definition at line 4219 of file basesup.c.

VOID PhRemoveStringBuilder ( _Inout_ PPH_STRING_BUILDER  StringBuilder,
_In_ SIZE_T  StartIndex,
_In_ SIZE_T  Count 
)

Removes characters from a string builder string.

Parameters
StringBuilderA string builder object.
StartIndexThe index, in characters, at which to begin removing characters.
CountThe number of characters to remove.

Definition at line 3796 of file basesup.c.

VOID PhResizeList ( _Inout_ PPH_LIST  List,
_In_ ULONG  NewCapacity 
)

Resizes a list.

Parameters
ListA list object.
NewCapacityThe new required number of elements for which storage has been reserved. This must not be smaller than the current number of items in the list.

Definition at line 4031 of file basesup.c.

ULONG PhRoundUpToPowerOfTwo ( _In_ ULONG  Number)

Rounds up a number to the next power of two.

Definition at line 5336 of file basesup.c.

BOOLEAN PhSplitStringRefAtChar ( _In_ PPH_STRINGREF  Input,
_In_ WCHAR  Separator,
_Out_ PPH_STRINGREF  FirstPart,
_Out_ PPH_STRINGREF  SecondPart 
)

Splits a string.

Parameters
InputThe input string.
SeparatorThe character to split at.
FirstPartA variable which receives the part of Input before the separator. This may be the same variable as Input. If the separator is not found in Input, this variable is set to Input.
SecondPartA variable which recieves the part of Input after the separator. This may be the same variable as Input. If the separator is not found in Input, this variable is set to an empty string.
Returns
TRUE if Separator was found in Input, otherwise FALSE.

Definition at line 1619 of file basesup.c.

BOOLEAN PhSplitStringRefAtLastChar ( _In_ PPH_STRINGREF  Input,
_In_ WCHAR  Separator,
_Out_ PPH_STRINGREF  FirstPart,
_Out_ PPH_STRINGREF  SecondPart 
)

Splits a string at the last occurrence of a character.

Parameters
InputThe input string.
SeparatorThe character to split at.
FirstPartA variable which receives the part of Input before the separator. This may be the same variable as Input. If the separator is not found in Input, this variable is set to Input.
SecondPartA variable which recieves the part of Input after the separator. This may be the same variable as Input. If the separator is not found in Input, this variable is set to an empty string.
Returns
TRUE if Separator was found in Input, otherwise FALSE.

Definition at line 1668 of file basesup.c.

BOOLEAN PhSplitStringRefAtString ( _In_ PPH_STRINGREF  Input,
_In_ PPH_STRINGREF  Separator,
_In_ BOOLEAN  IgnoreCase,
_Out_ PPH_STRINGREF  FirstPart,
_Out_ PPH_STRINGREF  SecondPart 
)

Splits a string.

Parameters
InputThe input string.
SeparatorThe string to split at.
IgnoreCaseTRUE to perform a case-insensitive search, otherwise FALSE.
FirstPartA variable which receives the part of Input before the separator. This may be the same variable as Input. If the separator is not found in Input, this variable is set to Input.
SecondPartA variable which recieves the part of Input after the separator. This may be the same variable as Input. If the separator is not found in Input, this variable is set to an empty string.
Returns
TRUE if Separator was found in Input, otherwise FALSE.

Definition at line 1719 of file basesup.c.

BOOLEAN PhSplitStringRefEx ( _In_ PPH_STRINGREF  Input,
_In_ PPH_STRINGREF  Separator,
_In_ ULONG  Flags,
_Out_ PPH_STRINGREF  FirstPart,
_Out_ PPH_STRINGREF  SecondPart,
_Out_opt_ PPH_STRINGREF  SeparatorPart 
)

Splits a string.

Parameters
InputThe input string.
SeparatorThe character set, string or range to split at.
FlagsA combination of flags.
  • PH_SPLIT_AT_CHAR_SET Separator specifies a character set. Input will be split at a character which is contained in Separator.
  • PH_SPLIT_AT_STRING Separator specifies a string. Input will be split an occurrence of Separator.
  • PH_SPLIT_AT_RANGE Separator specifies a range. The Buffer field contains a character index cast to PWSTR and the Length field contains the length of the range, in bytes.
  • PH_SPLIT_CASE_INSENSITIVE Specifies a case-insensitive search.
  • PH_SPLIT_COMPLEMENT_CHAR_SET If used with PH_SPLIT_AT_CHAR_SET, the separator is a character which is not contained in Separator.
  • PH_SPLIT_START_AT_END If used with PH_SPLIT_AT_CHAR_SET, the search is performed starting from the end of the string.
  • PH_SPLIT_CHAR_SET_IS_UPPERCASE If used with PH_SPLIT_CASE_INSENSITIVE, specifies that the character set in Separator contains only uppercase characters.
FirstPartA variable which receives the part of Input before the separator. This may be the same variable as Input. If the separator is not found in Input, this variable is set to Input.
SecondPartA variable which recieves the part of Input after the separator. This may be the same variable as Input. If the separator is not found in Input, this variable is set to an empty string.
SeparatorPartA variable which receives the part of Input that is the separator. If the separator is not found in Input, this variable is set to an empty string.
Returns
TRUE if a separator was found in Input, otherwise FALSE.

Definition at line 1789 of file basesup.c.

BOOLEAN PhStringToInteger64 ( _In_ PPH_STRINGREF  String,
_In_opt_ ULONG  Base,
_Out_opt_ PLONG64  Integer 
)

Converts a string to an integer.

Parameters
StringThe string to process.
BaseThe base which the string uses to represent the integer. The maximum value is
  1. If the parameter is 0, the base is inferred from the string.
IntegerThe resulting integer.
Remarks
If Base is 0, the following prefixes may be used to indicate bases:
  • 0x Base 16.
  • 0o Base 8.
  • 0b Base 2.
  • 0t Base 3.
  • 0q Base 4.
  • 0w Base 12.
  • 0r Base 32.

If there is no recognized prefix, base 10 is used.

Definition at line 5544 of file basesup.c.

VOID PhSystemTimeToLocalTime ( _In_ PLARGE_INTEGER  SystemTime,
_Out_ PLARGE_INTEGER  LocalTime 
)

Converts system time to local time.

Parameters
SystemTimeA UTC time value.
LocalTimeA variable which receives the local time value. This may be the same variable as SystemTime.
Remarks
Use this function instead of RtlSystemTimeToLocalTime() because no system calls are involved.

Definition at line 312 of file basesup.c.

VOID PhTrimStringRef ( _Inout_ PPH_STRINGREF  String,
_In_ PPH_STRINGREF  CharSet,
_In_ ULONG  Flags 
)

Definition at line 2006 of file basesup.c.

VOID PhUnregisterCallback ( _Inout_ PPH_CALLBACK  Callback,
_Inout_ PPH_CALLBACK_REGISTRATION  Registration 
)

Unregisters a callback function.

Parameters
CallbackA pointer to a callback object.
RegistrationThe structure returned by PhRegisterCallback().
Remarks
It is guaranteed that the callback function will not be in execution once this function returns. Attempting to unregister a callback function from within the same function will result in a deadlock.

Definition at line 5221 of file basesup.c.

BOOLEAN PhWriteUnicodeDecoder ( _Inout_ PPH_UNICODE_DECODER  Decoder,
_In_ ULONG  CodeUnit 
)

Definition at line 2480 of file basesup.c.

VOID FASTCALL PhxfDivideSingle2U ( PFLOAT  A,
FLOAT  B,
ULONG  Count 
)

Deprecated.

Use PhDivideSinglesBySingle instead.

Definition at line 5882 of file basesup.c.

VOID FASTCALL PhxfFillMemoryUlong ( PULONG  Memory,
ULONG  Value,
ULONG  Count 
)

Deprecated.

Use PhFillMemoryUlong instead.

Definition at line 5793 of file basesup.c.

VOID PhZeroExtendToUtf16Buffer ( _In_reads_bytes_(InputLength) PSTR  Input,
_In_ SIZE_T  InputLength,
_Out_writes_bytes_(InputLength *sizeof(WCHAR)) PWSTR  Output 
)

Converts an ASCII string to a UTF-16 string by zero-extending each byte.

Parameters
InputThe original ASCII string.
InputLengthThe length of Input.
OutputA buffer which will contain the converted string.

Definition at line 2897 of file basesup.c.

PPH_STRING PhZeroExtendToUtf16Ex ( _In_reads_bytes_(InputLength) PCH  Input,
_In_ SIZE_T  InputLength 
)

Definition at line 2932 of file basesup.c.

Variable Documentation

PPH_OBJECT_TYPE PhBytesType

Definition at line 102 of file basesup.c.

PPH_OBJECT_TYPE PhHashtableType

Definition at line 105 of file basesup.c.

PPH_OBJECT_TYPE PhListType

Definition at line 103 of file basesup.c.

PPH_OBJECT_TYPE PhPointerListType

Definition at line 104 of file basesup.c.

PPH_OBJECT_TYPE PhStringType

Definition at line 101 of file basesup.c.