c++ - C++ ASM 发布模式下推送偏移字符串问题
问题描述
我要调用的函数是一个类的函数:
void D3DBase::SetTexture(const std::string& path);
当我用 asm 块调用它时它可以工作,但是当我在发布模式下构建它时出现错误,然后当我从内存中检查它时,我意识到我需要将字符串偏移量移动 4 个字节并且当我尝试它时它工作.
我的问题是我为什么要这样做?这是什么原因?
std::string __tmpString = "";
void SetTexture(DWORD table, const std::string& str)
{
__tmpString = str;
__asm {
#ifdef NDEBUG
push offset __tmpString - 0x4
#else
push offset __tmpString
#endif
mov ecx, table
mov eax, 0x401FC0
call eax
}
}
解决方案
推荐阅读
- python - np.where() to eliminate data, where coordinates are too close to each other
- rxjs - Rxjs 延迟订阅Subject 完成后触发
- javascript - 如何通过传递参数从 .gs 文件中的方法调用“somename.html”?
- c# - c# - While loop coding theory, making a login and register sysem
- java - Java 比较器 Arrays.sort()
- android - Why can't we use vector images for icons in Android?
- python - 如何在 Pandas Dataframe 中的 groupby 之后使用分配函数
- java - Exception Handling in JS using Graal
- javascript - How to do the correct display of the template with ajax requests
- c# - Selecting TreeView values based on a many to many relationships in a razor pages model