1. 4FipS.com
  2. Photos
  3. Videos
  4. Code
  5. Forums
  6. pfQuizzz
  7. About

4FipS.com Forums

Forums dedicated to the projects hosted at 4FipS.com

Skip to content

Exploring the Rust programming language

> About coding, hacking, photography, and such...

Exploring the Rust programming language

Postby FipS on Sun Sep 24, 2017 8:45 pm

I have finally found some time to learn more about the Rust programming language, which has been under my radar for a couple of years now, but I had no chance to get my hands dirty until recently. There's a great book to start with, called: The Rust Programming Language, which is very well written and quite approachable (demonstrating how vital the Rust comunity is). I now begin to feel that Rust is a serious contender to C++, almost as if Rust came into existence to fix all the C++'s mistakes and expand the benefits, which I guess was among other motivations actually the case.

Anyway, my fist Rust program is not quite a typical one. I was rather curious how to dynamically load a library and call an exported function (In my case, I'm invoking 'cosf', which is available in 'msvcr100.dll' on Windows). This is an essential tool a system hacker needs to posses :), so here it is:

Code: Select all

extern crate libloading;

use libloading::{Library, Symbol};

type CosFunc = fn(f32) -> f32;

fn main() {
    let dll = Library::new("msvcr100.dll").unwrap();
    unsafe {
        let func: Symbol<CosFunc> = dll.get(b"cosf").unwrap();
        println!("cos(0) = {}", func(0.0));

// output:
// cos(0) = 1

Some more useful resources:

User avatar
Site Admin
Posts: 146
Joined: Wed Nov 12, 2008 9:49 pm
Location: Prague

Exploring the Rust programming language



Return to 4FipS.com General Discussion & Blog

Who is online

Users browsing this forum: No registered users and 2 guests