Skip to content

Instantly share code, notes, and snippets.

@shavitush
Created March 9, 2020 12:27
Show Gist options
  • Save shavitush/77512d0f37af487918a715ec2553e91d to your computer and use it in GitHub Desktop.
Save shavitush/77512d0f37af487918a715ec2553e91d to your computer and use it in GitHub Desktop.
template<typename T>
T sig_scan(const uint32_t dwStart, const uint32_t dwEnd, const uint8_t abPattern[], const char aMask[], const size_t dwPatternSize)
{
for(uint32_t i = dwStart; i < dwEnd; i++)
{
for(uint32_t x = 0; x < dwPatternSize; x++)
{
const uint8_t bMemory = *reinterpret_cast<uint8_t*>(i + x);
if(aMask[x] == 'x' && bMemory != abPattern[x])
{
break;
}
else if(x == dwPatternSize - 1)
{
return reinterpret_cast<T>(i);
}
}
}
return nullptr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment