69 #define PH_VECTOR_LEVEL_NONE 0 
   70 #define PH_VECTOR_LEVEL_SSE2 1 
   71 #define PH_VECTOR_LEVEL_AVX 2 
   73 typedef struct _PHP_BASE_THREAD_CONTEXT
 
  116 ULONG PhDbgThreadDbgTlsIndex;
 
  117 LIST_ENTRY PhDbgThreadListHead;
 
  123 static ULONG PhpPrimeNumbers[] =
 
  125     0x3, 0x7, 0xb, 0x11, 0x17, 0x1d, 0x25, 0x2f, 0x3b, 0x47, 0x59, 0x6b, 0x83,
 
  126     0xa3, 0xc5, 0xef, 0x125, 0x161, 0x1af, 0x209, 0x277, 0x2f9, 0x397, 0x44f,
 
  127     0x52f, 0x63d, 0x78b, 0x91d, 0xaf1, 0xd2b, 0xfd1, 0x12fd, 0x16cf, 0x1b65,
 
  128     0x20e3, 0x2777, 0x2f6f, 0x38ff, 0x446f, 0x521f, 0x628d, 0x7655, 0x8e01,
 
  129     0xaa6b, 0xcc89, 0xf583, 0x126a7, 0x1619b, 0x1a857, 0x1fd3b, 0x26315, 0x2dd67,
 
  130     0x3701b, 0x42023, 0x4f361, 0x5f0ed, 0x72125, 0x88e31, 0xa443b, 0xc51eb,
 
  131     0xec8c1, 0x11bdbf, 0x154a3f, 0x198c4f, 0x1ea867, 0x24ca19, 0x2c25c1, 0x34fa1b,
 
  132     0x3f928f, 0x4c4987, 0x5b8b6f, 0x6dda89
 
  148  if (USER_SHARED_DATA->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE])
 
  168     PhDbgThreadDbgTlsIndex = TlsAlloc();
 
  188     PHP_BASE_THREAD_DBG dbg;
 
  195     dbg.ClientId = NtCurrentTeb()->ClientId;
 
  197     dbg.StartAddress = context.StartAddress;
 
  198     dbg.Parameter = context.Parameter;
 
  199     dbg.CurrentAutoPool = NULL;
 
  205     TlsSetValue(PhDbgThreadDbgTlsIndex, &dbg);
 
  210     result = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
 
  213     status = context.StartAddress(context.Parameter);
 
  217     if (result == S_OK || result == S_FALSE)
 
  237     _In_opt_ SIZE_T StackSize,
 
  239     _In_opt_ PVOID Parameter
 
  246     context->StartAddress = StartAddress;
 
  247     context->Parameter = Parameter;
 
  249     threadHandle = CreateThread(
 
  278     _Out_ PLARGE_INTEGER SystemTime
 
  283         SystemTime->HighPart = USER_SHARED_DATA->SystemTime.High1Time;
 
  284         SystemTime->LowPart = USER_SHARED_DATA->SystemTime.LowPart;
 
  285     } 
while (SystemTime->HighPart != USER_SHARED_DATA->SystemTime.High2Time);
 
  292     _Out_ PLARGE_INTEGER TimeZoneBias
 
  297         TimeZoneBias->HighPart = USER_SHARED_DATA->TimeZoneBias.High1Time;
 
  298         TimeZoneBias->LowPart = USER_SHARED_DATA->TimeZoneBias.LowPart;
 
  299     } 
while (TimeZoneBias->HighPart != USER_SHARED_DATA->TimeZoneBias.High2Time);
 
  313     _In_ PLARGE_INTEGER SystemTime,
 
  314     _Out_ PLARGE_INTEGER LocalTime
 
  317     LARGE_INTEGER timeZoneBias;
 
  320     LocalTime->QuadPart = SystemTime->QuadPart - timeZoneBias.QuadPart;
 
  334     _In_ PLARGE_INTEGER LocalTime,
 
  335     _Out_ PLARGE_INTEGER SystemTime
 
  338     LARGE_INTEGER timeZoneBias;
 
  341     SystemTime->QuadPart = LocalTime->QuadPart + timeZoneBias.QuadPart;
 
  407     _Frees_ptr_opt_ PVOID Memory
 
  431     _Frees_ptr_opt_ PVOID Memory,
 
  474     _Out_opt_ PSIZE_T NewSize
 
  507     _Frees_ptr_opt_ PVOID Memory
 
  540         p = (PWSTR)((ULONG_PTR)String & ~0xe); 
 
  541         unaligned = (ULONG)String & 0xf;
 
  542         z = _mm_setzero_si128();
 
  546             b = _mm_load_si128((__m128i *)p);
 
  547             b = _mm_cmpeq_epi16(b, z);
 
  548             mask = _mm_movemask_epi8(b) >> unaligned;
 
  550             if (_BitScanForward(&index, mask))
 
  551                 return index / 
sizeof(WCHAR);
 
  553             p += 16 / 
sizeof(WCHAR);
 
  558             b = _mm_load_si128((__m128i *)p);
 
  559             b = _mm_cmpeq_epi16(b, z);
 
  560             mask = _mm_movemask_epi8(b);
 
  562             if (_BitScanForward(&index, mask))
 
  563                 return (SIZE_T)(p - String) + index / 
sizeof(WCHAR);
 
  565             p += 16 / 
sizeof(WCHAR);
 
  570         return wcslen(String);
 
  588     length = strlen(String) + 1; 
 
  590     newString = PhAllocate(length);
 
  591     memcpy(newString, String, length);
 
  611     length = strlen(String) + 1; 
 
  618     memcpy(newString, String, length);
 
  639     newString = PhAllocate(length);
 
  640     memcpy(newString, String, length);
 
  672     _In_ PSTR InputBuffer,
 
  673     _In_ SIZE_T InputCount,
 
  674     _Out_writes_opt_z_(OutputCount) PSTR OutputBuffer,
 
  675     _In_ SIZE_T OutputCount,
 
  676     _Out_opt_ PSIZE_T ReturnCount
 
  684     if (InputCount != -1)
 
  688         while (i < InputCount && InputBuffer[i])
 
  693         i = strlen(InputBuffer);
 
  698     if (OutputBuffer && OutputCount >= i + 1) 
 
  700         memcpy(OutputBuffer, InputBuffer, i);
 
  710         *ReturnCount = i + 1;
 
  742     _In_ PWSTR InputBuffer,
 
  743     _In_ SIZE_T InputCount,
 
  744     _Out_writes_opt_z_(OutputCount) PWSTR OutputBuffer,
 
  745     _In_ SIZE_T OutputCount,
 
  746     _Out_opt_ PSIZE_T ReturnCount
 
  754     if (InputCount != -1)
 
  758         while (i < InputCount && InputBuffer[i])
 
  768     if (OutputBuffer && OutputCount >= i + 1) 
 
  770         memcpy(OutputBuffer, InputBuffer, i * 
sizeof(WCHAR));
 
  780         *ReturnCount = i + 1;
 
  812     _In_ PSTR InputBuffer,
 
  813     _In_ SIZE_T InputCount,
 
  814     _Out_writes_opt_z_(OutputCount) PWSTR OutputBuffer,
 
  815     _In_ SIZE_T OutputCount,
 
  816     _Out_opt_ PSIZE_T ReturnCount
 
  824     if (InputCount != -1)
 
  828         while (i < InputCount && InputBuffer[i])
 
  833         i = strlen(InputBuffer);
 
  838     if (OutputBuffer && OutputCount >= i + 1) 
 
  850         *ReturnCount = i + 1;
 
  882     _In_ PSTR InputBuffer,
 
  883     _In_ SIZE_T InputCount,
 
  884     _Out_writes_opt_z_(OutputCount) PWSTR OutputBuffer,
 
  885     _In_ SIZE_T OutputCount,
 
  886     _Out_opt_ PSIZE_T ReturnCount
 
  896     if (InputCount != -1)
 
  900         while (i < InputCount && InputBuffer[i])
 
  905         i = strlen(InputBuffer);
 
  926     if (OutputBuffer && OutputCount >= unicodeBytes / 
sizeof(WCHAR) + 1)
 
  939             *(PWCHAR)((PCHAR)OutputBuffer + unicodeBytes) = 0;
 
  953         *ReturnCount = unicodeBytes / 
