简体   繁体   中英

Getting address of variable using baseaddress and offsets

I am trying to get the address of a global variable from a target program. I can get the baseaddress of the target program using PsGetProcessSectionBaseAddress.

Target Program Code:

#include <iostream>

MyType myObject;

int main(){
    ...
}

How do I get the offset of myObject (I can't figure how with offsetof because it requires a type for the variable to be inside of), and once I get the offset can I just add the offset to the baseaddress to get the address of the variable since it's global?

By offset, do you mean address of? Just use the address of operator & in that case. If you mean offset from base address it's just a basic subtraction of n = (addr - base_addr) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM