frida / frida-rust

Frida Rust bindings
Other
185 stars 52 forks source link

Doesn't compile on 32-bit x86 #63

Closed khang06 closed 1 year ago

khang06 commented 2 years ago
error[E0432]: unresolved import `crate::instruction_writer::TargetInstructionWriter`
 --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\stalker\transformer.rs:7:13
  |
7 | use crate::{instruction_writer::TargetInstructionWriter, CpuContext, Gum};
  |             ^^^^^^^^^^^^^^^^^^^^-----------------------
  |             |                   |
  |             |                   help: a similar name exists in the module: `InstructionWriter`
  |             no `TargetInstructionWriter` in `instruction_writer`

error[E0425]: cannot find value `writer` in this scope
   --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\stalker\transformer.rs:138:13
    |
138 |             writer
    |             ^^^^^^ not found in this scope

error[E0412]: cannot find type `TargetRegister` in this scope
  --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\instruction_writer.rs:41:14
   |
41 |     Register(TargetRegister),
   |              ^^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `TargetInstructionWriter` in this scope
    --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\instruction_writer.rs:1294:42
     |
420  | pub trait InstructionWriter {
     | --------------------------- similarly named trait `InstructionWriter` defined here
...
1294 |     fn new(input_code: u64, output: &mut TargetInstructionWriter) -> Self;
     |                                          ^^^^^^^^^^^^^^^^^^^^^^^ help: a trait with a similar name exists: `InstructionWriter`

error[E0308]: mismatched types
  --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\module_map.rs:53:23
   |
53 |     let end = start + (*range).size;
   |                       ^^^^^^^^^^^^^ expected `u64`, found `u32`

error[E0277]: cannot add `u32` to `u64`
  --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\module_map.rs:53:21
   |
53 |     let end = start + (*range).size;
   |                     ^ no implementation for `u64 + u32`
   |
   = help: the trait `Add<u32>` is not implemented for `u64`
   = help: the following other types implement trait `Add<Rhs>`:
             <&'a f32 as Add<Complex<f32>>>
             <&'a f32 as Add<f32>>
             <&'a f64 as Add<Complex<f64>>>
             <&'a f64 as Add<f64>>
             <&'a i128 as Add<BigInt>>
             <&'a i128 as Add<Complex<i128>>>
             <&'a i128 as Add<i128>>
             <&'a i16 as Add<BigInt>>
           and 176 others

error[E0308]: mismatched types
   --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\memory_range.rs:88:22
    |
88  |                 Some(callback),
    |                 ---- ^^^^^^^^ expected `u32`, found `u64`
    |                 |
    |                 arguments to this enum variant are incorrect
    |
    = note: expected fn pointer `unsafe extern "C" fn(_, u32, _) -> _`
                  found fn item `extern "C" fn(_, u64, _) -> _ {memory_range::MemoryRange::scan::callback}`
note: tuple variant defined here
   --> C:\Users\Khang\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\option.rs:526:5
    |
526 |     Some(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     ^^^^

error[E0308]: mismatched types
  --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\range_details.rs:57:18
   |
56 |     pub fn size(&self) -> u64 {
   |                           --- expected `u64` because of return type
57 |         unsafe { (*self.file_mapping).size }
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found `u32`
   |
help: you can convert a `u32` to a `u64`
   |
57 |         unsafe { (*self.file_mapping).size.into() }
   |                                           +++++++

error[E0308]: mismatched types
  --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\range_details.rs:73:23
   |
73 |     let end = start + (*range).size;
   |                       ^^^^^^^^^^^^^ expected `u64`, found `u32`

error[E0277]: cannot add `u32` to `u64`
  --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\range_details.rs:73:21
   |
73 |     let end = start + (*range).size;
   |                     ^ no implementation for `u64 + u32`
   |
   = help: the trait `Add<u32>` is not implemented for `u64`
   = help: the following other types implement trait `Add<Rhs>`:
             <&'a f32 as Add<Complex<f32>>>
             <&'a f32 as Add<f32>>
             <&'a f64 as Add<Complex<f64>>>
             <&'a f64 as Add<f64>>
             <&'a i128 as Add<BigInt>>
             <&'a i128 as Add<Complex<i128>>>
             <&'a i128 as Add<i128>>
             <&'a i16 as Add<BigInt>>
           and 176 others

Some errors have detailed explanations: E0277, E0308, E0412, E0425, E0432.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `frida-gum` due to 10 previous errors

Seems to be a combination of using #[cfg(target_arch = "x86_64")] and not using usize where applicable. Not sure if that's all that would be required for full 32-bit support, though.

meme commented 2 years ago

A PR for adding 32-bit x86 or just stubbing out the types that have do not have target_arch implemented would be appreciated.

meme commented 1 year ago

Done! Please let me know if you experience any issues.