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

Modules with static variables to resolve readable names to plaftorm specific symbols #5

Open
notnotmelon opened this issue Aug 12, 2024 · 0 comments

Comments

@notnotmelon
Copy link
Member

Currently you have to put the raw mangled name into the detour macro.
This is ugly and only works on windows.

We need a giant enum of nice function names into mangled names for both platforms.
We also need automated scripts to update the enum when factorio's version increases.

Here is a mockup:

#[cfg(target_os = "linux")]
mod linux {
    pub mod LuaSurface {
        pub const valid: &str = "_ZNK10LuaSurface5validEv";
    }

    pub mod LuaEntity {
        pub const valid: &str = "_ZNK9LuaEntity5validEv";

        #[deprecated(note = "LuaEntity::luaDamage is unknown on linux")]
        pub const luaDamage: () = ();
    }

    pub mod LuaPlayer {
        pub const valid: &str = "_ZNK9LuaPlayer5validEv";
    }

    pub mod LuaRCON {
        pub const getObjectName: &str = "_ZNK7LuaRCON13getObjectNameEv";
        pub const luaIndex: &str = "_ZN7LuaRCON8luaIndexEP9lua_State";
        pub const luaPrint: &str = "_ZN7LuaRCON8luaPrintEP9lua_State";
        pub const deconstructor: &str = "_ZN7LuaRCOND0Ev";
    }
}

#[cfg(target_os = "windows")]
mod windows {
    pub mod LuaSurface {
        pub const valid: () = ();
    }

    pub mod LuaEntity {
        pub const valid: () = ();
    }

    pub mod LuaPlayer {
        pub const valid: () = ();
    }

    pub mod LuaRCON {
        pub const getObjectName: () = ();
        pub const luaIndex: () = ();
        pub const luaPrint: () = ();
        pub const deconstructor: () = ();
    }
}
@fgardt fgardt changed the title Make a giant enum to resolve symbol names to pointer addresses that would exist in both operating systems Modules with static variables to resolve readable names to plaftorm specific symbols Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant