 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
TheTime How do I cheat?
Reputation: 0
Joined: 22 May 2012 Posts: 2
|
Posted: Tue May 22, 2012 5:20 pm Post subject: [C++][AA][SOLVED] AA code to C++ |
|
|
Here is my AA code that works in game injected using CE :
| Code: | [ENABLE]
alloc(newmem,512)
label(returnhere)
007XXXX9:
jmp newmem
nop
returnhere:
newmem:
and dword ptr [esp+20],7XXXXXXX
fmul dword ptr [esp+20]
mov eax,[eax]
jmp returnhere
[DISABLE]
dealloc(newmem)
007XXXX9:
fmul dword ptr [esp+20]
mov eax,[eax] |
I have converted this code in C++ to inject it via a dll, but my code when it's injected makes the game crash :
| Code: |
#define jmp(frm, to) (int)(((int)to - (int)frm) - 5);
DWORD Address = 0x007XXXX9, AddressRet = 0x007XXXXF; // Those are correct, checked via CE
char szAddressMem[5];
void __declspec(naked) __stdcall On()
{
_asm
{
and dword ptr [esp+0x20],0x7XXXXXXX
fmul dword ptr [esp+0x20]
mov eax,[eax]
jmp dword ptr [AddressRet]
}
}
void Jump(unsigned long ulAddress, void* Function, unsigned long ulNops)
{
*(unsigned char*)ulAddress = 0xE9;
*(unsigned long*)(ulAddress + 1) = jmp(ulAddress, Function);
memset((void*)(ulAddress + 5), 0x90, ulNops);
}
void _stdcall OnOff()
{
Jump(Address, On, 1);
} |
What I'm doing wrong ?
Last edited by TheTime on Wed May 23, 2012 2:48 am; edited 2 times in total |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25833 Location: The netherlands
|
Posted: Tue May 22, 2012 5:32 pm Post subject: |
|
|
perhaps ulAddress is readonly
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
TheTime How do I cheat?
Reputation: 0
Joined: 22 May 2012 Posts: 2
|
Posted: Wed May 23, 2012 2:34 am Post subject: |
|
|
| Dark Byte wrote: | | perhaps ulAddress is readonly |
You were right !
So I added method :
| Code: | void MakePageWritable(unsigned long ulAddress, unsigned long ulSize)
{
MEMORY_BASIC_INFORMATION* mbi = new MEMORY_BASIC_INFORMATION;
VirtualQuery((void*)ulAddress, mbi, ulSize);
if (mbi->Protect != PAGE_EXECUTE_READWRITE)
{
unsigned long* ulProtect = new unsigned long;
VirtualProtect((void*)ulAddress, ulSize, PAGE_EXECUTE_READWRITE, ulProtect);
delete ulProtect;
}
delete mbi;
} |
Then i called the h*ck like this :
| Code: |
void _stdcall OnOff()
{
MakePageWritable(Address,6);
Jump(Address, PatchBoostOn, 1);
} |
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Mon May 28, 2012 7:50 am Post subject: |
|
|
| TheTime wrote: | | Dark Byte wrote: | | perhaps ulAddress is readonly |
You were right !
So I added method :
| Code: | void MakePageWritable(unsigned long ulAddress, unsigned long ulSize)
{
MEMORY_BASIC_INFORMATION* mbi = new MEMORY_BASIC_INFORMATION;
VirtualQuery((void*)ulAddress, mbi, ulSize);
if (mbi->Protect != PAGE_EXECUTE_READWRITE)
{
unsigned long* ulProtect = new unsigned long;
VirtualProtect((void*)ulAddress, ulSize, PAGE_EXECUTE_READWRITE, ulProtect);
delete ulProtect;
}
delete mbi;
} |
Then i called the h*ck like this :
| Code: |
void _stdcall OnOff()
{
MakePageWritable(Address,6);
Jump(Address, PatchBoostOn, 1);
} |
|
Given that you are hacking, why care what the protection is unless you absolutely have to change it to something specific? Just force the change no matter what.
Also, there is no reason to allocate memory to call VirtualProtect.
_________________
- Retired. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|