Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ jobs:
fail-fast: false
matrix:
variants:
# - {os: ubuntu-22.04, config: release, compiler: gcc_64, aqt_os: linux, aqt_compiler: gcc_64}
- {os: ubuntu-24.04, config: release, compiler: gcc_64, aqt_os: linux, aqt_compiler: gcc_64}
# - {os: ubuntu-24.04-arm, config: release, compiler: linux_gcc_arm64, aqt_os: linux_arm64, aqt_compiler: linux_gcc_arm64}
# - {os: windows-2022, config: release, compiler: msvc2022_64, aqt_os: windows, aqt_compiler: win64_msvc2022_64}
- {os: windows-2025, config: release, compiler: msvc2022_64, aqt_os: windows, aqt_compiler: win64_msvc2022_64}
- {os: macos-14, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64}
# - {os: macos-15, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64}
- {os: ubuntu-24.04, config: release, compiler: gcc_64, aqt_os: linux, aqt_compiler: gcc_64}
- {os: ubuntu-24.04-arm, config: release, compiler: gcc_arm64, aqt_os: linux_arm64, aqt_compiler: gcc_arm64}
- {os: windows-2025, config: release, compiler: msvc2022_64, aqt_os: windows, aqt_compiler: win64_msvc2022_64}
# - {os: macos-15, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64}
# - {os: macos-14, config: release, compiler: clang_64, aqt_os: mac, aqt_compiler: clang_64}
runs-on: ${{ matrix.variants.os }}
steps:
- uses: actions/checkout@v5
Expand Down
18 changes: 15 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ fn get_qt_libs_path() -> String {
return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/macos/lib");

#[cfg(target_os = "linux")]
return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/gcc_64/lib");
{
#[cfg(target_arch = "aarch64")]
return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/gcc_arm64/lib");

#[cfg(target_arch = "x86_64")]
return format!("./{LIBDIE_BUILD_DIR}/{QT_VERSION}/gcc_64/lib");
}
}

