3F / Conari

🧬 One-touch unmanaged memory, runtime dynamic use of the unmanaged native C/C++ in .NET world, related P/Invoke features, and …
MIT License
252 stars 28 forks source link

Support of exported variables / constants #7

Closed 3F closed 7 years ago

3F commented 7 years ago

https://github.com/3F/DllExport/issues/24

Something like:

LIBAPI DWORD  ADDR_SPEC = 0x00001CE8;
l.RVA.variables<UInt32>("ADDR_SPEC")
l.RVAvar.ADDR_SPEC
...

anyway, do not use l.DLR node

3F commented 7 years ago

I added variant through new IExVar (plans for v1.3):

l.ExVar.get<UInt32>("ADDR_SPEC"); // 0x00001CE8
l.ExVar.getField(typeof(UInt32).NativeSize(), "ADDR_SPEC"); // Native.Core.Field via raw size
l.Svc.native("lpProcName"); // Raw access via NativeData & Native.Core !

For old versions you can also use exported variables, but only via Provider or ConariL frontend + your custom wrapper:

class MyConari: ConariL
{
    public MyConari(string lib, string prefix = null)
        : base((Config)lib, prefix)
    { }
    // ... now you can get pointer via IProvider/IBinder and use NativeData, etc.
}
3F commented 7 years ago

+DLR:

((dynamic)l.ExVar).ADDR_SPEC
l.ExVar.DLR.ADDR_SPEC
l.ExVar.DLR.ADDR_SPEC<UInt32>()