S
S
SKREPKA1232018-03-28 14:08:39
C++ / C#
SKREPKA123, 2018-03-28 14:08:39

Vector subscript out of range - Visual C++ how to fix?

There is one error left (the error crashes only on other computers, there is no such error on the computer where the compilation takes place):
vector subscript out of range
screen in attack
vector is used only when loading a file (add lines to the push_back vector) in the search procedure
vector<string> signBase; //(MAX_PATH);

bool scanSig(string path, int signCount)
{
    InitConsole();
    FILE *in1 = fopen(path.c_str(), "rb");
    if (!in1) cout << "Couldn't open file";
    for (int wsignCount = 0; wsignCount < signCount; wsignCount++)
    {
        //Convert string vector to int
        istringstream iss(signBase[wsignCount]);
        vector<string> results(istream_iterator<string>{iss},
            istream_iterator<string>());
        reverse(results.begin(), results.end());
        vector <int> signInt(results.size());
        //cout << "check: " << signBase[wsignCount] << endl;
        int resultsSize = results.size();
 
        for (int i = 0; i < results.size(); i++)
        {
            stringstream ss;
            ss << hex << results[i];
            int x;
            ss >> x;
            signInt[i] = x;
        }
 
        //unsigned char buf[26000];
        unsigned char buf[MAX_PATH];        
        int z = 0;
        size_t count;
        //while (count = fread(buf, sizeof(buf[0]), 26000, in1)) {
        while (count = fread(buf, sizeof(buf[0]), MAX_PATH, in1)) {
            int i;
            for (i = 0; i < count; ++i) {
 
                if ((int)buf[i] == signInt[0])
                {
                    for (z = 1; z < resultsSize; z++)
                    {
                        if (buf[i - z] != signInt[z]) break;
                    }
                    if (z == resultsSize)
                    {
                        detectedSignature = signBase[wsignCount];
                        detectedPath = path;
                        botFound = true;
                        cout << "Detected: " << path << endl << signBase[wsignCount]  << endl;
                    }
                }
                sleepCount++;
                if (sleepCount == 3000)
                {
                Sleep(6);
                sleepCount = 0;
                }
            }
        }
 
 
    }
    fclose(in1);
    return 0;                       
}

tell me where could be the problem
5abb7797e4534311498445.jpeg

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question