sizeof(WCHAR) + 1;
 
 1033     _In_ BOOLEAN IgnoreCase
 
 1082             fractional = (ca == 
'0' || cb == 
'0');
 
 1128     _In_ BOOLEAN IgnoreCase
 
 1148     _In_ BOOLEAN IgnoreCase
 
 1162     l1 = String1->Length;
 
 1163     l2 = String2->Length;
 
 1166     s1 = String1->Buffer;
 
 1167     s2 = String2->Buffer;
 
 1169     end = (PWCHAR)((PCHAR)s1 + (l1 <= l2 ? l1 : l2));
 
 1206     return (
LONG)(l1 - l2);
 
 1220     _In_ BOOLEAN IgnoreCase
 
 1231     l1 = String1->Length;
 
 1232     l2 = String2->Length;
 
 1239     s1 = String1->Buffer;
 
 1240     s2 = String2->Buffer;
 
 1253                 b1 = _mm_loadu_si128((__m128i *)s1);
 
 1254                 b2 = _mm_loadu_si128((__m128i *)s2);
 
 1255                 b1 = _mm_cmpeq_epi32(b1, b2);
 
 1257                 if (_mm_movemask_epi8(b1) != 0xffff)
 
 1266                         l1 = length * 16 + (l1 & 15);
 
 1267                         l1 /= 
sizeof(WCHAR);
 
 1268                         goto CompareCharacters;
 
 1272                 s1 += 16 / 
sizeof(WCHAR);
 
 1273                 s2 += 16 / 
sizeof(WCHAR);
 
 1274             } 
while (--length != 0);
 
 1279         l1 = (l1 & 15) / 
sizeof(WCHAR);
 
 1283         length = l1 / 
sizeof(ULONG_PTR);
 
 1289                 if (*(PULONG_PTR)s1 != *(PULONG_PTR)s2)
 
 1298                         l1 = length * 
sizeof(ULONG_PTR) + (l1 & (
sizeof(ULONG_PTR) - 1));
 
 1299                         l1 /= 
sizeof(WCHAR);
 
 1300                         goto CompareCharacters;
 
 1304                 s1 += 
sizeof(ULONG_PTR) / 
sizeof(WCHAR);
 
 1305                 s2 += 
sizeof(ULONG_PTR) / 
sizeof(WCHAR);
 
 1306             } 
while (--length != 0);
 
 1311         l1 = (l1 & (
sizeof(ULONG_PTR) - 1)) / 
sizeof(WCHAR);
 
 1329             } 
while (--l1 != 0);
 
 1349             } 
while (--l1 != 0);
 
 1368     _In_ WCHAR Character,
 
 1369     _In_ BOOLEAN IgnoreCase
 
 1375     buffer = String->Buffer;
 
 1376     length = String->Length / 
sizeof(WCHAR);
 
 1384             length16 = String->Length / 16;
 
 1394                 pattern = _mm_set1_epi16(Character);
 
 1398                     block = _mm_loadu_si128((__m128i *)buffer);
 
 1399                     block = _mm_cmpeq_epi16(block, pattern);
 
 1400                     mask = _mm_movemask_epi8(block);
 
 1402                     if (_BitScanForward(&index, mask))
 
 1403                         return (String->Length - length16 * 16) / 
sizeof(WCHAR) - length + index / 2;
 
 1405                     buffer += 16 / 
sizeof(WCHAR);
 
 1406                 } 
while (--length16 != 0);
 
 1414                 if (*buffer == Character)
 
 1415                     return String->Length / 
sizeof(WCHAR) - length;
 
 1418             } 
while (--length != 0);
 
 1432                     return String->Length / 
sizeof(WCHAR) - length;
 
 1435             } 
while (--length != 0);
 
 1454     _In_ WCHAR Character,
 
 1455     _In_ BOOLEAN IgnoreCase
 
 1461     buffer = (PWCHAR)((PCHAR)String->Buffer + String->Length);
 
 1462     length = String->Length / 
sizeof(WCHAR);
 
 1470             length16 = String->Length / 16;
 
 1480                 pattern = _mm_set1_epi16(Character);
 
 1481                 buffer -= 16 / 
sizeof(WCHAR);
 
 1485                     block = _mm_loadu_si128((__m128i *)buffer);
 
 1486                     block = _mm_cmpeq_epi16(block, pattern);
 
 1487                     mask = _mm_movemask_epi8(block);
 
 1489                     if (_BitScanReverse(&index, mask))
 
 1490                         return (length16 - 1) * 16 / 
sizeof(WCHAR) + length + index / 2;
 
 1492                     buffer -= 16 / 
sizeof(WCHAR);
 
 1493                 } 
while (--length16 != 0);
 
 1495                 buffer += 16 / 
sizeof(WCHAR);
 
 1505                 if (*buffer == Character)
 
 1509             } 
while (--length != 0);
 
 1527             } 
while (--length != 0);
 
 1548     _In_ BOOLEAN IgnoreCase
 
 1558     length1 = String->
Length / 
sizeof(WCHAR);
 
 1559     length2 = SubString->Length / 
sizeof(WCHAR);
 
 1562     if (length2 > length1)
 
 1568     sr1.
Buffer = String->Buffer;
 
 1569     sr1.
Length = SubString->Length - 
sizeof(WCHAR);
 
 1570     sr2.
Buffer = SubString->Buffer;
 
 1571     sr2.
Length = SubString->Length - 
sizeof(WCHAR);
 
 1577         for (i = length1 - length2 + 1; i != 0; i--)
 
 1589         for (i = length1 - length2 + 1; i != 0; i--)
 
 1600     return (ULONG_PTR)(sr1.
Buffer - String->Buffer - 1);
 
 1621     _In_ WCHAR Separator,
 
 1636         FirstPart->Buffer = Input->Buffer;
 
 1637         FirstPart->Length = Input->Length;
 
 1638         SecondPart->Buffer = NULL;
 
 1639         SecondPart->Length = 0;
 
 1644     FirstPart->Buffer = input.
Buffer;
 
 1645     FirstPart->Length = index * 
sizeof(WCHAR);
 
 1646     SecondPart->Buffer = (PWCHAR)((PCHAR)input.
Buffer + index * 
sizeof(WCHAR) + 
sizeof(WCHAR));
 
 1647     SecondPart->Length = input.
