View previous topic :: View next topic |
Author |
Message |
ulysse31 Master Cheater
Reputation: 2
Joined: 19 Mar 2015 Posts: 324 Location: Paris
|
Posted: Sat Sep 05, 2015 10:47 am Post subject: Make an asm pointer to an array of byte buffer |
|
|
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
Edit :
This seems to do the job :
int y = (int)&szReceivedFirstKey;
_asm
{
mov eax,y
mov y,eax
}
|
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Sep 05, 2015 1:57 pm Post subject: |
|
|
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 |
|
 |
ulysse31 Master Cheater
Reputation: 2
Joined: 19 Mar 2015 Posts: 324 Location: Paris
|
Posted: Sat Sep 05, 2015 4:49 pm Post subject: |
|
|
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 |
|
 |
|