1、这是一个C/C++ 与 SSE 实现的特征码加速算法,是一般暴力搜索算法代码的3倍以上的速度。
2、本文附带两种实现方法,一种暴力搜索,一种SSE加速暴力搜索。
3、特征码定位格式以OD为标准【BB ?? ?? ?? ?? 8B C3 33 C9 BA ?? ?? ?? ?? E8】默认我将??替换成了'X'方便算法过滤
4、当然您可以动手修改成您自己想要的格式。
5、头文件以及其他依赖项请自行添加

#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <immintrin.h>
 
namespace test
{
    using s8  = int8_t;
    using s16 = int16_t;
    using s32 = int32_t;
    using s64 = int64_t;
 
    using u8  = uint8_t;
    using u16 = uint16_t;
    using u32 = uint32_t;
    using u64 = uint64_t;
 
    using s96 = intptr_t;
    using u96 = uintptr_t;
 
    static unsigned char hex[] = { 0xE9, 0x3B, 0x9A, 0x0A, 0x00, 0xE9, 0x96, 0xBC, 0x05, 0x00, 0xE9, 0xA1, 0x56, 0x07, 0x00, 0xE9, 0x2C, 0x3A, 0x05, 0x00, 0xE9, 0xB7, 0x57, 0x07, 0x00, 0xE9, 0x72, 0x77, 0x04, 0x00, 0xE9, 0xDD, 0xAD, 0x08, 0x00, 0xE9, 0xF8, 0xDF, 0x06, 0x00, 0xE9, 0xE3, 0xBB, 0x01, 0x00, 0xE9, 0x4E, 0xDC, 0x03, 0x00, 0xE9, 0x49, 0xD6, 0x03, 0x00, 0xE9, 0xE4, 0x3F, 0x03, 0x00, 0xE9, 0x8F, 0x7C, 0x01, 0x00, 0xE9, 0xFA, 0xCD, 0x08, 0x00, 0xE9, 0x05, 0xEA, 0x05, 0x00, 0xE9, 0xA0, 0xB3, 0x03, 0x00, 0xE9, 0x9B, 0xEC, 0x04, 0x00, 0xE9, 0x16, 0x2E, 0x05, 0x00, 0xE9, 0xA1, 0x33, 0x0C, 0x00, 0xE9, 0x1C, 0xB0, 0x0C, 0x00, 0xE9, 0xE7, 0x08, 0x04, 0x00, 0xE9, 0xB2, 0xC4, 0x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, 0x00, 0xE9, 0x0D, 0xE7, 0x0C, 0x00, 0xE9, 0x28, 0x2A, 0x08, 0x00, 0xE9, 0x33, 0x5A, 0x02, 0x00, 0xE9, 0x9E, 0xD5, 0x03, 0x00, 0xE9, 0x29, 0x55, 0x07, 0x00, 0xE9, 0xE4, 0xE1, 0x07, 0x00, 0xE9, 0x0F, 0xDD, 0x07, 0x00, 0xE9, 0x6A, 0xDE, 0x07, 0x00, 0xE9, 0xF5, 0x73, 0x0D, 0x00, 0xE9, 0xF0, 0xC6, 0x04, 0x00, 0xE9, 0xFB, 0xD4, 0x0A, 0x00, 0xE9, 0x26, 0xE9, 0x02, 0x00, 0xE9, 0x41, 0x30, 0x05, 0x00 };
 
    static constexpr char charhexset[] = "0123456789ABCDEFabcdef";
 
    static bool StringReplace(std::string& source, const std::string& delimiters, const std::string& dispose = "", const std::size_t offset = 1)
    {
        if (source.empty())
        {
            return false;
        }
 
        if (delimiters.empty())
        {
            return true;
        }
 
        for (std::string::size_type pos = source.find(delimiters); pos != std::string::npos; pos = source.find(delimiters))
        {
            if (source.replace(pos, offset, dispose).size())
            {
                continue;
            }
            return false;
        }
 
        return true;
    }
 
