C++ ASM Inline如何使用布尔值?
假设我得到了这样的东西..
bool isPatched;
我还有一些其他的 GUI,我在其中设置了 isPatched= true;
和 isPatched= false;
, isPatched = !isPatched;< /code>
void __declspec( naked ) test(void) { //
__asm {
PUSHAD
PUSHFD
MOV EAX, isPatched
CMP EAX, 0
je noPatched
MOV EAX, DWORD PTR DS:[ESI+0x77C]
MOV John.oldA, EAX
MOV EAX, John.A
MOV DWORD PTR DS:[ESI+0x77C], EAX
JMP finish
noPatched:
PUSH EDX
MOV DWORD PTR DS:[ESI+0x77C], EDX
finish:
POPFD
POPAD
JMP gotoAddressBack
}
}
是否可以在内联汇编中使用 bool
运算符?
我认为它认为 isPatched 是一个标签..来自这个错误消息。 错误 C2094:标签“isPatched”未定义
Say I got something like this..
bool isPatched;
I have a few other GUI's where I set isPatched= true;
and isPatched= false;
, isPatched = !isPatched;
void __declspec( naked ) test(void) { //
__asm {
PUSHAD
PUSHFD
MOV EAX, isPatched
CMP EAX, 0
je noPatched
MOV EAX, DWORD PTR DS:[ESI+0x77C]
MOV John.oldA, EAX
MOV EAX, John.A
MOV DWORD PTR DS:[ESI+0x77C], EAX
JMP finish
noPatched:
PUSH EDX
MOV DWORD PTR DS:[ESI+0x77C], EDX
finish:
POPFD
POPAD
JMP gotoAddressBack
}
}
Is it possible to use bool
operator in inline assembly?
I think it thinks isPatched is a label.. from this error message.error C2094: label 'isPatched' was undefined
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要
TEST
或CMP
。在这种情况下,TEST
是最简单的:根据其他情况,您还可以使用
SUB
、SETcc
或MOVcc
问题是作用域之一,
isPatched
在 ASM 使用时不在作用域内,因此它假定它是一个DWORD
,然后无法找到内存标签(符号名称)在生成地址时为其指定。您还需要为bool
使用正确的操作数大小。MSVC 的肮脏小测试,
当
b
为true
时输出 1,当b
为false
时输出 0。You want to
TEST
orCMP
.TEST
is the easiest in this case:Depending on other cases you can also use
SUB
,SETcc
orMOVcc
Your issue is one of scoping,
isPatched
is not in scope when used by the ASM, so it assumes it to be aDWORD
, and then fails to find a memory label (the symbol name) for it when generating the addresses. You also need to use the correct operand size forbool
as well.A dirty litte test for MSVC
this outputs 1 when
b
istrue
, or 0 whenb
isfalse
.