Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::uintptr_t util::FindPattern( const char* smodule, const char* pattern, bool only_text_or_code, bool format ) {
- const auto mod_p = (uintptr_t)util::get_module_base_ansi( smodule );
- PIMAGE_DOS_HEADER pe_headers = (PIMAGE_DOS_HEADER)mod_p;
- PIMAGE_NT_HEADERS new_pe_headers = PIMAGE_NT_HEADERS( (uint8_t*)( mod_p + pe_headers->e_lfanew ) );
- DWORD dwSizeOfImage;
- DWORD end;
- uintptr_t begin;
- if ( only_text_or_code ) {
- PIMAGE_SECTION_HEADER Section = IMAGE_FIRST_SECTION( new_pe_headers );
- for ( WORD i = 0; i < new_pe_headers->FileHeader.NumberOfSections; i++ ) {
- if ( !fast_strcmp( (char*)Section->Name, ".code" ) || !fast_strcmp( (char*)Section->Name, ".text" ) ) {
- begin = Section->VirtualAddress;
- dwSizeOfImage = Section->SizeOfRawData;
- end = begin + dwSizeOfImage;
- //printf( "%-8s\t%x\t%x\t%x\n", Section->Name, Section->VirtualAddress,
- // Section->PointerToRawData, Section->SizeOfRawData );
- }
- Section++;
- }
- }
- else {
- begin = mod_p;
- dwSizeOfImage = new_pe_headers->OptionalHeader.SizeOfImage;
- end = begin + dwSizeOfImage;
- }
- if ( const auto result = reinterpret_cast<std::uintptr_t>( find_pattern_internal( begin, end, format ? ParseCombo( pattern ).c_str( ) : pattern ) ); result ) {
- return result;
- }
- return NULL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement