Results 1 to 15 of 18

Threaded View

  1. #1
    yodaliketaco's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    winsock.dll
    Posts
    645
    Reputation
    45
    Thanks
    514
    My Mood
    Tired

    My pattern finding function

    There are probably still some errors with this (I have never coded hacks before; I wrote this yesterday in the span of about 20 minutes), but I thought I'd share my ideas. The idea is to make a more efficient pattern finding function. I based this off of the boyer-moore string searching algorithm.

    Code:
    #define realAddy( cast, base, offset ) (cast)((DWORD)(base) + (DWORD)(offset))
    template <typename T>
    bool exist(BYTE part, T whole)
    {
    	BYTE *start = (BYTE*)&whole;
    	for(DWORD loc = 0; loc < sizeof(whole); loc++)
    		if(*(BYTE*)(start + loc) == part) return true;
    	return false;
    }
    DWORD lastLocationOfByte(BYTE part, T whole)
    {
    	BYTE *start = (BYTE*)&whole;
    	for(DWORD loc = 0; loc < sizeof(whole); loc++)
    		if(*(BYTE*)(start + sizeof(whole) - loc) == part) return (sizeof(whole) - loc);
    }
    T *searchAddy(T val)
    {
    	MEMORY_BASIC_INFORMATION memInfo;
    	VirtualQuery(NULL, &memInfo, sizeof(MEMORY_BASIC_INFORMATION));
    	size_t total = memInfo.RegionSize;
    	T *first = (T*)memInfo.BaseAddress;
    	size_t next = sizeof(val);
    	T *addy = (T*)(--(&val + next));
    	bool exist = false;
    	T *loc;
    	unsigned char check;
    	for(DWORD n = (next - 1); n < total;)
    	{
    		DWORD spot;
    		for(spot = 0; *(unsigned char*)(first + n - spot) == *(unsigned char*)(addy - spot); spot++);
    		if(spot == next) return realAddy( T*, first, n );
    		else if(exist(*(BYTE*)(first + n), val)
    			n += lastLocationOfByte(*(BYTE*)(first + n), val);
    		else n += next;
    	}
    	return false;
    }

    I haven't tested this yet because I am still working on making a complete hack (I don't want to use someone else's base). If you try this out, please tell me how it worked for you.

  2. The Following User Says Thank You to yodaliketaco For This Useful Post:

    DecoderBack (08-03-2011)

Similar Threads

  1. finding and hooking an unknown function
    By JonnyD in forum General Game Hacking
    Replies: 1
    Last Post: 08-26-2010, 06:51 AM
  2. Replies: 8
    Last Post: 07-09-2007, 03:15 PM
  3. Replies: 37
    Last Post: 06-20-2006, 04:24 PM
  4. hi can any1 help me make or find a cheat code
    By CrUsHa in forum WarRock - International Hacks
    Replies: 3
    Last Post: 05-19-2006, 04:39 PM
  5. Where do i find WPE Pro?
    By Rileyman1211 in forum WarRock - International Hacks
    Replies: 1
    Last Post: 01-16-2006, 09:52 AM