Giter Site home page Giter Site logo

mod_loader's People

Contributors

lcdr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mod_loader's Issues

llvm_asm! removed from nightly.

Since llvm_asm! was removed from nightly, this can no longer be compiled on the nightly compiler.

I found that this forces you to keep a static mut FARPROC for each function you export, and the new asm!() block looks like this. Unfortunately, Intel syntax would not generate the correct assm with jmp [{}]. Even if I used an identifier.

pub static mut pGetdfDIJoystick: FARPROC = 0 as FARPROC;

#[naked]
#[no_mangle]
pub extern "system" fn GetdfDIJoystick() {
    unsafe {
        asm!(
        "jmpq  *{}(%rip)",
        sym pGetdfDIJoystick,
        options(noreturn, att_syntax),
        );
    }
}

I also found GetdfDIJoystick can be added to the list of exports, too.

and my init_dinput8() function looks like this

pub const MAX_PATH: usize = 260;

pub unsafe fn init_dinput8() {
    let buffer = [0u8; MAX_PATH + 1];
    let path_size = GetWindowsDirectoryA(buffer.as_ptr() as LPSTR, MAX_PATH as u32 + 1) as usize;
    let dir = &buffer[..path_size];
    let dinput = LoadLibraryA(
        format!(
            "{}\\System32\\dinput8.dll\0",
            std::str::from_utf8(dir).unwrap_or_default()
        )
            .as_ptr() as *const i8,
    );

    if dinput.is_null() {
        panic!("Could not find dinput8.dll.");
    }
    let module = GetModuleHandleA(0 as *const i8) as usize;

    pDirectInput8Create = GetProcAddress(dinput, b"DirectInput8Create\0".as_ptr() as *const i8);
    pDllCanUnloadNow = GetProcAddress(dinput, b"DllCanUnloadNow\0".as_ptr() as *const i8);
    pDllGetClassObject = GetProcAddress(dinput, b"DllGetClassObject\0".as_ptr() as *const i8);
    pDllRegisterServer = GetProcAddress(dinput, b"DllRegisterServer\0".as_ptr() as *const i8);
    pDllUnregisterServer = GetProcAddress(dinput, b"DllUnregisterServer\0".as_ptr() as *const i8);
    pGetdfDIJoystick = GetProcAddress(dinput, b"GetdfDIJoystick\0".as_ptr() as *const i8);
}

Hope this helps! If you want a proper update, but don't wanna do it, let me know and I will fork this and send a PR!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.