Help Converting FindPattern Functions
Posted: Mon Nov 25, 2013 11:47 pm
				
				ello, I am working on a plugin for a game. And am in need to using signatures to pull offsets from the game. As coding offsets directly into the plugin will cause the plugin to break after future updates (new offsets). So the purpose of it is to keep the plugin compatible with a majority of future versions without needing to update the plugin any (only rarely). I am need of help converting a few C++ functions to the PureBasic equivalent. Here is the basic FindPattern() function that is standard in plugin and mod development.
Usage:
Hope its not too much to ask for. I can handle the signatures, masks, and the rest of that on my own.
Greets.
			Code: Select all
BOOL DataCompare( BYTE* pData, BYTE* bMask, char * szMask )
{
    for( ; *szMask; ++szMask, ++pData, ++bMask )
         if( *szMask == 'x' && *pData != *bMask )
                return FALSE;
    return ( *szMask == NULL );
}
DWORD CTools::FindPattern( DWORD dwAddress, DWORD dwLen, BYTE *bMask, char * szMask )
{
    for( DWORD i = 0; i < dwLen; i++ )
         if( DataCompare( (BYTE*)( dwAddress + i ), bMask, szMask ) )
             return (DWORD)( dwAddress + i );
    return 0;
}Code: Select all
FindPattern( DWORD dwAddress, DWORD dwLen, BYTE *bMask, char * szMask )Greets.



