Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliases for exported-functions and variables #9

Closed
3F opened this issue Dec 28, 2016 · 1 comment
Closed

Aliases for exported-functions and variables #9

3F opened this issue Dec 28, 2016 · 1 comment
Milestone

Comments

@3F
Copy link
Owner

3F commented Dec 28, 2016

hmm, just thought that is a good additional variant for: Undecorate functions from C++ compilers #3

Moreover, it will be useful for any other cases like for DllImport

[PrefixL]procName -> [PrefixR]alias1
                  -> [PrefixR]alias2

where PrefixL/R it's a main IProvider.Prefix if used
etc.

TODO

@3F
Copy link
Owner Author

3F commented Jan 19, 2017

I implemented the following:

  • Example: bool net::r_eg::Conari::UnLib::API::getD_True(void)
    • MSVC compiler C++ linkage: ?getD_True@API@UnLib@Conari@r_eg@net@@YA_NXZ
using(var l = new ConariL(...))
{
    l.Aliases["getD_True"]  = "?getD_True@API@UnLib@Conari@r_eg@net@@YA_NXZ";
    l.Aliases["getFlag"]    = l.Aliases["getD_True"]; // getFlag -> getD_True -> ...

    // ...
    
    l.DLR.getD_True<bool>();
    l.DLR.getFlag<bool>();
l.Aliases["HelloWorld"] = new ProcAlias("?HelloWorld@API@UnLib@Conari@r_eg@net@@YAPBDXZ");

l.DLR.HelloWorld<CharPtr>(); // "Hello World !"

Even for simple linkage, it easy as:

l.Aliases["Flag"] = l.Aliases["getFlag"] = l.Aliases["xFunc"]; //Flag() -> getFlag() -> xFunc()->...
l.DLR.getFlag<bool>();

l.Aliases["a"] = l.Aliases["b"] = l.Aliases["c"] = l.Aliases["d"];

the PrefixL/R features will be considered later via IAliasCfg:

public interface IAliasCfg
{
    //TODO: PrefixL/R, the rules of mangling, ...
}

upd.:

l.Aliases["gmn"] = new ProcAlias(
    "GetMagicNum",
    new AliasCfg() { NoPrefixR = true } // false by default
);

@3F 3F added this to the v1.3 milestone Jan 19, 2017
3F added a commit that referenced this issue Jan 23, 2017
…aviour with prefixes /part of #9

* +NoPrefixR - to avoid prefix for right operand if it's defined:
```
l.Aliases["gmn"] = new ProcAlias(
    "GetMagicNum",
    new AliasCfg() { NoPrefixR = true } // false by default
);
```
3F added a commit that referenced this issue Jan 27, 2017
    NEW: Improved speed >80% (DLR) & >90% (Lambda)
         `*` results for regXwild x64 (Unicode) via snet tester - https://github.com/3F/regXwild

    NEW: Improved DLR. Automatic detection for ByRef types & null-values for any reference-types that pushed with out/ref modifier.
         * +UseCallingContext - To use information about types from CallingContext if it's possible.
         * +UseByRef - To use ByRef& (reference-types) for all sent types.

    NEW: Added `NullType<T>` as optional way for work with reference-types. And for other purpose to store additional information about basic type for any null values.
    NEW: Added IProvider.NewProcAddress event - When handling new non-zero ProcAddress.
    NEW: Started support of Exported-Variables via IExVar & DLR - Issue #7
            ```
            l.ExVar.DLR.ADDR_SPEC; // 0x00001CE8
            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 !
            ```

    NEW: Implemented aliases for Exported-Functions and Variables - Issue #9
            ```
            l.Aliases["Flag"] = l.Aliases["getFlag"] = l.Aliases["xFunc"]; //Flag() -> getFlag() -> xFunc()->...
            l.DLR.getFlag<bool>();
            ```
            ```
            l.Aliases["gmn"] = new ProcAlias(
                "GetMagicNum",
                new AliasCfg() { NoPrefixR = true } // false by default
            );
            ```

    NEW: Native.Core improvements - Extensions & new `t` signatures for node (raw alignments via size and managed types)
         +`t(Type type, string name = null)`
         +`t(Type[] types, params string[] names)`
         +`t(int size, string name = null)`

    NEW: Aliases for 'empty' types:
         +`Action bindFunc(string lpProcName);`
         +`Action bind(string func);`

    NEW: New group of binding via regular arguments:
         +`Method bindFunc(string lpProcName, Type ret, params Type[] args);`
         +`Method<T, object> bindFunc<T>(string lpProcName, Type ret, params Type[] args);`
         +`Method bind(string func, Type ret, params Type[] args);`
         +`Method<T, object> bind<T>(string func, Type ret, params Type[] args);`

    FIXED: Fixed possible crashes - 'A heap has been corrupted' when use of shared pointer between several UnmanagedStructure.
    CHANGED: ILoader: minor incompatible changes for PE32/PE32+ features.
             * New `IPE PE` property for complex work with PE-file.
             * The `ExportFunctionNames` property has been removed as obsolete. Use same `PE.ExportedProcNamesArray`

    CHANGED: IProvider minor incompatible changes `funcName()` -> `procName()`
             `string funcName(string name);` has been renamed to `string procName(string name);`
              - as a common method for getting full lpProcName with main prefix etc.

    CHANGED: `TDyn IBinder.bind(MethodInfo mi, bool prefix = false);` removed as a deprecated, because for this can be a lot of misunderstandings.
              If you need something, use like: `prefix ? l.procName(mi.Name) : mi.Name` etc. for any available methods with MethodInfo.

    CHANGED: Added User object (+`user`) for Native.Core.Field. To store any additional information that's related for specific field.
@3F 3F closed this as completed Jan 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant