Skip to content

Commit 4fc4605

Browse files
committed
Process: fix imports of frida namespaced glib functions
1 parent 34464d5 commit 4fc4605

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

frida-gum/src/process.rs

+24
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,21 @@ use {
1919
use alloc::{string::String, string::ToString, vec::Vec};
2020
use cstr_core::CString;
2121

22+
#[cfg(target_os = "linux")]
2223
extern "C" {
2324
pub fn _frida_g_get_home_dir() -> *const c_char;
2425
pub fn _frida_g_get_current_dir() -> *const c_char;
2526
pub fn _frida_g_get_tmp_dir() -> *const c_char;
2627
}
2728

29+
#[cfg(not(target_os = "linux"))]
30+
extern "C" {
31+
pub fn _g_get_home_dir() -> *const c_char;
32+
pub fn _g_get_current_dir() -> *const c_char;
33+
pub fn _g_get_tmp_dir() -> *const c_char;
34+
}
35+
36+
2837
#[derive(Clone, FromPrimitive, Debug)]
2938
#[repr(u32)]
3039
pub enum CodeSigningPolicy {
@@ -121,27 +130,42 @@ impl<'a> Process<'a> {
121130
/// Returns a string specifying the filesystem path to the current working directory
122131
pub fn current_dir(&self) -> String {
123132
unsafe {
133+
#[cfg(target_os = "linux")]
124134
CStr::from_ptr(_frida_g_get_current_dir())
125135
.to_string_lossy()
126136
.to_string()
137+
#[cfg(not(target_os = "linux"))]
138+
CStr::from_ptr(_g_get_current_dir())
139+
.to_string_lossy()
140+
.to_string()
127141
}
128142
}
129143

130144
/// Returns a string specifying the filesystem path to the directory to use for temporary files
131145
pub fn tmp_dir(&self) -> String {
132146
unsafe {
147+
#[cfg(target_os = "linux")]
133148
CStr::from_ptr(_frida_g_get_tmp_dir())
134149
.to_string_lossy()
135150
.to_string()
151+
#[cfg(not(target_os = "linux"))]
152+
CStr::from_ptr(_g_get_tmp_dir())
153+
.to_string_lossy()
154+
.to_string()
136155
}
137156
}
138157

139158
/// Returns a string specifying the filesystem path to the current user’s home directory
140159
pub fn home_dir(&self) -> String {
141160
unsafe {
161+
#[cfg(target_os = "linux")]
142162
CStr::from_ptr(_frida_g_get_home_dir())
143163
.to_string_lossy()
144164
.to_string()
165+
#[cfg(not(target_os = "linux"))]
166+
CStr::from_ptr(_g_get_home_dir())
167+
.to_string_lossy()
168+
.to_string()
145169
}
146170
}
147171

0 commit comments

Comments
 (0)