diff --git a/Cargo.lock b/Cargo.lock index 3c42fea..3bc70c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -267,7 +267,7 @@ dependencies = [ [[package]] name = "object" version = "0.36.0" -source = "git+https://github.com/nixcloud/object.git?rev=6b356b4133c27807d95bcab357057317cc86ae75#6b356b4133c27807d95bcab357057317cc86ae75" +source = "git+https://github.com/nixcloud/object.git?branch=fixPath-0.1.0#03ff5929c39fde8d0ded29e00767dc834438ec92" dependencies = [ "crc32fast", "flate2", diff --git a/Cargo.toml b/Cargo.toml index bbd030d..3f8137b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,5 +16,5 @@ once_cell = "1.19.0" features = ["write", "xcoff", "read", "all"] #path = "object" git = "https://github.com/nixcloud/object.git" -#branch = "fixPath" -rev = "6b356b4133c27807d95bcab357057317cc86ae75" \ No newline at end of file +branch = "fixPath-0.1.0" +#rev = "6b356b4133c27807d95bcab357057317cc86ae75" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 906c351..02ec66f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -143,7 +143,7 @@ fn process_imports(in_file_path: &str, dll_change: Option) { Some(make_change_set) => { let _ = make_change_set.dll_changes.iter().for_each(|cs| { if cs.old_dll_name != cs.new_dll_name { - + match file.seek(SeekFrom::Start(cs.abs_address as u64)) { Ok(_) => {}, Err(e) => { println!("{e}")} @@ -155,7 +155,7 @@ fn process_imports(in_file_path: &str, dll_change: Option) { let c_str: &CStr = c_string.as_c_str(); // FIXME maybe we should reset all fiels to 0 which are not covered by a string file.write_all(c_str.to_bytes_with_nul()).expect("Error writing make_change_set to file"); - println!("original_dll_name: {}, old_dll_name: {}, new_dll_name: {}", + println!("original_dll_name: {}, old_dll_name: {}, new_dll_name: {}", cs.original_dll_name, cs.old_dll_name, cs.new_dll_name); if cs.original_dll_name == cs.new_dll_name { println!("UPDATE {} @ 0x{:0x}", cs.new_dll_name, @@ -174,7 +174,6 @@ fn process_imports(in_file_path: &str, dll_change: Option) { fn process_file(in_data: &[u8], dll_change: Option) -> Option { - let fix_path_data: FixPathData; let fix_path_section_info: FixPathSectionInfo; @@ -234,8 +233,8 @@ fn process_file(in_data: &[u8], dll_change: Option = vec![]; let delayed_import_table = in_data_directories.delay_load_import_table(in_data, &in_sections).unwrap().unwrap(); - // FIXME handle unwrap on files without delay imports let mut delayed_import_descriptor_iterator = delayed_import_table.descriptors().unwrap(); + // FIXME handle unwrap on files without delay imports while let Some(delayed_import) = delayed_import_descriptor_iterator.next().unwrap() { //println!("{:?}", import); let dll_name_address: u32 = delayed_import.dll_name_rva.get(LittleEndian); @@ -294,7 +293,6 @@ fn process_file(in_data: &[u8], dll_change: Option(in_data: &[u8], dll_change: Option, from: &String) -> Option { v.iter().position(|el| el == from) } - match try_find_in_vec(&fix_path_data.info.idata_entries, &change.from) { Some(i) => { let old_dll_name = fix_path_data.imports[i].dll_name.clone(); @@ -326,7 +321,6 @@ fn process_file(in_data: &[u8], dll_change: Option {} } - match try_find_in_vec(&fix_path_data.info.didata_entries, &change.from) { Some(i) => { let old_dll_name = fix_path_data.delayed_imports[i].dll_name.clone(); @@ -340,11 +334,9 @@ fn process_file(in_data: &[u8], dll_change: Option {} } - if make_change_set.dll_changes.len() > 0 { return Some(make_change_set); } - eprintln!("Can't find the DLL '{}' in the IMPORTS/DELAYED IMPORTS of PE file", change.from); process::exit(1); }