Given the sample code below:

#include <iostream> 

struct Data {
    int a;
    int b;
    int c;

int main() {
    Data *d = new Data;
    d->a = 1337;
    d->b = 1338;
    d->c = 1339;

    std::cout << d << std::endl;

    return 0;

Printing out the address of the pointer d is never the same (which seems logical). But the pointer that points to the base of d is also never the same.

Is there a way to find a static address that is always the same and points to the base of d? Or do I need to do this with a signature scan?

The main purpose is to always have a pointer to the base of d, without disassembling it when I restarting the program.

  • Is the addition "on Mac OS" in your title and tags relevant? The observed behavior is common for almost all operating systems.
    – Jongware
    Commented Dec 28, 2017 at 14:05
  • "Is there a way to find a static address ..." when live debugging? (I guess so; but maybe you might want to add the procedure you are using.)
    – Jongware
    Commented Dec 28, 2017 at 14:07
  • 1
    why is the first observation "logical" but the other isn't?
    – Igor Skochinsky
    Commented Dec 28, 2017 at 23:15

1 Answer 1


By declaring d inside main() it is a local scope variable, which exists on the stack and is therefore dynamic.

If you declare this pointer outside of main, it will be a global variable and it will have the same address every time, as long as there is know memory randomization provided as security measure of the OS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.