Length - index * 
sizeof(WCHAR) - 
sizeof(WCHAR);
 
 1670     _In_ WCHAR Separator,
 
 1685         FirstPart->Buffer = Input->Buffer;
 
 1686         FirstPart->Length = Input->Length;
 
 1687         SecondPart->Buffer = NULL;
 
 1688         SecondPart->Length = 0;
 
 1693     FirstPart->Buffer = input.
Buffer;
 
 1694     FirstPart->Length = index * 
sizeof(WCHAR);
 
 1695     SecondPart->Buffer = (PWCHAR)((PCHAR)input.
Buffer + index * 
sizeof(WCHAR) + 
sizeof(WCHAR));
 
 1696     SecondPart->Length = input.
Length - index * 
sizeof(WCHAR) - 
sizeof(WCHAR);
 
 1722     _In_ BOOLEAN IgnoreCase,
 
 1737         FirstPart->Buffer = Input->Buffer;
 
 1738         FirstPart->Length = Input->Length;
 
 1739         SecondPart->Buffer = NULL;
 
 1740         SecondPart->Length = 0;
 
 1745     FirstPart->Buffer = input.
Buffer;
 
 1746     FirstPart->Length = index * 
sizeof(WCHAR);
 
 1747     SecondPart->Buffer = (PWCHAR)((PCHAR)input.
Buffer + index * 
sizeof(WCHAR) + Separator->Length);
 
 1748     SecondPart->Length = input.
Length - index * 
sizeof(WCHAR) - Separator->Length;
 
 1799     SIZE_T separatorIndex;
 
 1800     SIZE_T separatorLength;
 
 1802     SIZE_T charSetCount;
 
 1803     BOOLEAN charSetTable[256];
 
 1804     BOOLEAN charSetTableComplete;
 
 1815         separatorIndex = (SIZE_T)Separator->
Buffer;
 
 1816         separatorLength = Separator->Length;
 
 1818         if (separatorIndex == -1)
 
 1819             goto SeparatorNotFound;
 
 1821         goto SeparatorFound;
 
 1828             goto SeparatorNotFound;
 
 1833         if (separatorIndex == -1)
 
 1834             goto SeparatorNotFound;
 
 1836         separatorLength = Separator->Length;
 
 1837         goto SeparatorFound;
 
 1848         if (separatorIndex == -1)
 
 1849             goto SeparatorNotFound;
 
 1851         separatorLength = 
sizeof(WCHAR);
 
 1852         goto SeparatorFound;
 
 1856         goto SeparatorNotFound;
 
 1860     charSet = Separator->Buffer;
 
 1861     charSetCount = Separator->Length / 
sizeof(WCHAR);
 
 1862     memset(charSetTable, 0, 
sizeof(charSetTable));
 
 1863     charSetTableComplete = 
TRUE;
 
 1865     for (i = 0; i < charSetCount; i++)
 
 1872         charSetTable[c & 0xff] = 
TRUE;
 
 1875             charSetTableComplete = 
FALSE;
 
 1880     i = input.
Length / 
sizeof(WCHAR);
 
 1881     separatorLength = 
sizeof(WCHAR);
 
 1890         s = (PWCHAR)((PCHAR)input.
Buffer + input.
Length - 
sizeof(WCHAR));
 
 1901         if (c < 256 && charSetTableComplete)
 
 1903             if (!(Flags & PH_SPLIT_COMPLEMENT_CHAR_SET))
 
 1905                 if (charSetTable[c])
 
 1910                 if (!charSetTable[c])
 
 1916             if (!(Flags & PH_SPLIT_COMPLEMENT_CHAR_SET))
 
 1918                 if (charSetTable[c & 0xff])
 
 1922                         for (j = 0; j < charSetCount; j++)
 
 1924                             if (charSet[j] == c)
 
 1930                         for (j = 0; j < charSetCount; j++)
 
 1940                 if (charSetTable[c & 0xff])
 
 1944                         for (j = 0; j < charSetCount; j++)
 
 1946                             if (charSet[j] == c)
 
 1952                         for (j = 0; j < charSetCount; j++)
 
 1959                     if (j == charSetCount)
 
 1972     goto SeparatorNotFound;
 
 1975     separatorIndex = s - input.
Buffer;
 
 1978     FirstPart->Buffer = input.
Buffer;
 
 1979     FirstPart->Length = separatorIndex * 
sizeof(WCHAR);
 
 1980     SecondPart->Buffer = (PWCHAR)((PCHAR)input.
Buffer + separatorIndex * 
sizeof(WCHAR) + separatorLength);
 
 1981     SecondPart->Length = input.
Length - separatorIndex * 
sizeof(WCHAR) - separatorLength;
 
 1985         SeparatorPart->Buffer = input.
Buffer + separatorIndex;
 
 1986         SeparatorPart->Length = separatorLength;
 
 1992     FirstPart->Buffer = input.
Buffer;
 
 1993     FirstPart->Length = input.
Length;
 
 1994     SecondPart->Buffer = NULL;
 
 1995     SecondPart->Length = 0;
 
 1999         SeparatorPart->Buffer = NULL;
 
 2000         SeparatorPart->Length = 0;
 
 2013     SIZE_T charSetCount;
 
 2014     BOOLEAN charSetTable[256];
 
 2015     BOOLEAN charSetTableComplete;
 
 2023     if (String->Length == 0 || CharSet->Length == 0)
 
 2026     if (CharSet->Length == 
sizeof(WCHAR))
 
 2028         c = CharSet->Buffer[0];
 
 2033             count = String->Length / 
sizeof(WCHAR);
 
 2036             while (count-- != 0)
 
 2050             count = String->Length / 
sizeof(WCHAR);
 
 2051             s = (PWCHAR)((PCHAR)String->Buffer + String->Length - 
sizeof(WCHAR));
 
 2053             while (count-- != 0)
 
 2061             String->Length -= trimCount * 
sizeof(WCHAR);
 
 2069     charSet = CharSet->Buffer;
 
 2070     charSetCount = CharSet->Length / 
sizeof(WCHAR);
 
 2071     memset(charSetTable, 0, 
sizeof(charSetTable));
 
 2072     charSetTableComplete = 
TRUE;
 
 2074     for (i = 0; i < charSetCount; i++)
 
 2077         charSetTable[c & 0xff] = 
TRUE;
 
 2080             charSetTableComplete = 
FALSE;
 
 2088         count = String->Length / 
sizeof(WCHAR);
 
 2091         while (count-- != 0)
 
 2095             if (!charSetTable[c & 0xff])
 
 2098             if (!charSetTableComplete)
 
 2100                 for (j = 0; j < charSetCount; j++)
 
 2102                     if (charSet[j] == c)
 
 2119         count = String->Length / 
sizeof(WCHAR);
 
 2120         s = (PWCHAR)((PCHAR)String->Buffer + String->Length - 
sizeof(WCHAR));
 
 2122         while (count-- != 0)
 
 2126             if (!charSetTable[c & 0xff])
 
 2129             if (!charSetTableComplete)
 
 2131                 for (j = 0; j < charSetCount; j++)
 
 2133                     if (charSet[j] == c)
 
 2144         String->Length -= trimCount * 
sizeof(WCHAR);
 
 2168     _In_opt_ PWCHAR Buffer,
 
 2175         FIELD_OFFSET(
PH_STRING, Data) + Length + 
sizeof(WCHAR), 
 
 2179     assert(!(Length & 1));
 
 2180     string->Length = Length;
 
 2181     string->Buffer = 
