diff --git a/src/pe/resource.rs b/src/pe/resource.rs index ba62351c..99535be0 100644 --- a/src/pe/resource.rs +++ b/src/pe/resource.rs @@ -628,7 +628,7 @@ impl<'a> Iterator for ResourceStringIterator<'a> { } /// Represents a resource string entry. -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialEq)] pub struct ResourceString<'a> { /// The length, in bytes, of this String structure. pub len: u16, @@ -1521,6 +1521,7 @@ mod tests { assert_eq!(it_vec.is_ok(), true); let it_vec = it_vec.unwrap(); + assert_eq!(it_vec[0].is_binary_data(), true); assert_eq!(it_vec[0].key_string(), VS_VERSION_INFO_KEY); assert_eq!( it_vec[0].value, @@ -1531,27 +1532,122 @@ mod tests { 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, 0x74, 0x00, 0x72, 0x00 ] ); + + assert_eq!(it_vec[1].r#type, 103); // Invalid, seems broken by RC (resource compiler) assert_eq!(it_vec[1].key_string(), "FileInfo"); + assert_eq!( + it_vec[1].value, + &[ + 0xb4, 0x02, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x34, 0x00, 0x30, 0x00, 0x39, 0x00, + 0x30, 0x00, 0x34, 0x00, 0x45, 0x00, 0x34, 0x00, 0x00, 0x00, 0x58, 0x00, 0x36, 0x00, + 0x00, 0x00, 0x43, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x70, 0x00, 0x61, 0x00, 0x6e, 0x00, + 0x79, 0x00, 0x4e, 0x00, 0x61, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x79, 0x00, 0x74, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, + 0x53, 0x00, 0x6f, 0x00, 0x66, 0x00, 0x74, 0x00, 0x77, 0x00, 0x61, 0x00, 0x72, 0x00, + 0x65, 0x00, 0x20, 0x00, 0x46, 0x00, 0x6f, 0x00, 0x75, 0x00, 0x6e, 0x00, 0x64, 0x00, + 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, + ] + ); + assert_eq!(it_vec[2].is_binary_data(), true); assert_eq!(it_vec[2].key_string(), "FileDescription"); assert_eq!(it_vec[2].value_string(), "Python 3.11.3 (64-bit)"); + assert_eq!( + it_vec[2].value, + &[ + 0x50, 0x00, 0x79, 0x00, 0x74, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, + 0x33, 0x00, 0x2e, 0x00, 0x31, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x33, 0x00, 0x20, 0x00, + 0x28, 0x00, 0x36, 0x00, 0x34, 0x00, 0x2d, 0x00, 0x62, 0x00, 0x69, 0x00, 0x74, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, + ] + ); + assert_eq!(it_vec[3].is_binary_data(), true); assert_eq!(it_vec[3].key_string(), "FileVersion"); assert_eq!(it_vec[3].value_string(), "3.11.3150.0"); + assert_eq!( + it_vec[3].value, + &[ + 0x33, 0x00, 0x2e, 0x00, 0x31, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x33, 0x00, 0x31, 0x00, + 0x35, 0x00, 0x30, 0x00, 0x2e, 0x00, 0x30, 0x00, 0x00, 0x00, + ] + ); + assert_eq!(it_vec[4].is_text_data(), true); assert_eq!(it_vec[4].key_string(), "InternalName"); assert_eq!(it_vec[4].value_string(), "setup"); + assert_eq!( + it_vec[4].value, + &[0x73, 0x00, 0x65, 0x00, 0x74, 0x00, 0x75, 0x00, 0x70, 0x00, 0x00, 0x00,] + ); + assert_eq!(it_vec[5].is_binary_data(), true); assert_eq!(it_vec[5].key_string(), "LegalCopyright"); assert_eq!( it_vec[5].value_string(), "Copyright (c) Python Software Foundation. All rights reserved." ); + assert_eq!( + it_vec[5].value, + &[ + 0x43, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x79, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, + 0x68, 0x00, 0x74, 0x00, 0x20, 0x00, 0x28, 0x00, 0x63, 0x00, 0x29, 0x00, 0x20, 0x00, + 0x50, 0x00, 0x79, 0x00, 0x74, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, + 0x53, 0x00, 0x6f, 0x00, 0x66, 0x00, 0x74, 0x00, 0x77, 0x00, 0x61, 0x00, 0x72, 0x00, + 0x65, 0x00, 0x20, 0x00, 0x46, 0x00, 0x6f, 0x00, 0x75, 0x00, 0x6e, 0x00, 0x64, 0x00, + 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x2e, 0x00, 0x20, 0x00, + 0x41, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x20, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, + 0x68, 0x00, 0x74, 0x00, 0x73, 0x00, 0x20, 0x00, 0x72, 0x00, 0x65, 0x00, 0x73, 0x00, + 0x65, 0x00, 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x64, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x00, 0x00, + ] + ); + assert_eq!(it_vec[6].is_binary_data(), true); assert_eq!(it_vec[6].key_string(), "OriginalFilename"); assert_eq!(it_vec[6].value_string(), "python-3.11.3-amd64.exe"); + assert_eq!( + it_vec[6].value, + &[ + 0x70, 0x00, 0x79, 0x00, 0x74, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x2d, 0x00, + 0x33, 0x00, 0x2e, 0x00, 0x31, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x33, 0x00, 0x2d, 0x00, + 0x61, 0x00, 0x6d, 0x00, 0x64, 0x00, 0x36, 0x00, 0x34, 0x00, 0x2e, 0x00, 0x65, 0x00, + 0x78, 0x00, 0x65, 0x00, 0x00, 0x00, + ] + ); + assert_eq!(it_vec[7].is_binary_data(), true); assert_eq!(it_vec[7].key_string(), "ProductName"); assert_eq!(it_vec[7].value_string(), "Python 3.11.3 (64-bit)"); + assert_eq!( + it_vec[7].value, + &[ + 0x50, 0x00, 0x79, 0x00, 0x74, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, + 0x33, 0x00, 0x2e, 0x00, 0x31, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x33, 0x00, 0x20, 0x00, + 0x28, 0x00, 0x36, 0x00, 0x34, 0x00, 0x2d, 0x00, 0x62, 0x00, 0x69, 0x00, 0x74, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, + ] + ); + + assert_eq!(it_vec[8].is_binary_data(), true); + assert_eq!(it_vec[8].key_string(), "ProductVersion"); + assert_eq!(it_vec[8].value_string(), "3.11.3150.0"); + assert_eq!( + it_vec[8].value, + &[ + 0x33, 0x00, 0x2e, 0x00, 0x31, 0x00, 0x31, 0x00, 0x2e, 0x00, 0x33, 0x00, 0x31, 0x00, + 0x35, 0x00, 0x30, 0x00, 0x2e, 0x00, 0x30, 0x00, 0x00, 0x00, + ] + ); + + assert_eq!(it_vec[9].is_binary_data(), true); + assert_eq!(it_vec[9].key_string(), "VarFileInfo"); + assert_eq!(it_vec[9].value, &[]); + + assert_eq!(it_vec[9].is_binary_data(), true); + assert_eq!(it_vec[10].key_string(), "Translation"); + assert_eq!(it_vec[10].value, &[0x09, 0x04, 0xe4, 0x04]); + + assert_eq!(it_vec.get(11), None); } }