Skip to content

Instantly share code, notes, and snippets.

@p4nd4sec
p4nd4sec / dll.rs
Last active September 7, 2023 03:20
Template DLL rust
//cargo.toml
//[dependencies]
//winapi = { version = "0.3.9", features = ["minwindef","winuser"] }
//[lib]
//crate-type = ["cdylib"]
//lib.rs
#![cfg(windows)]
use std::ptr::null_mut;
use std::ffi::c_void;
use std::ptr;
type Error = u32;
type FnMessageBox = extern "stdcall" fn(hWnd: *const c_void, lpText: *const u16, lpCaption: *const u16, uType: u32) -> i32;
#[link(name = "kernel32")]
#[no_mangle]
extern "stdcall" {
fn GetLastError() -> Error;
//Ref https://gist.github.com/jimmychu0807/9a89355e642afad0d2aeda52e6ad2424
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();