string->Data;
 
 2182     *(PWCHAR)((PCHAR)
string->Buffer + Length) = 0;
 
 2186         memcpy(string->
Buffer, Buffer, Length);
 
 2202     string = PhSharedEmptyString;
 
 2209             &PhSharedEmptyString,
 
 2239     va_start(argptr, Count);
 
 2257     SIZE_T totalLength = 0;
 
 2258     SIZE_T stringLength;
 
 2267     for (i = 0; i < Count; i++)
 
 2269         arg = va_arg(argptr, PWSTR);
 
 2271         totalLength += stringLength;
 
 2274             cachedLengths[i] = stringLength;
 
 2286     for (i = 0; i < Count; i++)
 
 2288         arg = va_arg(argptr, PWSTR);
 
 2291             stringLength = cachedLengths[i];
 
 2296             (PCHAR)string->
Buffer + totalLength,
 
 2300         totalLength += stringLength;
 
 2330         (PCHAR)string->
Buffer + length1,
 
 2351     assert(!(String1->Length & 1));
 
 2352     assert(!(String2->Length & 1));
 
 2355     memcpy(string->
Buffer, String1->Buffer, String1->Length);
 
 2356     memcpy((PCHAR)string->
Buffer + String1->Length, String2->Buffer, String2->Length);
 
 2377     assert(!(String1->Length & 1));
 
 2378     assert(!(String2->Length & 1));
 
 2379     assert(!(String3->Length & 1));
 
 2381     string = 
PhCreateStringEx(NULL, String1->Length + String2->Length + String3->Length);
 
 2383     buffer = (PCHAR)string->
Buffer;
 
 2384     memcpy(buffer, String1->Buffer, String1->Length);
 
 2386     buffer += String1->Length;
 
 2387     memcpy(buffer, String2->Buffer, String2->Length);
 
 2389     buffer += String2->Length;
 
 2390     memcpy(buffer, String3->Buffer, String3->Length);
 
 2401     _In_ _Printf_format_string_ PWSTR Format,
 
 2407     va_start(argptr, Format);
 
 2419     _In_ _Printf_format_string_ PWSTR Format,
 
 2426     length = _vscwprintf(Format, ArgPtr);
 
 2432     _vsnwprintf(string->
Buffer, length, Format, ArgPtr);
 
 2457     _In_opt_ PCHAR Buffer,
 
 2464         FIELD_OFFSET(
PH_BYTES, Data) + Length + 
sizeof(CHAR), 
 
 2470     bytes->
Buffer[Length] = 0;
 
 2474         memcpy(bytes->
Buffer, Buffer, Length);
 
 2485     switch (Decoder->Encoding)
 
 2488         if (Decoder->InputCount >= 4)
 
 2490         Decoder->u.Utf8.Input[Decoder->InputCount] = (UCHAR)CodeUnit;
 
 2491         Decoder->InputCount++;
 
 2494         if (Decoder->InputCount >= 2)
 
 2496         Decoder->u.Utf16.Input[Decoder->InputCount] = (USHORT)CodeUnit;
 
 2497         Decoder->InputCount++;
 
 2500         if (Decoder->InputCount >= 1)
 
 2502         Decoder->u.Utf32.Input = CodeUnit;
 
 2503         Decoder->InputCount = 1;
 
 2512     _Out_ PULONG CodeUnit
 
 2515     switch (Decoder->Encoding)
 
 2518         if (Decoder->InputCount == 0)
 
 2520         *CodeUnit = Decoder->u.Utf8.Input[0];
 
 2521         Decoder->u.Utf8.Input[0] = Decoder->u.Utf8.Input[1];
 
 2522         Decoder->u.Utf8.Input[1] = Decoder->u.Utf8.Input[2];
 
 2523         Decoder->u.Utf8.Input[2] = Decoder->u.Utf8.Input[3];
 
 2524         Decoder->InputCount--;
 
 2527         if (Decoder->InputCount == 0)
 
 2529         *CodeUnit = Decoder->u.Utf16.Input[0];
 
 2530         Decoder->u.Utf16.Input[0] = Decoder->u.Utf16.Input[1];
 
 2531         Decoder->InputCount--;
 
 2534         if (Decoder->InputCount == 0)
 
 2536         *CodeUnit = Decoder->u.Utf32.Input;
 
 2537         Decoder->InputCount--;
 
 2549     switch (Decoder->Encoding)
 
 2552         if (Decoder->InputCount >= 4)
 
 2554         Decoder->u.Utf8.Input[3] = Decoder->u.Utf8.Input[2];
 
 2555         Decoder->u.Utf8.Input[2] = Decoder->u.Utf8.Input[1];
 
 2556         Decoder->u.Utf8.Input[1] = Decoder->u.Utf8.Input[0];
 
 2557         Decoder->u.Utf8.Input[0] = (UCHAR)CodeUnit;
 
 2558         Decoder->InputCount++;
 
 2561         if (Decoder->InputCount >= 2)
 
 2563         Decoder->u.Utf16.Input[1] = Decoder->u.Utf16.Input[0];
 
 2564         Decoder->u.Utf16.Input[0] = (USHORT)CodeUnit;
 
 2565         Decoder->InputCount++;
 
 2568         if (Decoder->InputCount >= 1)
 
 2570         Decoder->u.Utf32.Input = CodeUnit;
 
 2571         Decoder->InputCount = 1;
 
 2580     _Out_ PULONG CodePoint,
 
 2591     *CodePoint = (ULONG)Decoder->u.Utf8.CodeUnit1 + 0xdc00;
 
 2599     _Out_ PULONG CodePoint
 
 2606         switch (Decoder->Encoding)
 
 2612             switch (Decoder->State)
 
 2615                 Decoder->u.Utf8.CodeUnit1 = (UCHAR)codeUnit;
 
 2617                 if (codeUnit < 0x80)
 
 2619                     *CodePoint = codeUnit;
 
 2622                 else if (codeUnit < 0xc2)
 
 2626                 else if (codeUnit < 0xe0)
 
 2631                 else if (codeUnit < 0xf0)
 
 2636                 else if (codeUnit < 0xf5)
 
 2648                 Decoder->u.Utf8.CodeUnit2 = (UCHAR)codeUnit;
 
 2650                 if ((codeUnit & 0xc0) == 0x80)
 
 2652                     *CodePoint = ((ULONG)Decoder->u.Utf8.CodeUnit1 << 6) + codeUnit - 0x3080;
 
 2663                 Decoder->u.Utf8.CodeUnit2 = (UCHAR)codeUnit;
 
 2665                 if (((codeUnit & 0xc0) == 0x80) &&
 
 2666                     (Decoder->u.Utf8.CodeUnit1 != 0xe0 || codeUnit >= 0xa0))
 
 2678                 Decoder->u.Utf8.CodeUnit2 = (UCHAR)codeUnit;
 
 2680                 if (((codeUnit & 0xc0) == 0x80) &&
 
 2681                     (Decoder->u.Utf8.CodeUnit1 != 0xf0 || codeUnit >= 0x90) &&
 
 2682                     (Decoder->u.Utf8.CodeUnit1 != 0xf4 || codeUnit < 0x90))
 
 2694                 Decoder->u.Utf8.CodeUnit3 = (UCHAR)codeUnit;
 
 2696                 if ((codeUnit & 0xc0) == 0x80)
 
 2699                         ((ULONG)Decoder->u.Utf8.CodeUnit1 << 12) +
 
 2700                         ((ULONG)Decoder->u.Utf8.CodeUnit2 << 6) +
 
 2712                 Decoder->u.Utf8.CodeUnit3 = (UCHAR)codeUnit;
 
 2714                 if ((codeUnit & 0xc0) == 0x80)
 
 2726                 Decoder->u.Utf8.CodeUnit4 = (UCHAR)codeUnit;
 
 2728                 if ((codeUnit & 0xc0) == 0x80)
 
 2731                         ((ULONG)Decoder->u.Utf8.CodeUnit1 << 18) +
 
 2732                         ((ULONG)Decoder->u.Utf8.CodeUnit2 << 12) +
 
 2733                         ((ULONG)Decoder->u.Utf8.CodeUnit3 << 6) +
 
 2734                         codeUnit - 0x3c82080;
 
 2751             switch (Decoder->State)
 
 2756                     Decoder->u.Utf16.CodeUnit = (USHORT)codeUnit;
 
 2762                     *CodePoint = codeUnit;
 
 2775                     *CodePoint = Decoder->u.Utf16.CodeUnit;
 
 2795     _In_ UCHAR Encoding,
 
 2796     _In_ ULONG CodePoint,
 
 2797     _Out_opt_ PVOID CodeUnits,
 
 2798     _Out_ PULONG NumberOfCodeUnits
 
 2805             PUCHAR codeUnits = CodeUnits;
 
 2807             if (CodePoint < 0x80)
 
 2809                 *NumberOfCodeUnits = 1;
 
 2812                     codeUnits[0] = (UCHAR)CodePoint;
 
 2814             else if (CodePoint <= 0x7ff)
 
 2816                 *NumberOfCodeUnits = 2;
 
 2820                     codeUnits[0] = (UCHAR)(CodePoint >> 6) + 0xc0;
 
 2821                     codeUnits[1] = (UCHAR)(CodePoint & 0x3f) + 0x80;
 
 2824             else if (CodePoint <= 0xffff)
 
 2826                 *NumberOfCodeUnits = 3;
 
 2830                     codeUnits[0] = (UCHAR)(CodePoint >> 12) + 0xe0;
 
 2831                     codeUnits[1] = (UCHAR)((CodePoint >> 6) & 0x3f) + 0x80;
 
 2832                     codeUnits[2] = (UCHAR)(CodePoint & 0x3f) + 0x80;
 
 2837                 *NumberOfCodeUnits = 4;
 
 2841                     codeUnits[0] = (UCHAR)(CodePoint >> 18) + 0xf0;
 
 2842                     codeUnits[1] = (UCHAR)((CodePoint >> 12) & 0x3f) + 0x80;
 
 2843                     codeUnits[2] = (UCHAR)((CodePoint >> 6) & 0x3f) + 0x80;
 
 2844                     codeUnits[3] = (UCHAR)(CodePoint & 0x3f) + 0x80;
 
 2855             PUSHORT codeUnits = CodeUnits;
 
 2857             if (CodePoint < 0x10000)
 
 2859                 *NumberOfCodeUnits = 1;
 
 2862                     codeUnits[0] = (USHORT)CodePoint;
 
 2866                 *NumberOfCodeUnits = 2;
 
 2881         *NumberOfCodeUnits = 1;
 
 2883             *(PULONG)CodeUnits = CodePoint;
 
 2898     _In_reads_bytes_(InputLength) PSTR Input,
 
 2899     _In_ SIZE_T InputLength,
 
 2900     _Out_writes_bytes_(InputLength * 
sizeof(WCHAR)) PWSTR Output
 
 2905     inputLength = InputLength & -4;
 
 2911             Output[0] = 
