Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 19:05

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Problem bei pattern search

Discussion on Problem bei pattern search within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
EthnicX's Avatar
 
elite*gold: 301
Join Date: Mar 2010
Posts: 1,227
Received Thanks: 170
Problem bei pattern search

Moinsen, ich habe folgenden code im Internet für einen Pattern scan gefunden:

Main.cpp
Code:
#include <StdAfx.h>
#include <Windows.h>
#include <iostream>  
#include "Functions.h"
using namespace std;

//Define all Here, its easier.
char BytesToPatch[] = "\x90\x90"; //What we are replacing with, for example \x90\ = NOP.
char ProcessName[] = "TheCodenZ.exe"; //Processname
char BytePattern[] = "\xFF\x0E\x8D\x74\x24\x24\xE8\x00\x00\x00\x00\x5F\x5E\xB0\x01\x5B\x8B\xE5\x5D\xC2\x04\x00"; //Our Pattern
char ByteMask[] = "xxxxxxx????xxxxxxxxxxx"; //Our Mask
int Position = 0; //0 means first.
int NoOfBytes = 2;

//Our Main Function
void InitiatePatch()
{    
    DWORD Bytes = FindPattern(ProcessName, BytePattern, ByteMask);
    Bytes+= Position;
    WriteToMemory(Bytes, BytesToPatch, NoOfBytes);
        
}
Functions.h
Code:
#include <Psapi.h>



//Get all module related info, this will include the base DLL. 
//and the size of the module
MODULEINFO GetModuleInfo( char *szModule ) //Hier steckt der Fehler
{
    MODULEINFO modinfo = {0};
    HMODULE hModule = GetModuleHandle(szModule);
    if(hModule == 0) 
        return modinfo;
    GetModuleInformation(GetCurrentProcess(), hModule, &modinfo, sizeof(MODULEINFO));
    return modinfo;
}


void WriteToMemory(uintptr_t addressToWrite, char* valueToWrite, int byteNum)
{
    //used to change our file access type, stores the old
    //access type and restores it after memory is written
    unsigned long OldProtection;
    //give that address read and write permissions and store the old permissions at oldProtection
    VirtualProtect((LPVOID)(addressToWrite), byteNum, PAGE_EXECUTE_READWRITE, &OldProtection);

    //write the memory into the program and overwrite previous value
    memcpy( (LPVOID)addressToWrite, valueToWrite, byteNum);

    //reset the permissions of the address back to oldProtection after writting memory
    VirtualProtect((LPVOID)(addressToWrite), byteNum, OldProtection, NULL);
}


DWORD FindPattern(char *module, char *pattern, char *mask)
{
    //Get all module related information
    MODULEINFO mInfo = GetModuleInfo(module);

    //Assign our base and module size
    //Having the values right is ESSENTIAL, this makes sure
    //that we don't scan unwanted memory and leading our game to crash
    DWORD base = (DWORD)mInfo.lpBaseOfDll;
    DWORD size =  (DWORD)mInfo.SizeOfImage;

    //Get length for our mask, this will allow us to loop through our array
    DWORD patternLength = (DWORD)strlen(mask);

    for(DWORD i = 0; i < size - patternLength; i++)
    {
        bool found = true;
        for(DWORD j = 0; j < patternLength; j++)
        {
            //if we have a ? in our mask then we have true by default, 
            //or if the bytes match then we keep searching until finding it or not
            found &= mask[j] == '?' || pattern[j] == *(char*)(base + i + j);
        }

        //found = true, our entire pattern was found
        //return the memory addy so we can write to it
        if(found) 
        {
            return base + i;
        }
    }

    return NULL;
}
Jetzt wenn ich diesen code compilen möchte bekomme ich jedes mal diesen Fehler:
" error C2664: 'GetModuleHandleW': Konvertierung des Parameters 1 von 'char *' in 'LPCWSTR' nicht möglich"

Ich bin jetzt kein Profi, aber ich frage mich wie kann es sein das ein Code der bei jedem anderen zu compilen geht, nur bei mir nicht funktoniert.
EthnicX is offline  
Old 04/29/2014, 14:47   #2
 
elite*gold: 5
Join Date: Aug 2010
Posts: 745
Received Thanks: 3,041
Use MultiByteToWideChar for char* to lpcwstr.
lalaker1 is offline  
Thanks
1 User
Old 04/29/2014, 21:25   #3
 
