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++ inline asm
Goto page 1, 2, 3  Next
 
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: Mon Sep 15, 2008 11:11 am    Post subject: c++ inline asm Reply with quote

i started learn about inline asm a in C++ but every time i call the function that contains the assembly code my window crushes
here's the function:
Code:

void _declspec(naked) Hack()
{
   _asm
   {
   }
}


as u can see it has no assembly code.. exactly what i wanted to show u O_O
it crushes even though there's no code inside
help pl0x Crying or Very sad

_________________
Stylo
Back to top
View user's profile Send private message
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Mon Sep 15, 2008 2:22 pm    Post subject: Reply with quote

Try adding a return, it seems like you created a blank label.
Back to top
View user's profile Send private message
jackyyll
Expert Cheater
Reputation: 0

Joined: 28 Jan 2008
Posts: 143
Location: here

PostPosted: Mon Sep 15, 2008 2:32 pm    Post subject: Reply with quote

DoomsDay wrote:
Try adding a return, it seems like you created a blank label.


void's dont have returns.

@1qaz:

When you have a naked function, you have to add your own prologue and epilogue, can't remember off the top of my head what it's supposed to look like though.
Back to top
View user's profile Send private message AIM Address MSN Messenger
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Mon Sep 15, 2008 3:13 pm    Post subject: Reply with quote

jackyyll wrote:
DoomsDay wrote:
Try adding a return, it seems like you created a blank label.


void's dont have returns.

@1qaz:

When you have a naked function, you have to add your own prologue and epilogue, can't remember off the top of my head what it's supposed to look like though.
Void is a typecast for a value; it mean that the programmer doesn't care abiout the value.
As for what I was saying, you created an empty block of code which means that the compiler will place the generated label just above the next function.

I compiled the follwing code:
Code:
void _declspec(naked) Hack()
{
   __asm
   {
   }
}

int main(int argc, char* argv[])
{
   Hack();
   return 0;
}
And it was compiled to:
Code:
main      /$  55            PUSH EBP
00401171  |.  8BEC          MOV EBP,ESP
00401173  |.  E8 F8FFFFFF   CALL main
00401178  |.  33C0          XOR EAX,EAX
0040117A  |.  5D            POP EBP
0040117B  \.  C3            RETN
As I said, the function was compiled to an "empty" label, below it was the main function, which resulted with an endless call chain, which eventually leads to a stack overflow.

Note: you will need to return manually if you use a naked function
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Mon Sep 15, 2008 3:23 pm    Post subject: Reply with quote

so um yea that instantly returns ... and doesnt really crash...oh btw you compiler optimized your code for you and removed hack();

Try adding this to Hack();...
Code:

char *SomeText = "Hello";
__asm
{
  push 0
  push [SomeText]
  push 0
  push 0
  call MessageBox
}
Back to top
View user's profile Send private message MSN Messenger
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Mon Sep 15, 2008 8:59 pm    Post subject: Reply with quote

jackyyll wrote:
When you have a naked function, you have to add your own prologue and epilogue, can't remember off the top of my head what it's supposed to look like though.


Epilogue has a return. He meant an assembly return not a C return, although you could just do a return; statement (which is the same thing).

Standard prologue/epilogue is:

Code:

push ebp
mov ebp,esp
sub esp,8 ; optional, make room for local variables in advance
; ...
retn 8 ; same as add esp, 8; retn;


Although depending on the calling convention you are using (if not using naked) the caller may be responsible for cleaning the stack.

_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Mon Sep 15, 2008 9:31 pm    Post subject: Reply with quote

Code:
LEAVE
Clean up the Epilogue noggy.
_________________
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 Sep 16, 2008 4:52 am    Post subject: Reply with quote

:S :S :S you confused me with prologue / epilogue whatever it calls :S
all i try to do is "nop" the flags address at Minesweeper using inline asm
just for start :>

i removed the __declspec(naked) and left void Hack() now the window doesn't crush but nothing is happening
Code:

void Hack()
{
 __asm
 {
 mov dword ptr ds:[0x0100346E],0x90
 }
}

_________________
Stylo
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Tue Sep 16, 2008 4:58 am    Post subject: Reply with quote

I'm going to remind you that you have to attach to the process and use WPM to do something like that. If you want direct access to the memory you have to change your program so that its a DLL.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Zand
Master Cheater
Reputation: 0

Joined: 21 Jul 2006
Posts: 424

PostPosted: Tue Sep 16, 2008 6:57 am    Post subject: Reply with quote

When using naked functions, you need a return, in your case, a return; or RETN
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Sep 16, 2008 9:15 am    Post subject: Reply with quote

oib111 wrote:
I'm going to remind you that you have to attach to the process and use WPM to do something like that. If you want direct access to the memory you have to change your program so that its a DLL.


What about starting a remote thread?
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 Sep 16, 2008 9:17 am    Post subject: Reply with quote

why do i need to attach my window to the process?
i'm only writing to an address in the memory
the address is exist already in the memory so all i need to do is writing to it ?! :s

_________________
Stylo
Back to top
View user's profile Send private message
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Tue Sep 16, 2008 10:51 am    Post subject: Reply with quote

1qaz wrote:
:S :S :S you confused me with prologue / epilogue whatever it calls :S
all i try to do is "nop" the flags address at Minesweeper using inline asm
just for start :>

i removed the __declspec(naked) and left void Hack() now the window doesn't crush but nothing is happening
Code:

void Hack()
{
 __asm
 {
 mov dword ptr ds:[0x0100346E],0x90
 }
}

are you tryng to write
Code:
90 00 00 00
?
Try byte instead of dword.

_________________
Gone
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 Sep 16, 2008 10:54 am    Post subject: Reply with quote

oh i think i forgot to mention that i tried already byte ptr and dword ptr with 0x90 00 00 00 still not working
btw i attached the window to the process as u told me to (still don't know what it's good for) and it doesn't work too

_________________
Stylo
Back to top
View user's profile Send private message
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Tue Sep 16, 2008 11:32 am    Post subject: Reply with quote

sponge wrote:
Code:
LEAVE
Clean up the Epilogue noggy.


Hi, I'm dumb.

Code:
mov esp, ebp
pop ebp
ret


For some reason I never see leave used.

_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
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
Goto page 1, 2, 3  Next
Page 1 of 3

 
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