C_1uTo2(Input[0]);
 
 2912             Output[1] = 
C_1uTo2(Input[1]);
 
 2913             Output[2] = 
C_1uTo2(Input[2]);
 
 2914             Output[3] = 
C_1uTo2(Input[3]);
 
 2918         } 
while (inputLength != 0);
 
 2921     switch (InputLength & 3)
 
 2924         *Output++ = 
C_1uTo2(*Input++);
 
 2926         *Output++ = 
C_1uTo2(*Input++);
 
 2928         *Output++ = 
C_1uTo2(*Input++);
 
 2933     _In_reads_bytes_(InputLength) PCH Input,
 
 2934     _In_ SIZE_T InputLength
 
 2948     _In_opt_ CHAR Replacement
 
 2962     inRemaining = Length / 
sizeof(WCHAR);
 
 2966     while (inRemaining != 0)
 
 2974             if (codePoint < 0x80)
 
 2976                 *out++ = (CHAR)codePoint;
 
 2979             else if (Replacement)
 
 2981                 *out++ = Replacement;
 
 2987     bytes->
Length = outLength;
 
 2988     bytes->
Buffer[outLength] = 0;
 
 3078     ULONG multiByteLength;
 
 3108     _Out_ PSIZE_T BytesInUtf16String,
 
 3109     _In_reads_bytes_(BytesInUtf8String) PCH Utf8String,
 
 3110     _In_ SIZE_T BytesInUtf8String
 
 3117     SIZE_T bytesInUtf16String;
 
 3119     ULONG numberOfCodeUnits;
 
 3124     inRemaining = BytesInUtf8String;
 
 3125     bytesInUtf16String = 0;
 
 3127     while (inRemaining != 0)
 
 3136                 bytesInUtf16String += numberOfCodeUnits * 
sizeof(WCHAR);
 
 3142     *BytesInUtf16String = bytesInUtf16String;
 
 3148     _Out_writes_bytes_to_(MaxBytesInUtf16String, *BytesInUtf16String) PWCH Utf16String,
 
 3149     _In_ SIZE_T MaxBytesInUtf16String,
 
 3150     _Out_opt_ PSIZE_T BytesInUtf16String,
 
 3151     _In_reads_bytes_(BytesInUtf8String) PCH Utf8String,
 
 3152     _In_ SIZE_T BytesInUtf8String
 
 3160     SIZE_T outRemaining;
 
 3161     SIZE_T bytesInUtf16String;
 
 3163     USHORT codeUnits[2];
 
 3164     ULONG numberOfCodeUnits;
 
 3169     inRemaining = BytesInUtf8String;
 
 3171     outRemaining = MaxBytesInUtf16String / 
sizeof(WCHAR);
 
 3172     bytesInUtf16String = 0;
 
 3174     while (inRemaining != 0)
 
 3184                 bytesInUtf16String += numberOfCodeUnits * 
sizeof(WCHAR);
 
 3186                 if (outRemaining >= numberOfCodeUnits)
 
 3188                     *out++ = codeUnits[0];
 
 3190                     if (numberOfCodeUnits >= 2)
 
 3191                         *out++ = codeUnits[1];
 
 3193                     outRemaining -= numberOfCodeUnits;
 
 3207     if (BytesInUtf16String)
 
 3208         *BytesInUtf16String = bytesInUtf16String;
 
 3258     _Out_ PSIZE_T BytesInUtf8String,
 
 3259     _In_reads_bytes_(BytesInUtf16String) PWCH Utf16String,
 
 3260     _In_ SIZE_T BytesInUtf16String
 
 3267     SIZE_T bytesInUtf8String;
 
 3269     ULONG numberOfCodeUnits;
 
 3274     inRemaining = BytesInUtf16String / 