​Tension's Avatar
 
elite*gold: 110
Join Date: Jun 2013
Posts: 599
Received Thanks: 510
Oder GetModuleHandleA.
Wenn du aber bei solchen Fehlermeldungen scheiterst solltest du eventuell die Grundlagen lernen.
​Tension is offline  
Old 04/29/2014, 22:40   #4
 
EthnicX's Avatar
 
elite*gold: 301
Join Date: Mar 2010
Posts: 1,227
Received Thanks: 170
Ich bin momentan auch nicht daran wirklich interessiert die Programmiersprache zu lernen, ich muss allerdings ein paar Sachen versuchen da Cheat Engine nun von dem Spiel was ich hacken möchte geblockt wird.
Lieber würde ich das mit Autoit machen, das kann ich besser doch das wird auch nicht wirklich was ohne dll injection.
EthnicX is offline  
Old 04/30/2014, 06:57   #5

 
Delinquenz's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 1,160
Received Thanks: 232
Quote:
Ich bin momentan auch nicht daran wirklich interessiert die Programmiersprache zu lernen
Dann frag wen, ob er dir das für Geld macht. Wenn du daran nicht interessiert bist, dann lass es.
Delinquenz is offline  
Old 04/30/2014, 15:49   #6
 
EthnicX's Avatar
 
elite*gold: 301
Join Date: Mar 2010
Posts: 1,227
Received Thanks: 170
Quote:
Originally Posted by Delinquenz View Post
Dann frag wen, ob er dir das für Geld macht. Wenn du daran nicht interessiert bist, dann lass es.
EthnicX is offline  
Reply


Similar Threads Similar Threads
AutoIT Pattern Search ?
01/27/2014 - AutoIt - 2 Replies
Ich wolte mal eine kleine frage stellen ich habe es wersucht mit autoit pattern search aber ich glaube irgendwas habe ich falsch gemacht kan mir jemad bitte schreiben was ich falsch gemacht habe und erkleren bitte ? danke . Code: #include <NomadMemory.au3> #include <PatternSearch.au3> ;//Sig maker Base adress 0x3650000 - Scan size 0x140000 Global Const $Player_Basepoint_Pattern = "\x20\x12\x62\x00\x01\x00\x00\x00\x20\x50\x3F \x03\x00\x00\x00\x00\x6F\x00\x19\x00\xF1";
[Regex] Problem mit Pattern
02/12/2013 - .NET Languages - 9 Replies
Hallo meine lieben, habe folgende zwei Probleme Dort möchte ich per Regex den Namen : johann.goldbaum Dieser ändert sich natürlich also .* ? Pattern:Dim ra As New Regex("<a class=""fbxWelcomeBoxBlock _8o _8s lfloat"" href=""http:\/\/www.facebook.com\/(?< name>(+))") Funktioniert nicht.
[Frage] Search Pattern Signature
06/09/2012 - Nostale - 5 Replies
Ich versuche schon seit einiger Zeit eine gleichbleibende Signatur zu finden, bekomme es aber einfach nicht hin. :/ Als Beispiel hab ich den HP-Pointer benutzt: Address: 007D5500 Signature: \x60\x40\xD9\x07\xC0\xDF\x4A Mask: xxxxxxx Aber nachdem ich NosTale neu gestartet habe, findet er die Signature nicht mehr, weil sie sich verändert hat.
Search Pattern [HILFE]
10/08/2011 - General Coding - 5 Replies
Hallo alle zusammen, ich habe Probleme mit Pattern. Ich habe so einige Fragen : 1. Wenn ich mein Pointer finde wie kann ich in OllyDbg zu diesem Pointer gehen ? 2. Woher was ich das Offset des Pattern ? 3. Hättet ihr gut deutsche Tutorials ?
Pattern based memory Search ?
12/26/2006 - General Coding - 3 Replies
Is there any tool that allows to search for patterns in memory ? All I tried (TSearch / Cheatengine) only allow you to search for one value or a fixed array of bytes. But I need a tool that lets me search for patterns, like XX XX 00 00 XX XX 00 00 while XX can be 00 to FF etc ?



All times are GMT +1. The time now is 19:06.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.