Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    yodaliketaco's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    winsock.dll
    Posts
    646
    Reputation
    45
    Thanks
    511
    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)

  3. #2
    CAFlames's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    Where ever my imagination takes me
    Posts
    3,014
    Reputation
    202
    Thanks
    2,934
    My Mood
    Twisted
    Don't really have time to look at it, but good job.

    Current Works:
    ---Horror Game






    Special thanks to drgnforce9 for my sig picture

    Quote Originally Posted by m_t_h View Post

    CAflames is one epic coder.

    Rep and thanks him.. or you're perma banned.

  4. #3
    Fabolous's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    192.168.1.01
    Posts
    2,706
    Reputation
    261
    Thanks
    682
    My Mood
    Paranoid
    Already looking at the code, i see some undefined stuff, might wanna look over it bruh.

  5. #4
    supercarz1991's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    North of Hell, South of Heaven
    Posts
    6,066
    Reputation
    323
    Thanks
    3,319
    My Mood
    Doh
    lol gettin into the coding i see, modding get boring? :P

    commando: You're probably the best non-coder coder I know LOL


  6. #5
    yodaliketaco's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    winsock.dll
    Posts
    646
    Reputation
    45
    Thanks
    511
    My Mood
    Tired
    Updated it a bit to fix some issues... haven't tested yet.

    Code:
    #define realAddy( cast, base, offset ) (cast)((DWORD)(base) + (DWORD)(offset))
    template <typename T>
    bool bExist(BYTE part, T whole)
    {
    	BYTE *start = (BYTE*)&whole;
    	for(DWORD loc = 0; loc < sizeof(whole); loc++)
    		if((*(BYTE*)(start + loc) == part) || (*(BYTE*)(start + loc) == '?')) return true;
    	return false;
    }
    template <typename T>
    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) || (*(BYTE*)(start + loc) == '?')) return (sizeof(whole) - loc);
    }
    template <typename T>
    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) - 1);
    	bool exist = false;
    	T *loc;
    	for(DWORD n = (next - 1); n < total;)
    	{
    		DWORD spot;
    		for(spot = 0; (*(unsigned char*)(first + n - spot) == *(unsigned char*)(addy - spot)) || (*(unsigned char*)(addy - spot) == '?'); spot++);
    		if(spot == next) return realAddy( T*, first, n );
    		else if(bExist(*(BYTE*)(first + n), val))
    			n += lastLocationOfByte(*(BYTE*)(first + n), val);
    		else n += next;
    	}
    	return false;
    }

    Quote Originally Posted by supercarz1991 View Post
    lol gettin into the coding i see, modding get boring? :P
    Yes. Modding got boring a while ago, I'm more interested in game development.
    Last edited by yodaliketaco; 07-25-2011 at 03:38 PM.

  7. #6
    supercarz1991's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    North of Hell, South of Heaven
    Posts
    6,066
    Reputation
    323
    Thanks
    3,319
    My Mood
    Doh
    same here, i just redownloaded the lithtech jupiter source and something called XNA engine

    commando: You're probably the best non-coder coder I know LOL


  8. #7
    yodaliketaco's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    winsock.dll
    Posts
    646
    Reputation
    45
    Thanks
    511
    My Mood
    Tired
    Just finished my hotkey base... the address finding function executes, but when I use the provided address with my PTC function:
    Code:
    void __cdecl PTC(const std::string called)
    {
    	if(!PTCaddy)
    	{
    		PTCaddy = (void*)searchAddy("ι????0xΜΜΜΜΜΜΜΜΜΜΜ΅????");
    		return;
    	}
    	__asm
    	{
    		push called
    		call PTCaddy
    		add esp, 0x4
    	}
    }
    The game crashes. I've looked at some other PTC functions and it seems that most people prefer to use C strings. I prefer having access to string methods for my decryption function, but this may be causing my issue. I will update when I get different results.




    Quote Originally Posted by supercarz1991 View Post
    same here, i just redownloaded the lithtech jupiter source and something called XNA engine
    I'm waiting for the cryengine 3 sdk. I'm interesting in making an RTS.
    Last edited by yodaliketaco; 07-26-2011 at 01:21 PM.

  9. #8
    mmbob's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    ja
    Posts
    655
    Reputation
    70
    Thanks
    1,156
    My Mood
    Bitchy
    Quote Originally Posted by yodaliketaco View Post

    Code:
    void __cdecl PTC(const std::string called)
    {
    	if(!PTCaddy)
    	{
    		PTCaddy = (void*)searchAddy("ι????0xΜΜΜΜΜΜΜΜΜΜΜ΅????");
    		return;
    	}
            const char* pNigga = called.c_str();
    	__asm
    	{
    		push pNigga
    		call PTCaddy
    		add esp, 0x4
    	}
    }
    Fixed. That's why people use C strings.

  10. The Following User Says Thank You to mmbob For This Useful Post:

    yodaliketaco (07-26-2011)

  11. #9
    CAFlames's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    Where ever my imagination takes me
    Posts
    3,014
    Reputation
    202
    Thanks
    2,934
    My Mood
    Twisted
    Quote Originally Posted by mmbob View Post

    Fixed. That's why people use C strings.
    Does it really make a difference?

    Current Works:
    ---Horror Game






    Special thanks to drgnforce9 for my sig picture

    Quote Originally Posted by m_t_h View Post

    CAflames is one epic coder.

    Rep and thanks him.. or you're perma banned.

  12. #10
    mmbob's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    ja
    Posts
    655
    Reputation
    70
    Thanks
    1,156
    My Mood
    Bitchy
    Quote Originally Posted by CAFlames View Post


    Does it really make a difference?
    Umm... yes. A std::string can't fit in an argument, so the compiler actually passes a pointer to the std::string. PTC wants a pointer to a char array, not a string.

    @CAFlames

  13. #11
    yodaliketaco's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    winsock.dll
    Posts
    646
    Reputation
    45
    Thanks
    511
    My Mood
    Tired
    Quote Originally Posted by mmbob View Post

    Fixed. That's why people use C strings.
    Well, it still crashes. Thanks for the help though. I will use this function as a scanner and see if that portion of the hack is working.

  14. #12
    mmbob's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    ja
    Posts
    655
    Reputation
    70
    Thanks
    1,156
    My Mood
    Bitchy
    Quote Originally Posted by yodaliketaco View Post
    Well, it still crashes. Thanks for the help though. I will use this function as a scanner and see if that portion of the hack is working.
    You could show a message box with the value of PTCAddy in it to make sure your scanner is working correctly.

  15. #13
    yodaliketaco's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    winsock.dll
    Posts
    646
    Reputation
    45
    Thanks
    511
    My Mood
    Tired
    Now that I'm using the function in a logger it seems to be crashing combat arms. I'm not sure where the problem is yet; I will look again tomorrow. If anyone looks at/implements the function, please let me know your results.

  16. #14
    topblast's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Far from around you Programmer: C++ | VB | C# | JAVA
    Posts
    3,607
    Reputation
    149
    Thanks
    4,922
    My Mood
    Cool
    Quote Originally Posted by CAFlames View Post
    Don't really have time to look at it, but good job.
    OMFG, whos the bigshot now?
    I just like programming, that is all.

    Current Stuff:

    • GPU Programmer (Cuda)
    • Client/Server (Cloud Server)
    • Mobile App Development

  17. The Following User Says Thank You to topblast For This Useful Post:

    ~Stephen (08-03-2011)

  18. #15
    blauespony's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    2
    Posts
    3
    Reputation
    10
    Thanks
    0
    My Mood
    Hot
    Quote Originally Posted by CAFlames View Post
    Don't really have time to look at it, but good job.
    If you didn't even look at the thread, why would you come in here and post. You don't have time to look at the code but you have time to raise your post count with spam, huh?

    What were you thinking when you clicked the post button...

Page 1 of 2 12 LastLast

Similar Threads

  1. finding and hooking an unknown function
    By JonnyD in forum General Game Hacking
    Replies: 1
    Last Post: 08-26-2010, 07:51 AM
  2. Replies: 8
    Last Post: 07-09-2007, 04:15 PM
  3. Replies: 37
    Last Post: 06-20-2006, 05: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, 05:39 PM
  5. Where do i find WPE Pro?
    By Rileyman1211 in forum WarRock - International Hacks
    Replies: 1
    Last Post: 01-16-2006, 10:52 AM