sizeof(WCHAR);
 
 3275     bytesInUtf8String = 0;
 
 3277     while (inRemaining != 0)
 
 3286                 bytesInUtf8String += numberOfCodeUnits;
 
 3292     *BytesInUtf8String = bytesInUtf8String;
 
 3298     _Out_writes_bytes_to_(MaxBytesInUtf8String, *BytesInUtf8String) PCH Utf8String,
 
 3299     _In_ SIZE_T MaxBytesInUtf8String,
 
 3300     _Out_opt_ PSIZE_T BytesInUtf8String,
 
 3301     _In_reads_bytes_(BytesInUtf16String) PWCH Utf16String,
 
 3302     _In_ SIZE_T BytesInUtf16String
 
 3310     SIZE_T outRemaining;
 
 3311     SIZE_T bytesInUtf8String;
 
 3314     ULONG numberOfCodeUnits;
 
 3319     inRemaining = BytesInUtf16String / 
sizeof(WCHAR);
 
 3321     outRemaining = MaxBytesInUtf8String;
 
 3322     bytesInUtf8String = 0;
 
 3324     while (inRemaining != 0)
 
 3334                 bytesInUtf8String += numberOfCodeUnits;
 
 3336                 if (outRemaining >= numberOfCodeUnits)
 
 3338                     *out++ = codeUnits[0];
 
 3340                     if (numberOfCodeUnits >= 2)
 
 3341                         *out++ = codeUnits[1];
 
 3342                     if (numberOfCodeUnits >= 3)
 
 3343                         *out++ = codeUnits[2];
 
 3344                     if (numberOfCodeUnits >= 4)
 
 3345                         *out++ = codeUnits[3];
 
 3347                     outRemaining -= numberOfCodeUnits;
 
 3361     if (BytesInUtf8String)
 
 3362         *BytesInUtf8String = bytesInUtf8String;
 
 3420     _In_ SIZE_T InitialCapacity
 
 3424     if (InitialCapacity & 1)
 
 3427     StringBuilder->AllocatedLength = InitialCapacity;
 
 3432     StringBuilder->String = 
PhCreateStringEx(NULL, StringBuilder->AllocatedLength);
 
 3438     StringBuilder->String->Length = 0;
 
 3441     StringBuilder->String->Buffer[0] = 0;
 
 3473     return StringBuilder->String;
 
 3478     _In_ SIZE_T NewCapacity
 
 3485     StringBuilder->AllocatedLength *= 2;
 
 3487     if (StringBuilder->AllocatedLength < NewCapacity)
 
 3488         StringBuilder->AllocatedLength = NewCapacity;
 
 3496         StringBuilder->String->Buffer,
 
 3497         StringBuilder->String->Length + 
sizeof(WCHAR) 
 
 3501     newString->
Length = StringBuilder->String->Length;
 
 3513     assert(!(StringBuilder->String->Length & 1));
 
 3514     *(PWCHAR)((PCHAR)StringBuilder->String->Buffer + StringBuilder->String->Length) = 0;
 
 3562     _In_opt_ PWCHAR String,
 
 3570     if (StringBuilder->AllocatedLength < StringBuilder->String->Length + Length)
 
 3580             (PCHAR)StringBuilder->String->Buffer + StringBuilder->String->Length,
 
 3586     StringBuilder->String->Length += Length;
 
 3599     _In_ WCHAR Character
 
 3602     if (StringBuilder->AllocatedLength < StringBuilder->String->Length + 
sizeof(WCHAR))
 
 3607     *(PWCHAR)((PCHAR)StringBuilder->String->Buffer + StringBuilder->String->Length) = Character;
 
 3608     StringBuilder->String->Length += 
sizeof(WCHAR);
 
 3622     _In_ WCHAR Character,
 
 3630     if (StringBuilder->AllocatedLength < StringBuilder->String->Length + Count * 
sizeof(WCHAR))
 
 3636         (PWCHAR)((PCHAR)StringBuilder->String->Buffer + StringBuilder->String->Length),
 
 3641     StringBuilder->String->Length += Count * 
sizeof(WCHAR);
 
 3654     _In_ _Printf_format_string_ PWSTR Format,
 
 3660     va_start(argptr, Format);
 
 3666     _In_ _Printf_format_string_ PWSTR Format,
 
 3671     SIZE_T lengthInBytes;
 
 3673     length = _vscwprintf(Format, ArgPtr);
 
 3675     if (length == -1 || length == 0)
 
 3678     lengthInBytes = length * 
sizeof(WCHAR);
 
 3680     if (StringBuilder->AllocatedLength < StringBuilder->String->Length + lengthInBytes)
 
 3684         (PWCHAR)((PCHAR)StringBuilder->String->Buffer + StringBuilder->String->Length),
 
 3690     StringBuilder->String->Length += lengthInBytes;
 
 3751     _In_opt_ PWCHAR String,
 
 3759     if (StringBuilder->AllocatedLength < StringBuilder->String->Length + Length)
 
 3764     if (Index * 
sizeof(WCHAR) < StringBuilder->String->Length)
 
 3768             &StringBuilder->String->Buffer[Index + Length / 
sizeof(WCHAR)],
 
 3769             &StringBuilder->String->Buffer[Index],
 
 3770             StringBuilder->String->Length - Index * 
sizeof(WCHAR)
 
 3778             &StringBuilder->String->Buffer[Index],
 
 3784     StringBuilder->String->Length += Length;
 
 3798     _In_ SIZE_T StartIndex,
 
 3806         &StringBuilder->String->Buffer[StartIndex],
 
 3807         &StringBuilder->String->Buffer[StartIndex + Count],
 
 3808         StringBuilder->String->Length - (Count + StartIndex) * 
sizeof(WCHAR)
 
 3810     StringBuilder->String->Length -= Count * 
sizeof(WCHAR);
 
 3822     _In_ SIZE_T InitialCapacity
 
 3825     BytesBuilder->AllocatedLength = InitialCapacity;
 
 3826     BytesBuilder->Bytes = 
PhCreateBytesEx(NULL, BytesBuilder->AllocatedLength);
 
 3827     BytesBuilder->Bytes->Length = 0;
 
 3828     BytesBuilder->Bytes->Buffer[0] = 0;
 
 3858     return BytesBuilder->Bytes;
 
 3863     _In_ SIZE_T NewCapacity
 
 3870     BytesBuilder->AllocatedLength *= 2;
 
 3872     if (BytesBuilder->AllocatedLength < NewCapacity)
 
 3873         BytesBuilder->AllocatedLength = NewCapacity;
 
 3881         BytesBuilder->Bytes->Buffer,
 
 3882         BytesBuilder->Bytes->Length + 
sizeof(CHAR) 
 
 3886     newBytes->
Length = BytesBuilder->Bytes->Length;
 
 3896     BytesBuilder->Bytes->Buffer[BytesBuilder->Bytes->Length] = 0;
 
 3953     _In_opt_ PVOID Buffer,
 
 3955     _In_opt_ SIZE_T Alignment,
 
 3956     _Out_opt_ PSIZE_T Offset
 
 3959     SIZE_T currentLength;
 
 3961     currentLength = BytesBuilder->Bytes->Length;
 
 3967         currentLength = 
