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 


Make an asm pointer to an array of byte buffer

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ulysse31
Master Cheater
Reputation: 2

Joined: 19 Mar 2015
Posts: 324
Location: Paris

PostPosted: Sat Sep 05, 2015 10:47 am    Post subject: Make an asm pointer to an array of byte buffer Reply with quote

Hi,

I am coding a c++ packet crafter project. I receive tcp data into a buffer of type char. I decrypt this data with inline assembly code.

I need to move the address of the first byte from the 128 byte buffer into eax.

I tried this :
Code:

char szReceivedFirstKey[128]="\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02";

int main()
{

_asm
{
   push eax
      xor eax,eax
   movzx eax, szReceivedFirstKey
//do stuff
pop eax
}

it doesn't work.
I also tried :
movzx eax, &szReceivedFirstKey
It does not compile.

I'd be very gratefull, I am sure there is a simple solution for this Sad


Edit :
This seems to do the job :
int y = (int)&szReceivedFirstKey;
_asm
{
mov eax,y
mov y,eax
}
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Sep 05, 2015 1:57 pm    Post subject: Reply with quote

Does something like this work?
Code:
int ptr = &szReceivedFirstKey;
_asm {
  mov eax,ptr
}

or does it need to be declared as something like this?
Code:
void *ptr = &szReceivedFirstKey;
Back to top
View user's profile Send private message
ulysse31
Master Cheater
Reputation: 2

Joined: 19 Mar 2015
Posts: 324
Location: Paris

PostPosted: Sat Sep 05, 2015 4:49 pm    Post subject: Reply with quote

Zanzer wrote:
Does something like this work?
Code:
int ptr = &szReceivedFirstKey;
_asm {
  mov eax,ptr
}

or does it need to be declared as something like this?
Code:
void *ptr = &szReceivedFirstKey;


First proposition won't compile.

Second proposition is valid and works, also neatter than my work around which also worked :
int y = (int)&szReceivedFirstKey;
_asm
{
mov eax,y
mov y,eax
}

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