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.
This commit is contained in:
Lucas Schwiderski 2023-02-25 13:45:20 +01:00
parent b9cd9ed5de
commit 93c8f4fe9c
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8

View file

@ -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())
}
}