Answer the question
In order to leave comments, you need to log in
How to find a string in a vector using a regular expression?
I read the memory of the process and put everything in a vector
std::vector<char> ProcData;
void GetProcMemToVec(DWORD dwPID)
{
HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPID);
if (process)
{
SYSTEM_INFO si;
GetSystemInfo(&si);
MEMORY_BASIC_INFORMATION info;
char* p = 0;
while (p < si.lpMaximumApplicationAddress)
{
if (VirtualQueryEx(process, p, &info, sizeof(info)) == sizeof(info))
{
p = (char*)info.BaseAddress;
ProcData.resize(info.RegionSize);
SIZE_T bytesRead;
ReadProcessMemory(process, p, &ProcData[0], info.RegionSize, &bytesRead);
p += info.RegionSize;
}
}
}
}
Как проверить имеется ли в векторе строка, начинающаяся допустим с 7132(содержащая только числа после нее) и если имеется, занести в буффер 7132+10 символов после них?
Answer the question
In order to leave comments, you need to log in
https://ideone.com/RbikEj
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
int main() {
vector<char> ProcData = {'T','e','s','t',' ','t','e','x','t',' ','7','1','3','2',' ','L','o','r','e','m',' ','i','p','s','u','m',' ','d','o','l','o','r',' ','s','i','t',' ','a','m','e','t'};
const char *sub = strstr ( ProcData.data(), "7132" );
if(sub){
char word[15] = {'\0'};
strncpy( word, sub, 14 );
cout << word;
}
return 0;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question