|
You last visited: Today at 22:02
Advertisement
c++ ASM Problem
Discussion on c++ ASM Problem within the C/C++ forum part of the Coders Den category.
07/25/2012, 23:37
|
#1
|
elite*gold: 24
Join Date: Feb 2012
Posts: 1,173
Received Thanks: 3,113
|
c++ ASM Problem
hey guys i was trying to add my ASM into c++ it went good but when i add
Quote:
it give me an err while building
Quote:
|
error C2415: improper operand type
|
anyway here is my code
Code:
void func()
{
_asm
{
push ebx
jns 0x01061F5F
popad
jb 0x01061F69
push 0x0073746F
add [0x34532F73],ah
jmp func_ret_addy
}
}
AnyIdea
|
|
|
07/26/2012, 00:17
|
#2
|
elite*gold: 31
Join Date: Oct 2011
Posts: 2,276
Received Thanks: 2,029
|
I can't Asm, but maybe it goes like this:
Code:
void func()
{
DWORD Adress = 0x34532F73;
_asm
{
push ebx
jns 0x01061F5F
popad
jb 0x01061F69
push 0x0073746F
add [Adress],ah
jmp func_ret_addy
}
}
Greet's, BuRn3R!
|
|
|
07/26/2012, 00:37
|
#3
|
elite*gold: 24
Join Date: Feb 2012
Posts: 1,173
Received Thanks: 3,113
|
@BuRn3R
thx for helping
now a new error XD
Quote:
|
error C2443: operand size conflict
|
i guess the err comes from the addy since if u change the addy all works fine
|
|
|
07/26/2012, 15:17
|
#4
|
elite*gold: 0
Join Date: Jul 2010
Posts: 388
Received Thanks: 196
|
Quote:
Originally Posted by Darsh2012
@BuRn3R
thx for helping
now a new error XD
i guess the err comes from the addy since if u change the addy all works fine
|
Code:
mov eax, 0x34532F73
add dword ptr [eax] ,ah
|
|
|
07/26/2012, 16:04
|
#5
|
elite*gold: 1
Join Date: Feb 2009
Posts: 6,378
Received Thanks: 7,996
|
Quote:
Originally Posted by SmackJew
Code:
mov eax, 0x34532F73
add dword ptr [eax] ,ah
|
Bad idea - ah is an 8-byte part of eax, so the size specifier has to be byte - your code would just lead to another size conflict. Also, the first instruction would overwrite the register's original value, so the value at 0x34532F73 were increased by 0x2F (what's obviously not OP's aim).
An additional register usage is not required, the following syntax is perfectly valid:
Code:
add byte ptr ds:[0x34532F73], ah
Edit:
My code implies that the target value at 0x34532F73 is of BYTE type. If that's not the case, you'll have to do something similar to this for a DWORD typed value:
Code:
movzx eax, ah
add dword ptr ds:[0x34532F73], eax
Or something like this for a word value:
Code:
movzx ax, ah
add word ptr ds:[0x34532F73], ax
|
|
|
07/26/2012, 20:16
|
#6
|
elite*gold: 24
Join Date: Feb 2012
Posts: 1,173
Received Thanks: 3,113
|
Quote:
Originally Posted by Ende!
Bad idea - ah is an 8-byte part of eax, so the size specifier has to be byte - your code would just lead to another size conflict. Also, the first instruction would overwrite the register's original value, so the value at 0x34532F73 were increased by 0x2F (what's obviously not OP's aim).
An additional register usage is not required, the following syntax is perfectly valid:
Code:
add byte ptr ds:[0x34532F73], ah
Edit:
My code implies that the target value at 0x34532F73 is of BYTE type. If that's not the case, you'll have to do something similar to this for a DWORD typed value:
Code:
movzx eax, ah
add dword ptr ds:[0x34532F73], eax
Or something like this for a word value:
Code:
movzx ax, ah
add word ptr ds:[0x34532F73], ax
|
thx Ende for ur help
Problem Solved #CloseRequest
|
|
|
07/26/2012, 23:17
|
#7
|
elite*gold: 0
Join Date: Jul 2010
Posts: 388
Received Thanks: 196
|
Quote:
Originally Posted by Ende!
Bad idea - ah is an 8-byte part of eax, so the size specifier has to be byte - your code would just lead to another size conflict. Also, the first instruction would overwrite the register's original value, so the value at 0x34532F73 were increased by 0x2F (what's obviously not OP's aim).
|
You're right. I have barely typed or read a shred of ASM in years, I shouldn't be posting. Too much Java.
|
|
|
07/27/2012, 08:52
|
#8
|
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,902
Received Thanks: 25,407
|
|
|
|
All times are GMT +1. The time now is 22:02.
|
|