| View previous topic :: View next topic |
| Author |
Message |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Tue Mar 25, 2008 10:42 pm Post subject: [C++] what is wrong with that script? |
|
|
| Code: |
#include "stdafx.h"
#include "windows.h"
LPVOID NEWMEM;
HWND hWnd;
DWORD FLAGADD = 0x0100346E;
DWORD FLAGADD2 = 0x01005194;
BOOL APIENTRY DllMain( HMODULE hModule, DWORD reason, LPVOID lpReserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
hWnd = FindWindow(NULL,L"MineSweeper");
if (hWnd == 0)
MessageBox(0,L"MineSweeper Isn't Running",L"Failed",MB_ICONEXCLAMATION | MB_OK);
else
{
MessageBox(0,L"MineSweeper Is Running",L"Succeeded",MB_ICONEXCLAMATION | MB_OK);
NEWMEM = VirtualAlloc(NULL,0x01004000,MEM_COMMIT, PAGE_EXECUTE_READWRITE);
_asm
{
FLAGADD:
jmp NEWMEM
nop
returnhere:
NEWMEM:
push eax
mov eax,0x14
mov [FLAGADD2],eax
pop eax
jmp returnhere
}
}
}
return TRUE;
}
|
i think the problem is in the virtual allocation but i'm not sure :\
what i want is infinite mines at MineSweeper
and when i debug it there's no error
only when i inject it to the game nothing's happening (only the messageBox pops)
i'm kind of newbie at c++, started it only few days ago
_________________
Stylo |
|
| Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Tue Mar 25, 2008 11:15 pm Post subject: |
|
|
I don't think this code does what you think it does.
When you use the __asm command, it's not the same as ticking a script, it executes whatever it says.
From what I can gather, you're trying to code cave at 0100346E and have that set the addy 01005194 points at to 0x14.
I'm not up on VS ASM syntax, but I wouldn't've even guessed that would compiled.
I think would create a new label, not use 0100346E.
It would then jump to the NEWMEM label...which, again, I beleive is a new label, not using your variable.
Then, it would set the addy pointed to by the pointer to 0x14
then jump to return here and then go to NEWMEM again creating an infinite loop.
I'm not sure, but look at those addresses in the dissassembler and see if anything's changed.
I think your newmem is overwriting some stuff in minesweeper, so if you wrote to it you could mess something up.
If you want to write to that address, you don't have to go through all this.
BYTE * FLAGADD2 = 0x01005194;
FLAGGADD2 = 0x14;
Or something like that.
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed Mar 26, 2008 2:36 am Post subject: |
|
|
This isn't auto assembly, _asm writes an asm code at the current location of code.
Besides, you don't need this code:
| Code: | push eax
mov eax,0x14
mov [FLAGADD2],eax
pop eax |
You can modify FLAGDD2 directly:
mov [FLAGDD2],0x14
or use pointers. (instead of a code cave)
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Wed Mar 26, 2008 5:08 am Post subject: |
|
|
| Symbol wrote: | This isn't auto assembly, _asm writes an asm code at the current location of code.
Besides, you don't need this code:
| Code: | push eax
mov eax,0x14
mov [FLAGADD2],eax
pop eax |
You can modify FLAGDD2 directly:
mov [FLAGDD2],0x14
or use pointers. (instead of a code cave) |
On a second note, that wouldn't work either, unless all you want to do is make the value of FLAGADD2 0x14. ._.
_________________
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed Mar 26, 2008 6:33 am Post subject: |
|
|
all this point of this code for me is for precticing on inserting asm code at C++ project what i want is to make the value of mines stay at 20
can anyone fix it and post the code please? that'd be great :]
_________________
Stylo |
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Wed Mar 26, 2008 6:52 am Post subject: |
|
|
| 1qaz wrote: | all this point of this code for me is for precticing on inserting asm code at C++ project what i want is to make the value of mines stay at 20
can anyone fix it and post the code please? that'd be great :] |
| Code: |
void SetMines()
{
_asm
{
push eax
mov eax, 0x0040000 //put the address of the mines here
mov [eax],20
pop eax
}
}
|
Apparently, that's the way you have to do it (push/pop eax) for the C++ asm; there's always the C++ way out though:
| Code: |
void SetMines()
{
*(char*)0x00400000 = 20; //0x00400000 is of course your mine address
}
|
_________________
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed Mar 26, 2008 7:30 am Post subject: |
|
|
thx i got it work :]
about the second way i know it, it's just that i want to prectice on this whole _asm thing
again thx :>
_________________
Stylo |
|
| Back to top |
|
 |
|