Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] what is wrong with that script?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue Mar 25, 2008 10:42 pm    Post subject: [C++] what is wrong with that script? Reply with quote

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
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Tue Mar 25, 2008 11:15 pm    Post subject: Reply with quote

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.

Code:
FLAGADD:

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
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue Mar 25, 2008 11:23 pm    Post subject: Reply with quote

ok i think i understand what you're trying to tell me
so how can i use the variables that stores the addresses in the __asm part?
and the virtualalloc function.. i dont think it's correct i want to create a new memory to my code, how can i do it Confused

_________________
Stylo
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Wed Mar 26, 2008 2:36 am    Post subject: Reply with quote

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
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Wed Mar 26, 2008 5:08 am    Post subject: Reply with quote

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. ._.

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Mar 26, 2008 6:33 am    Post subject: Reply with quote

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
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Wed Mar 26, 2008 6:52 am    Post subject: Reply with quote

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
}

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Mar 26, 2008 7:30 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites