mirror of https://github.com/vxunderground/VX-API
65 lines
1.3 KiB
C++
65 lines
1.3 KiB
C++
#include "StringManipulation.h"
|
|
|
|
INT StringCompareStringRegionA(PCHAR String1, PCHAR String2, SIZE_T Count)
|
|
{
|
|
UCHAR Block1, Block2;
|
|
while (Count-- > 0)
|
|
{
|
|
Block1 = (UCHAR)*String1++;
|
|
Block2 = (UCHAR)*String2++;
|
|
|
|
if (Block1 != Block2)
|
|
return Block1 - Block2;
|
|
|
|
if (Block1 == '\0')
|
|
return 0;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
INT StringCompareStringRegionW(PWCHAR String1, PWCHAR String2, SIZE_T Count)
|
|
{
|
|
UCHAR Block1, Block2;
|
|
while (Count-- > 0)
|
|
{
|
|
Block1 = (UCHAR)*String1++;
|
|
Block2 = (UCHAR)*String2++;
|
|
|
|
if (Block1 != Block2)
|
|
return Block1 - Block2;
|
|
|
|
if (Block1 == '\0')
|
|
return 0;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
PCHAR StringFindSubstringA(_In_ PCHAR String1, _In_ PCHAR String2)
|
|
{
|
|
PCHAR pPointer = String1;
|
|
DWORD Length = (DWORD)StringLengthA(String2);
|
|
|
|
for (; (pPointer = StringLocateCharA(pPointer, *String2)) != 0; pPointer++)
|
|
{
|
|
if (StringCompareStringRegionA(pPointer, String2, Length) == 0)
|
|
return (PCHAR)pPointer;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
PWCHAR StringFindSubstringW(_In_ PWCHAR String1, _In_ PWCHAR String2)
|
|
{
|
|
PWCHAR pPointer = String1;
|
|
DWORD Length = (DWORD)StringLengthW(String2);
|
|
|
|
for (; (pPointer = StringLocateCharW(pPointer, *String2)) != 0; pPointer++)
|
|
{
|
|
if (StringCompareStringRegionW(pPointer, String2, Length) == 0)
|
|
return (PWCHAR)pPointer;
|
|
}
|
|
|
|
return NULL;
|
|
} |