Well i got the code cave to work in c++, pretty easy. Its nice to see some asm in my naked function, so i can tell wtf is going on when i look at my code in the debugger. BTW thanks to hellinsect for some code in a old post, i used some of his code to implement the writing for the patch, wpm was not doing it for me. I like his style.
Code:
void SCMod::jmpPatch(void *pDest, void *pSrc)
{ // credits to hellinsect, i tried to make one from wpm but this is
// sweet, im not going to reinvent the wheel!
DWORD OldAccessRights = 0;
VirtualProtect(pSrc, 5, PAGE_EXECUTE_READWRITE, &OldAccessRights);
*(BYTE*)((DWORD)pSrc) = 0xE9;
*(DWORD*)((DWORD)pSrc+1) = (DWORD)pDest - (DWORD)pSrc - 5;
VirtualProtect(pSrc, 5, OldAccessRights, &OldAccessRights);
}
void SCMod::nopIt(void *pDest, int nops)
{ // just another implementation of the code above
DWORD OldAccessRights = 0;
VirtualProtect(pDest, nops, PAGE_EXECUTE_READWRITE, &OldAccessRights);
for(BYTE i = 0; i<nops; i++)
*(BYTE*)((DWORD)pDest + i) = 0x90;
VirtualProtect(pDest, nops, OldAccessRights, &OldAccessRights);
}
I made the code cave just give the killer 100 hp to test and it works pretty good. Now its just a matter of bringning everything together so that different types of things happen depending on what attacks what. But for the time being im fed up with it.
Code:
__declspec(naked) void codecave1(void)
{
__asm{
PUSHAD
ADD DWORD PTR DS:[ESI+9],64
POPAD
MOV EAX,EBX
MOV DWORD PTR DS:[EBX+8],0
JMP retpt
}
}
--UPDATE--
Well i dont want to double post so i am editing this. Everything is coming along nicely, that code cave is a nightmare though, it was hashed out, im making a much better one. Also i've gotten text to print out on the screen, almost it prints just gibberish, it will be finished soon.
Im thinking of making it so there is like a random time based upgrades and stuff to switch it up, like you might get better ground attack upgrade while the other team gets air attack upgrade and the other team gets def upgrade or something of that sort, it will last for like 2 minutes then "wear off".
Also im doing this all in c++ in a very modular way. Once i clean up my code it will be very useful to anyone who wants to mess with starcraft. It will have stuff like .codecave .bwpubprint and lots of other stuff that are basic to most hacks/mods.
I just got a new puter today (core2 duo) so i was setting that up with windows xp 64. But ill get back to this in a few days.