DecoderBack (08-03-2011)
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.
DecoderBack (08-03-2011)
Already looking at the code, i see some undefined stuff, might wanna look over it bruh.
lol gettin into the coding i see, modding get boring? :P
commando: You're probably the best non-coder coder I know LOL
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; }
Yes. Modding got boring a while ago, I'm more interested in game development.
Last edited by yodaliketaco; 07-25-2011 at 02:38 PM.
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
Just finished my hotkey base... the address finding function executes, but when I use the provided address with my PTC function:
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.Code:void __cdecl PTC(const std::string called) { if(!PTCaddy) { PTCaddy = (void*)searchAddy("ι????0xΜΜΜΜΜΜΜΜΜΜΜ‘????"); return; } __asm { push called call PTCaddy add esp, 0x4 } }
I'm waiting for the cryengine 3 sdk. I'm interesting in making an RTS.
Last edited by yodaliketaco; 07-26-2011 at 12:21 PM.
yodaliketaco (07-26-2011)
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.
~Stephen (08-03-2011)