    static bool Hexadec2xdigit(const std::string& data, std::string& buffer, std::size_t offset)
    {
        if (data.empty())
        {
            return false;
        }
 
        for (std::size_t i = 0; i < data.size(); i += offset)
        {
            if (isxdigit(data[i]))
            {
                buffer += static_cast<char>(std::stoul(data.substr(i, offset), nullptr, 16));
            }
            else
            {
                buffer += 'X';
            }
        }
 
        return true;
    }
 
 
    static bool Hexadec2xdigitEx(const std::string& data, std::string& buffer, u32 checkxdigit = 0, u32 transform = 1)
    {
        if (data.empty())
        {
            return false;
        }
 
        std::string masks(data);
        {
            // 去掉 0x 去掉 空格
            if (StringReplace(masks, "0x") && StringReplace(masks, " "))
            {
                // 大小写转换
                if (masks.end() == (1 == transform ? std::transform(masks.begin(), masks.end(), masks.begin(), [] (unsigned char ch) { return toupper(ch); }) : std::transform(masks.begin(), masks.end(), masks.begin(), [] (unsigned char ch) { return tolower(ch); })))
                {
                    // 检查是否是完整的十六进制数
                    if (checkxdigit)
                    {
                        if (std::string::npos != masks.find_first_not_of(charhexset))
                        {
                            return false;
                        }
                    }
 
                    return Hexadec2xdigit(static_cast<const std::string&>(masks), buffer, 2);
                }
            }
        }
 
        return false;
    }
 
    static bool SearchPattern(const u8* pos, const std::string& chars)
    {
        for (std::string::const_iterator xdigit = chars.cbegin(); xdigit != chars.cend(); ++xdigit, ++pos)
        {
            if (*pos != static_cast<const u8>(*xdigit) &&           // no match
                'X' != static_cast<const u8>(*xdigit))              // filter out arbitrary characters
            {
                return false;
            }
            else
            {
                // hit character
                continue;
            }
        }
 
        return true;
    }
 
    static bool SearchPattern(const u8* start,                      // start address
                              const u8* end,                        // end address
                              const std::string& keyword,           // characteristic code
                              std::size_t index,                    // take out the serial number
                              std::size_t offset,                   // pointer offset
                              void*& address)                       // return to address
    {
        if (keyword.empty())
        {
            return true;
        }
 
        if (start != end && end > start && static_cast<std::size_t>(end - start) > keyword.size())
        {
            std::string chars;
            {
                if (Hexadec2xdigitEx(keyword, chars, 0))
                {
                    for (auto [pos, i] = std::make_tuple(start, static_cast<std::size_t>(0)); pos <= end; ++pos)
                    {
                        if (SearchPattern(pos, chars))
                        {
                            if (++i != index)
                            {
                                continue;
                            }
                            else
                            {
                                address = reinterpret_cast<void*>(const_cast<u8*>(reinterpret_cast<const u8*>(pos)) + offset);
                            }
 
                            return false;
                        }
                    }
                }
            }
        }
 
        return true;
    }
 
    template <typename Type = void*>
    static bool SearchPattern(const u96 start,                      // start address
                              const u96 end,                        // end address
                              const std::string& keyword,           // characteristic code
                              std::size_t index,                    // take out the serial number
                              std::size_t offset,                   // pointer offset
                              Type& address)                        // number of characteristic multiples
    {
        return SearchPattern(reinterpret_cast<const u8*>(start), reinterpret_cast<const u8*>(end), keyword, index, offset, reinterpret_cast<void*&>(address));
    }
 
    static bool SearchPatternEx(const u8* start,                    // start address
                                const u8* end,                      // end address
                                const std::string& chars,           // characteristic code
                                std::size_t index,                  // take out the serial number
                                std::size_t offset,                 // pointer offset
                                void*& address,                     // return to address
                                std::size_t count)                  // number of characteristic multiples
    {
        for (auto [masks, i, n, pos] = std::make_tuple(std::array<std::size_t, 32>{}, static_cast<std::size_t>(0), static_cast<std::size_t>(0), start); i < count; ++i)
        {
            for (std::size_t j = 0; j < 16 && n < chars.size(); ++j, ++n)
            {
                if ('X' != reinterpret_cast<const s8*>(chars.c_str() + i * 16)[j])
                {
                    masks[i] |= static_cast<std::size_t>(1) << j;
                }
            }
 
            for (auto [store, j] = std::make_tuple(_mm_loadu_si128(reinterpret_cast<const __m128i *>(chars.c_str() + i * 16)), static_cast<std::size_t>(0)); pos <= end; _mm_prefetch(reinterpret_cast<const char*>(++pos + 64), _MM_HINT_NTA))
            {
                if (static_cast<std::size_t>(static_cast<std::size_t>(_mm_movemask_epi8(_mm_cmpeq_epi8(_mm_loadu_si128(reinterpret_cast<const __m128i *>(pos + i * 16)), store))) & masks[i]) == masks[i])
                {
                    if (n < chars.size())
                    {
                        break;
                    }
 
                    if (++j != index)
                    {
                        continue;
                    }
                    else
                    {
                        address = reinterpret_cast<void*>(const_cast<u8*>(reinterpret_cast<const u8*>(pos)) + offset);
                    }
 
                    return true;
                }
            }
        }
 
        return false;
    }
 