ALIGN_UP_BY(currentLength, Alignment);
 
 3970     if (BytesBuilder->AllocatedLength < currentLength + Length)
 
 3976         memcpy(BytesBuilder->Bytes->Buffer + currentLength, Buffer, Length);
 
 3978     BytesBuilder->Bytes->Length = currentLength + Length;
 
 3983         *Offset = currentLength;
 
 3985     return BytesBuilder->Bytes->Buffer + currentLength;
 
 3995     _In_ ULONG InitialCapacity
 
 4003     if (InitialCapacity == 0)
 
 4004         InitialCapacity = 1;
 
 4033     _In_ ULONG NewCapacity
 
 4036     if (List->Count > NewCapacity)
 
 4039     List->AllocatedCount = NewCapacity;
 
 4040     List->Items = PhReAllocate(List->Items, List->AllocatedCount * 
sizeof(PVOID));
 
 4055     if (List->Count == List->AllocatedCount)
 
 4057         List->AllocatedCount *= 2;
 
 4058         List->Items = PhReAllocate(List->Items, List->AllocatedCount * 
sizeof(PVOID));
 
 4061     List->Items[List->Count++] = 
Item;
 
 4078     if (List->AllocatedCount < List->Count + Count)
 
 4080         List->AllocatedCount *= 2;
 
 4082         if (List->AllocatedCount < List->Count + Count)
 
 4083             List->AllocatedCount = List->Count + Count;
 
 4085         List->Items = PhReAllocate(List->Items, List->AllocatedCount * 
sizeof(PVOID));
 
 4089         &List->Items[List->Count],
 
 4091         Count * 
sizeof(PVOID)
 
 4094     List->Count += Count;
 
 4119 ULONG PhFindItemList(
 
 4126     for (i = 0; i < List->Count; i++)
 
 4128         if (List->Items[i] == Item)
 
 4167     if (List->AllocatedCount < List->Count + Count)
 
 4169         List->AllocatedCount *= 2;
 
 4171         if (List->AllocatedCount < List->Count + Count)
 
 4172             List->AllocatedCount = List->Count + Count;
 
 4174         List->Items = PhReAllocate(List->Items, List->AllocatedCount * 
sizeof(PVOID));
 
 4177     if (Index < List->Count)
 
 4181             &List->Items[Index + Count],
 
 4182             &List->Items[Index],
 
 4183             (List->Count - Index) * 
sizeof(PVOID)
 
 4189         &List->Items[Index],
 
 4191         Count * 
sizeof(PVOID)
 
 4194     List->Count += Count;
 
 4221     _In_ ULONG StartIndex,
 
 4227         &List->Items[StartIndex],
 
 4228         &List->Items[StartIndex + Count],
 
 4229         (List->Count - StartIndex - Count) * 
sizeof(PVOID)
 
 4232     List->Count -= Count;
 
 4242     _In_ ULONG InitialCapacity
 
 4250     if (InitialCapacity == 0)
 
 4251         InitialCapacity = 1;
 
 4253     pointerList->
Count = 0;
 
 4283     return (ULONG)((LONG_PTR)Index >> 1);
 
 4293     return (PVOID)(((ULONG_PTR)Index << 1) | 0x1);
 
 4302     return (HANDLE)(Index + 1);
 
 4309     return (ULONG)Handle - 1;
 
 4332     if (PointerList->FreeEntry != -1)
 
 4336         index = PointerList->FreeEntry;
 
 4337         oldPointer = PointerList->Items[index];
 
 4338         PointerList->Items[index] = Pointer;
 
 4344         if (PointerList->NextEntry == PointerList->AllocatedCount)
 
 4346             PointerList->AllocatedCount *= 2;
 
 4347             PointerList->Items = PhReAllocate(PointerList->Items, PointerList->AllocatedCount * 
sizeof(PVOID));
 
 4350         index = PointerList->NextEntry++;
 
 4351         PointerList->Items[index] = Pointer;
 
 4354     PointerList->Count++;
 
 4361     _Inout_ PULONG EnumerationKey,
 
 4362     _Out_ PVOID *Pointer,
 
 4363     _Out_ PHANDLE PointerHandle
 
 4368     while ((index = *EnumerationKey) < PointerList->NextEntry)
 
 4370         PVOID pointer = PointerList->Items[index];
 
 4372         (*EnumerationKey)++;
 
 4407     for (i = 0; i < PointerList->NextEntry; i++)
 
 4409         if (PointerList->Items[i] == Pointer)
 
 4429     _In_ HANDLE PointerHandle
 
 4434     assert(PointerHandle);
 
 4439     PointerList->FreeEntry = index;
 
 4441     PointerList->Count--;
 
 4450 #if defined(PH_HASHTABLE_FULL_HASH) && !defined(PH_HASHTABLE_POWER_OF_TWO_SIZE) 
 4456     return Hash & MAXLONG;
 
 4465 #ifdef PH_HASHTABLE_POWER_OF_TWO_SIZE 
 4466     return Hash & (Hashtable->AllocatedBuckets - 1);
 
 4468     return Hash % Hashtable->AllocatedBuckets;
 
 4476 #ifdef PH_HASHTABLE_POWER_OF_TWO_SIZE 
 4496     _In_ ULONG EntrySize,
 
 4499     _In_ ULONG InitialCapacity
 
 4507     if (InitialCapacity == 0)
 
 4508         InitialCapacity = 1;
 
 4524     hashtable->
Count = 0;
 
 4544     _In_ ULONG NewCapacity
 
 4553     PhFree(Hashtable->Buckets);
 
 4554     Hashtable->Buckets = PhAllocate(
sizeof(ULONG) * Hashtable->AllocatedBuckets);
 
 4556     memset(Hashtable->Buckets, 0xff, 
sizeof(ULONG) * Hashtable->AllocatedBuckets);
 
 4559     Hashtable->AllocatedEntries = Hashtable->AllocatedBuckets;
 
 4560     Hashtable->Entries = PhReAllocate(
 
 4568     entry = Hashtable->Entries;
 
 4570     for (i = 0; i < Hashtable->NextEntry; i++)
 
 4576             entry->
Next = Hashtable->Buckets[index];
 
 4577             Hashtable->Buckets[index] = i;
 
 4587     _In_ BOOLEAN CheckForDuplicate,
 
 4588     _Out_opt_ PBOOLEAN Added
 
 4599     if (CheckForDuplicate)
 
 4603         for (i = Hashtable->Buckets[index]; i != -1; i = entry->
Next)
 
 4607             if (entry->
HashCode == hashCode && Hashtable->CompareFunction(&entry->
Body, Entry))
 
 4612                 return &entry->
Body;
 
 4618     if (Hashtable->FreeEntry != -1)
 
 4620         freeEntry = Hashtable->FreeEntry;
 
 4622         Hashtable->FreeEntry = entry->
Next;
 
 4628         if (Hashtable->NextEntry == Hashtable->AllocatedEntries)
 
 4635         freeEntry = Hashtable->NextEntry++;
 
 4641     entry->
Next = Hashtable->Buckets[index];
 
 4642     Hashtable->Buckets[index] = freeEntry;
 
 4644     memcpy(&entry->
Body, Entry, Hashtable->EntrySize);
 
 4651     return &entry->
Body;
 
 4706     _Out_opt_ PBOOLEAN Added
 
 4721     if (Hashtable->Count > 0)
 
 4723         memset(Hashtable->Buckets, 0xff, 
sizeof(ULONG) * Hashtable->AllocatedBuckets);
 
 4724         Hashtable->Count = 0;
 
 4725         Hashtable->FreeEntry = -1;
 
 4726         Hashtable->NextEntry = 0;
 
 4754     _Inout_ PULONG EnumerationKey
 
 4757     while (*EnumerationKey < Hashtable->NextEntry)
 
 4761         (*EnumerationKey)++;
 
 4765             *Entry = &entry->
Body;
 
 4803     for (i = Hashtable->Buckets[index]; i != -1; i = entry->
Next)
 
 4807         if (entry->
HashCode == hashCode && Hashtable->CompareFunction(&entry->
Body, Entry))
 
 4809             return &entry->
Body;
 
 4838     ULONG previousIndex;
 
 4845     for (i = Hashtable->Buckets[index]; i != -1; i = entry->
Next)
 
 4849         if (entry->
HashCode == hashCode && Hashtable->CompareFunction(&entry->
Body, Entry))
 
 4852             if (previousIndex == -1)
 
 4854                 Hashtable->Buckets[index] = entry->
Next;
 
 4862             entry->
Next = Hashtable->FreeEntry;
 
 4863             Hashtable->FreeEntry = i;
 
 4883     _In_reads_(Length) PUCHAR Bytes,
 
 4898     } 
while (--Length != 0);
 
 4911     _In_ BOOLEAN IgnoreCase
 
 4918     if (String->Length == 0)
 
 4921     count = String->Length / 
sizeof(WCHAR);
 
 4926         return PhHashBytes((PUCHAR)String->Buffer, String->Length);
 
 4934         } 
