How to get access to Voldemort / private thingies

Johan Engelen via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 17 12:49:18 PDT 2016


Hi all,
   Is there another way to get access to Voldemort class methods, 
or private class members, other than using "pragma(mangle, ...)" 
on user symbols?

Example code:

In library, and _should not_ be changed :
```
Object getObject() {
     class Vold : Object {
         int store;
         this(int i) {
            store = i;
         }
     }
     return new Vold(2);
}

class Thread
{
      private:
      static struct AAA
      {
           int i;
      }
     __gshared AAA*  sm_cbeg;
}
```

And then the code seeking access:
```
pragma(mangle, "mangled name of Vold's constructor")
     private extern(C) void defaultTraceInfoCtor(Object) @nogc;

struct A
{
     int i;
}
__gshared extern {
     pragma(mangle, "the mangled symbol name") A* sm_cbeg;
}
```

Go mad on the "code seeking access" :-) The problem is that the 
types of `defaultTraceInfoCtor` and `sm_cbeg` are incorrect. If I 
can get the types to match (internally in the compiler), I'm 
happy.

Thanks,
   Johan



More information about the Digitalmars-d-learn mailing list