    static bool SearchPatternEx(const u8* start,                    // start address
                                const u8* end,                      // end address
                                const std::string& keyword,         // characteristic code
                                std::size_t index,                  // take out the serial number
                                std::size_t offset,                 // pointer offset
                                void*& address)                     // return to address
    {
        if (keyword.empty())
        {
            return false;
        }
 
        if (start != end && end > start && static_cast<std::size_t>(end - start) > keyword.size())
        {
            std::string chars;
            {
                if (Hexadec2xdigitEx(keyword, chars, 0))
                {
                    return SearchPatternEx(start, end, chars, index, offset, address, static_cast<std::size_t>((((chars.size()) + (16 - 1)) & ~(16 - 1)) >> 4));
                }
            }
        }
 
        return false;
    }
 
    template <typename Type = void*>
    static bool SearchPatternEx(u96 start,                          // start address
                                u96 end,                            // end address
                                const std::string& keyword,         // characteristic code
                                std::size_t index,                  // take out the serial number
                                std::size_t offset,                 // pointer offset
                                Type& address)                      // return to address
    {
        return SearchPatternEx(reinterpret_cast<const u8*>(start), reinterpret_cast<const u8*>(end), keyword, index, offset, reinterpret_cast<void*&>(address));
    }
}


int main()
{
    std::string string_hex = "E9 C3 8B ?? ?? E9 ?? 01 0A 00 E9 ?? 4A 02 ?? E9 ?? 22 ?? ?? ?? FF 75 04 00 E9 2A EB 07 ?? E9 ?? 30 ?? 00 ?? ?? 50";
 
    void* address = 0;
 
    test::SearchPatternEx(test::hex, test::hex + sizeof(test::hex), string_hex, 1, 0, address);
 
    printf("%p\n", address);
 
    return 0;
}

#include <iostream>
#include <string>
#include <random>
#include <cassert>

std::string generate_random_string()
{
    static const constexpr char allowed_chars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

    std::default_random_engine random_engine(std::random_device{}());
    std::uniform_int_distribution<std::size_t> random_distribution(0, sizeof(allowed_chars));

    std::string cname(static_cast<std::size_t>(std::uniform_int_distribution<std::size_t>{}(*const_cast<std::default_random_engine*>(std::addressof(static_cast<const std::default_random_engine&>(std::move(std::default_random_engine(std::random_device{}()))))), std::uniform_int_distribution<std::size_t>::param_type(6, sizeof(allowed_chars)))), '\0');

    for (std::string::value_type& chars : cname)
    {
        chars = allowed_chars[static_cast<std::size_t>(random_distribution(random_engine) % (sizeof(allowed_chars) - 1))];
    }

    return cname;
}

int main()
{
    for (int i = 0; i < 12000; ++i)
    {
        printf("%s\n", generate_random_string().c_str());
    }

    getchar();

    return 0;
}

Visual Studio 2010
Ultimate: YCFHQ-9DWCY-DKV88-T2TMH-G7BHP

Visual Studio 2013
Professional: XDM3T-W3T3V-MGJWK-8BFVD-GVPKY
Premium: FBJVC-3CMTX-D8DVP-RTQCT-92494
Ultimate: BWG7X-J98B3-W34RT-33B3R-JVYW9
Team Foundation Server: MHG9J-HHHX9-WWPQP-D8T7H-7KCQG

Visual Studio 2015
Professional: HMGNV-WCYXV-X7G9W-YCX63-B98R2
Enterprise: HM6NR-QXX7C-DFW2Y-8B82K-WTYJV
Visual Studio 2017
Test Professional: VG622-NKFP4-GTWPH-XB2JJ-JFHVF
Professional: KBJFW-NXHK6-W4WJM-CRMQB-G3CDH | 4F3PR-NFKDB-8HFP7-9WXGY-K77T7
Enterprise: NJVYC-BMHX2-G77MM-4XJMR-6Q8QF | N2VYX-9VR2K-T733M-MWD9X-KQCDF

Visual Studio 2019
Professional: NYWVH-HT4XC-R2WYW-9Y3CM-X4V3Y | NJVYC-BMHX2-G77MM-4XJMR-6Q8QF
Enterprise: BF8Y8-GN2QH-T84XB-QVY3B-RC4DF | KBJFW-NXHK6-W4WJM-CRMQB-G3CDH

Visual Studio 2022
Professional: TD244-P4NB7-YQ6XK-Y8MMM-YWV2J
Enterprise: VHF9H-NXBBB-638P6-6JHCY-88JWH

Visual Studio 2022: https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes

Visual Studio 2019: https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes

Visual Studio 2017: https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes

Visual Studio 2015: https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2015-update3-vs

Visual Studio 2013: https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2013-update5-vs

Visual Studio 2012: https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2012-update4-vs

Visual Studio 2010: https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2010-sp1-vs