-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Raleigh Littles
authored and
Raleigh Littles
committed
Nov 17, 2024
1 parent
7588b32
commit e7409c6
Showing
6 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* File: deviceinfo_constants.rs | ||
* | ||
* See: http://www.ipodlinux.org/ITunesDB/#DeviceInfo_File | ||
*/ | ||
|
||
pub const DEVICEINFO_FILE_SIZE: usize = 1536; // 0x600 | ||
pub const DEVICEINFO_STRING_LENGTH: usize = 510; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
use crate::constants::deviceinfo_constants; | ||
use crate::helpers::helpers; | ||
|
||
pub fn parse_device_info_file(deviceinfo_file_as_bytes: Vec<u8>) { | ||
|
||
if deviceinfo_file_as_bytes.len() != deviceinfo_constants::DEVICEINFO_FILE_SIZE { | ||
panic!("Invalid DeviceInfo file size! Expected: {} | Got: {}", deviceinfo_constants::DEVICEINFO_FILE_SIZE, deviceinfo_file_as_bytes.len()); | ||
} | ||
|
||
let ipod_name_length_raw = &deviceinfo_file_as_bytes[0..2]; | ||
|
||
let ipod_name_length = helpers::build_le_u16_from_bytes(ipod_name_length_raw) as usize; | ||
|
||
// The strings are formatted using UTF-16 so this byte value must be a multiple of 2 | ||
if ipod_name_length % 2 != 0 { | ||
panic!("Invalid iPod Name Length! Expected multiple of 2 | Got: {}", ipod_name_length); | ||
} | ||
|
||
println!("iPod Name Length: {}", ipod_name_length); | ||
|
||
// factor of 2 to account for UTF-16 encoding (2 bytes per character), | ||
// and the +2 to account for the length bytes | ||
let ipod_name_raw_bytes = &deviceinfo_file_as_bytes[2 .. (ipod_name_length * 2 + 2)]; | ||
|
||
println!("iPod Name: {:?}", String::from_utf16(&helpers::return_utf16_from_utf8(ipod_name_raw_bytes)).unwrap()); | ||
|
||
|
||
} |
Binary file not shown.