ReadProcessMemory输出中的C++正则表达式

C++ regular expression from ReadProcessMemory output

本文关键字:C++ 正则表达式 输出 ReadProcessMemory      更新时间:2023-10-16

我想匹配记事本进程内存中的一些字符串,但没有成功。这是代码:

int bytes_to_read = (int)info.RegionSize;
char *buffer;
buffer = (char*)malloc(bytes_to_read+1);
ReadProcessMemory(hProcess, info.BaseAddress, buffer, bytes_to_read, NULL);
const char *t1re = ";\d{0,19}";
regex ret1(t1re);
cmatch match;
if(regex_search(buffer, match, ret1))
{
    cout << "Found: " << pe32.szExeFile << "n";
    system("pause");
}

记事本,作为一个Windows程序,可能使用UCS-2,或者我想现在使用UTF-16。这意味着您需要一个Unicode正则表达式。

你确定regex_search甚至适用于二进制数据吗?它可能会在第一个零字节处退出,认为它是字符串的末尾。