while (--count != 0);
 
 4948     return entry1->
Key == entry2->
Key;
 
 4961     _In_ ULONG InitialCapacity
 
 4975     _In_opt_ PVOID Value
 
 4981     entry.
Value = Value;
 
 4997     lookupEntry.
Key = Key;
 
 5001         return &entry->
Value;
 
 5013     lookupEntry.
Key = Key;
 
 5029     _In_ ULONG MaximumCount
 
 5032     RtlInitializeSListHead(&FreeList->ListHead);
 
 5033     FreeList->Count = 0;
 
 5034     FreeList->MaximumCount = MaximumCount;
 
 5035     FreeList->Size = 
Size;
 
 5048     PSLIST_ENTRY listEntry;
 
 5050     listEntry = RtlInterlockedFlushSList(&FreeList->ListHead);
 
 5055         listEntry = listEntry->Next;
 
 5075     PSLIST_ENTRY listEntry;
 
 5077     listEntry = RtlInterlockedPopEntrySList(&FreeList->ListHead);
 
 5081         _InterlockedDecrement((PLONG)&FreeList->Count);
 
 5089     return &entry->
Body;
 
 5109     if (FreeList->Count < FreeList->MaximumCount)
 
 5111         RtlInterlockedPushEntrySList(&FreeList->ListHead, &entry->
ListEntry);
 
 5112         _InterlockedIncrement((PLONG)&FreeList->Count);
 
 5162     _In_opt_ PVOID Context,
 
 5193     _In_opt_ PVOID Context,
 
 5198     Registration->Function = Function;
 
 5199     Registration->Context = Context;
 
 5200     Registration->Busy = 0;
 
 5201     Registration->Unregistering = 
FALSE;
 
 5202     Registration->Flags = Flags;
 
 5226     Registration->Unregistering = 
TRUE;
 
 5231     while (Registration->Busy)
 
 5248     _In_opt_ PVOID Parameter
 
 5251     PLIST_ENTRY listEntry;
 
 5255     listEntry = Callback->ListHead.Flink;
 
 5257     while (listEntry != &Callback->ListHead)
 
 5269         _InterlockedIncrement(®istration->
Busy);
 
 5280         busy = _InterlockedDecrement(®istration->
Busy);
 
 5289         listEntry = listEntry->Flink;
 
 5305     for (i = 0; i < 
sizeof(PhpPrimeNumbers) / 
sizeof(ULONG); i++)
 
 5307         if (PhpPrimeNumbers[i] >= Minimum)
 
 5308             return PhpPrimeNumbers[i];
 
 5311     for (i = Minimum | 1; i < MAXLONG; i += 2)
 
 5313         ULONG sqrtI = (ULONG)sqrt(i);
 
 5315         for (j = 3; j <= sqrtI; j += 2)
 
 5341     Number |= Number >> 1;
 
 5342     Number |= Number >> 2;
 
 5343     Number |= Number >> 4;
 
 5344     Number |= Number >> 8;
 
 5345     Number |= Number >> 16;
 
 5407     _Out_writes_bytes_(String->Length / 
sizeof(WCHAR) / 2) PUCHAR Buffer
 
 5414     if ((String->Length / 
sizeof(WCHAR)) & 1)
 
 5417     length = String->Length / 
sizeof(WCHAR) / 2;
 
 5419     for (i = 0; i < length; i++)
 
 5438     _In_reads_bytes_(Length) PUCHAR Buffer,
 
 5455     _In_reads_bytes_(Length) PUCHAR Buffer,
 
 5457     _In_ BOOLEAN UpperCase
 
 5471     for (i = 0; i < Length; i++)
 
 5473         string->Buffer[i * 2] = table[Buffer[i] >> 4];
 
 5474         string->Buffer[i * 2 + 1] = table[Buffer[i] & 0xf];
 
 5492     _Out_ PULONG64 Integer
 
 5495     BOOLEAN valid = 
TRUE;
 
 5500     length = String->Length / 
sizeof(WCHAR);
 
 5503     for (i = 0; i < length; i++)
 
 5510             result = result * Base + value;
 
 5546     _In_opt_ ULONG Base,
 
 5547     _Out_opt_ PLONG64 Integer
 
 5562     if (
string.Length != 0 && (
string.Buffer[0] == 
'-' || 
string.Buffer[0] == 
'+'))
 
 5564         if (
string.Buffer[0] == 
'-')
 
 5581         if (
string.Length >= 2 * 
sizeof(WCHAR) && 
string.Buffer[0] == 
'0')
 
 5583             switch (
string.Buffer[1])
 
 5623         *Integer = negative ? -(LONG64)result : result;
 
 5643     _In_ LONG64 Integer,
 
 5644     _In_opt_ ULONG Base,
 
 5650     if (Base == 1 || Base > 69)
 
 5661         format.
Radix = (UCHAR)Base;
 
 5679             L
"%02I64u:%02I64u:%02I64u.%03I64u",
 
 5690             L
"%I64u:%02I64u:%02I64u:%02I64u",
 
 5701             L
"%02I64u:%02I64u:%02I64u",
 
 5733             } 
while (--Count != 0);
 
 5739     if ((ULONG_PTR)Memory & 0xf)
 
 5741         switch ((ULONG_PTR)Memory & 0xf)
 
 5767     pattern = _mm_set1_epi32(Value);
 
 5774             _mm_store_si128((__m128i *)Memory, pattern);
 
 5776         } 
while (--count != 0);
 
 5779     switch (Count & 0x3)
 
 5806     _Inout_updates_(Count) PFLOAT A,
 
 5822     if ((ULONG_PTR)A & 0xf)
 
 5824         switch ((ULONG_PTR)A & 0xf)
 
 5854     endA = (PFLOAT)((ULONG_PTR)(A + Count) & ~0xf);
 
 5855     b = _mm_load1_ps(&B);
 
 5862         a = _mm_div_ps(a, b);
 
 5868     switch (Count & 0x3)