[General C++] Problems with my FindPattern menu

User Tag List

Results 1 to 5 of 5
  1. #1
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [General C++] Problems with my FindPattern

    Hi.

    Today I was bored and I wanted to write an out-of-process version of FindPattern for myself.

    But for some reason it just doesn't work..maybe someone can look at my code for a sec? Thanks

    Code:
    bool Process::DataCompare(string data, int index, string pattern, string mask)
    {
        for (unsigned int i = 0; i < pattern.length(); i++)
        {
            if (mask[i] == 'x' && data[index + i] != pattern[i])
                return false;
        }
    
        return true;
    }
    
    DWORD Process::FindBinaryPattern(DWORD StartAddress, int Length, string pattern, string mask)
    {
        int index = 0;
        string buffer;
    
        if(FINDBINARYPATTERN_BYTESTOREAD > Length)
        {
            buffer = ReadMemString(StartAddress, Length);
    
            for(unsigned int i = 0; i < (Length - pattern.length()); i++)
            {
                if(DataCompare(buffer, i, pattern, mask))
                    return static_cast<DWORD>(StartAddress + i);
            }
        }
        else
        {
            while(index < Length)
            {
                buffer = ReadMemString(StartAddress + index, FINDBINARYPATTERN_BYTESTOREAD + pattern.length());
    
                for (unsigned int i = 0; i < FINDBINARYPATTERN_BYTESTOREAD; i++)
                {
                    if(DataCompare(buffer, i, pattern, mask))
                        return static_cast<DWORD>(StartAddress + index + i);
                }
    
                index += FINDBINARYPATTERN_BYTESTOREAD;
            }
        }
    
        return static_cast<DWORD>(NULL);
    }
    Greetings...

    [General C++] Problems with my FindPattern
  2. #2
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't use DWORD's to hold addresses, use a DWORD_PTR. Don't use an 'unsigned int' in a loop that takes the length of a STL container, use container::size_type. Don't manually loop over STL containers unless you have to, the STL algorithms are there for a reason.

    Yawn.

    None of that is actually going to solve your current problem (probably) but it will likely solve future ones if you ever intend to make your code portable.

  3. #3
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you considered grading CS101 projects?

    Nah... never mind. You'd run out of red ink...
    Don't believe everything you think.

  4. #4
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by amadmonk View Post
    Have you considered grading CS101 projects?

    Nah... never mind. You'd run out of red ink...

    Rofl, there's a thought! That would be fun, I'd be getting paid to complain all day long. Woot!

  5. #5
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whoooodawooop, changed every DWORD to a DWORD_PTR.
    As long as the code is dirty i ll keep on doing that dirty loop, but thanks anyway.

    Anyone a hint what I did wrong in my code?

Similar Threads

  1. Problems With Instance Switching
    By SandLOL in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 08-30-2006, 09:22 PM
  2. Problem with WPE
    By weedlord in forum World of Warcraft General
    Replies: 0
    Last Post: 08-14-2006, 03:35 AM
  3. Problem with BWH 1.11.2
    By gwl15 in forum World of Warcraft General
    Replies: 3
    Last Post: 08-11-2006, 05:37 PM
  4. Problem with CE.
    By Eldretch in forum World of Warcraft General
    Replies: 1
    Last Post: 08-08-2006, 06:49 PM
  5. I have problem with BHW 3.0
    By sunrize1 in forum World of Warcraft General
    Replies: 1
    Last Post: 07-17-2006, 08:49 AM
All times are GMT -5. The time now is 05:11 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search