fn qt_download() {
Expand All @@ -51,9 +57,15 @@ fn qt_download() {
.args(["-m", "aqt", "install-qt", "-O", LIBDIE_BUILD_DIR]);

#[cfg(target_os = "linux")]
cmd.args(["linux", "desktop", QT_VERSION]);
{
#[cfg(target_arch = "x86_64")]
cmd.args(["linux", "desktop", QT_VERSION]);

#[cfg(target_arch = "aarch64")]
cmd.args(["linux_arm64", "desktop", QT_VERSION, "linux_gcc_arm64"]);
}
#[cfg(target_os = "macos")]
cmd.args(["mac", "desktop", QT_VERSION, "clang_64"]);
cmd.args(["mac", "desktop", QT_VERSION]);
#[cfg(target_os = "windows")]
cmd.args(["windows", "desktop", QT_VERSION, "win64_msvc2022_64"]);

Expand Down
6 changes: 5 additions & 1 deletion libdie++/cmake/FindDieLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ set(QT_BUILD_VERSION "6.10.0")
if(WIN32)
set(QT_BUILD_COMPILER "msvc2022_64")
elseif(LINUX)
set(QT_BUILD_COMPILER "gcc_64")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
set(QT_BUILD_COMPILER "gcc_arm64")
else()
set(QT_BUILD_COMPILER "gcc_64")
endif()
elseif(APPLE)
set(QT_BUILD_COMPILER "macos")
else()
Expand Down
47 changes: 32 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ bitflags! {
#[link(name = "die", kind = "static")]
unsafe extern "C" {
// Definitions from die.h
fn DIE_FreeMemoryA(str: *const i8);
fn DIE_ScanFileA(fname: *const i8, flags: u32, db: *const i8) -> *const i8;
fn DIE_ScanFileExA(fname: *const i8, flags: u32) -> *mut i8;
fn DIE_ScanMemoryA(mem: *const u8, len: u32, flags: u32, db: *const i8) -> *mut i8;
fn DIE_ScanMemoryExA(mem: *const u8, len: u32, flags: u32) -> *mut i8;
fn DIE_LoadDatabaseA(fname: *const i8) -> i32;
fn DIE_FreeMemoryA(str: *const u8);
fn DIE_ScanFileA(fname: *const u8, flags: u32, db: *const u8) -> *const u8;
fn DIE_ScanFileExA(fname: *const u8, flags: u32) -> *const u8;
fn DIE_ScanMemoryA(mem: *const u8, len: u32, flags: u32, db: *const u8) -> *const u8;
fn DIE_ScanMemoryExA(mem: *const u8, len: u32, flags: u32) -> *const u8;
fn DIE_LoadDatabaseA(fname: *const u8) -> i32;
}

/// Scans a file at the specified path using the provided scan flags.
Expand Down Expand Up @@ -89,8 +89,10 @@ pub fn scan_file(fpath: &Path, flags: ScanFlags) -> Result<String> {
let fpath = CString::new(fpath.to_str().ok_or(Error::ConversionFailure)?)?;

unsafe {
let res = DIE_ScanFileExA(fpath.as_ptr(), flags.bits());
let out = CStr::from_ptr(res).to_str()?.to_string();
let res = DIE_ScanFileExA(fpath.as_bytes_with_nul().as_ptr(), flags.bits());
let out = CStr::from_ptr(res as *const std::os::raw::c_char)
.to_str()?
.to_string();
DIE_FreeMemoryA(res);
Ok(out)
}
Expand Down Expand Up @@ -133,9 +135,15 @@ pub fn scan_file_with_db(fpath: &Path, flags: ScanFlags, db_path: &Path) -> Resu
let db_path = CString::new(db_path.to_str().ok_or(Error::ConversionFailure)?)?;

unsafe {
let cstr = CStr::from_ptr(fpath.as_ptr() as *const i8);
let res = DIE_ScanFileA(cstr.as_ptr(), flags.bits(), db_path.as_ptr());
let str = CStr::from_ptr(res).to_str()?.to_string();
let cstr = CStr::from_ptr(fpath.as_ptr());
let res = DIE_ScanFileA(
cstr.to_bytes_with_nul().as_ptr(),
flags.bits(),
db_path.to_bytes_with_nul().as_ptr(),
);
let str = CStr::from_ptr(res as *const std::os::raw::c_char)
.to_str()?
.to_string();
DIE_FreeMemoryA(res);
Ok(str)
}
Expand Down Expand Up @@ -178,7 +186,9 @@ pub fn scan_memory(mem: &[u8], flags: ScanFlags) -> Result<String> {

unsafe {
let res = DIE_ScanMemoryExA(ptr, sz as u32, flags.bits());
let str = CStr::from_ptr(res).to_str()?.to_string();
let str = CStr::from_ptr(res as *const std::os::raw::c_char)
.to_str()?
.to_string();
DIE_FreeMemoryA(res);
Ok(str)
}
Expand Down Expand Up @@ -224,8 +234,15 @@ pub fn scan_memory_with_db(mem: &[u8], flags: ScanFlags, db_path: &Path) -> Resu
}

unsafe {
let res = DIE_ScanMemoryA(ptr, sz as u32, flags.bits(), db_path.as_ptr());
let str = CStr::from_ptr(res).to_str()?.to_string();
let res = DIE_ScanMemoryA(
ptr,
sz as u32,
flags.bits(),
db_path.as_bytes_with_nul().as_ptr(),
);
let str = CStr::from_ptr(res as *const std::os::raw::c_char)
.to_str()?
.to_string();
DIE_FreeMemoryA(res);
Ok(str)
}
Expand Down Expand Up @@ -263,7 +280,7 @@ pub fn scan_memory_with_db(mem: &[u8], flags: ScanFlags, db_path: &Path) -> Resu
pub fn load_database(fpath: &Path) -> Result<()> {
let fpath = CString::new(fpath.to_str().ok_or(Error::ConversionFailure)?)?;

let res = unsafe { DIE_LoadDatabaseA(fpath.as_ptr()) };
let res = unsafe { DIE_LoadDatabaseA(fpath.as_bytes_with_nul().as_ptr()) };
match res {
0 => Ok(()),
err => Err(Error::Ffi { error_code: err }),
Expand Down