[英]need to get offset of struct data member
我有一個對象的成員定義為:
struct statebuf
{
void* sp;
void* label;
};
在我的asm代碼中,我這樣做:
#define restorestate(SSB) \
__asm mov ebx, this \
__asm mov esp, [ebx]SSB.sp\
__asm jmp [ebx]SSB.label
#endif
我像函數一樣使用宏。 在“ mov ebx,this”之后,我需要為ebx添加偏移量以擊中正確的成員。 如何獲得SSB的偏移量?
解決方案是:
#define restorestate(SSB) \
__asm mov ebx, this \
__asm add ebx, [SSB] \
__asm mov esp, [ebx]SSB.sp\
__asm jmp [ebx]SSB.label
#endif
我從反復試驗中得到的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.