From 93c8f4fe9cbb68066784df4b249b2fa08f889e3c Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Sat, 25 Feb 2023 13:45:20 +0100 Subject: [PATCH] fix(sdk): Add missing value in Package binary format After digging through the VT2 SDK `.exe`, I found that `.package` files (`stingray::ResourcePackageResource`) actually have more data than I originally knew about. Most notably, there is a 1 byte `flags` value that is written at the end of every package file. Depending on what value those flags have, more data could come after it, but in most cases, it's just that one byte, which I must have missed in the binary. Ref: #28. Ref: #36. --- lib/sdk/src/filetype/package.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/sdk/src/filetype/package.rs b/lib/sdk/src/filetype/package.rs index fc2e8f6..338cc8e 100644 --- a/lib/sdk/src/filetype/package.rs +++ b/lib/sdk/src/filetype/package.rs @@ -97,6 +97,7 @@ pub struct Package { _name: String, _root: PathBuf, inner: PackageType, + flags: u8, } impl Deref for Package { @@ -119,6 +120,7 @@ impl Package { _name: name, _root: root, inner: Default::default(), + flags: 1, } } @@ -179,6 +181,7 @@ impl Package { inner, _name: name, _root: root.to_path_buf(), + flags: 1, }; Ok(pkg) @@ -225,10 +228,19 @@ impl Package { .insert(PathBuf::from(path.display().to_string())); } + let flags = r.read_u8()?; + + if cfg!(debug_assertions) && flags != 1 { + tracing::warn!("Unexpected value for package flags: {:0x}", flags); + } else if (flags & 0xFE) >= 2 { + tracing::warn!("Resource Package has common packages. Ignoring."); + } + let pkg = Self { inner, _name: name, _root: PathBuf::new(), + flags, }; Ok(pkg) @@ -251,6 +263,8 @@ impl Package { } } + w.write_u8(self.flags)?; + Ok(w.into_inner()) } }