scanner: Include other SWF header information in the scanner output.
This commit is contained in:
parent
c55bc96993
commit
37f084e3e0
|
@ -14,7 +14,6 @@ use ruffle_core::swf::{decompress_swf, parse_swf};
|
||||||
use ruffle_core::tag_utils::SwfMovie;
|
use ruffle_core::tag_utils::SwfMovie;
|
||||||
use ruffle_core::Player;
|
use ruffle_core::Player;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use swf::{FileAttributes, Tag};
|
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
@ -128,14 +127,22 @@ pub fn execute_report_main(execute_report_opt: ExecuteReportOpt) -> Result<(), s
|
||||||
match catch_unwind(|| parse_swf(&swf_buf)) {
|
match catch_unwind(|| parse_swf(&swf_buf)) {
|
||||||
Ok(swf) => match swf {
|
Ok(swf) => match swf {
|
||||||
Ok(swf) => {
|
Ok(swf) => {
|
||||||
let mut vm_type = Some(AvmType::Avm1);
|
let stage_size = swf.header.stage_size();
|
||||||
if let Some(Tag::FileAttributes(fa)) = swf.tags.first() {
|
let stage_width = (stage_size.x_max - stage_size.x_min).to_pixels();
|
||||||
if fa.contains(FileAttributes::IS_ACTION_SCRIPT_3) {
|
let stage_height = (stage_size.y_max - stage_size.y_min).to_pixels();
|
||||||
vm_type = Some(AvmType::Avm2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
file_result.vm_type = vm_type;
|
file_result.compression = Some(swf.header.compression().into());
|
||||||
|
file_result.version = Some(swf.header.version());
|
||||||
|
file_result.stage_size = Some(format!("{}x{}", stage_width, stage_height));
|
||||||
|
file_result.frame_rate = Some(swf.header.frame_rate().into());
|
||||||
|
file_result.num_frames = Some(swf.header.num_frames());
|
||||||
|
file_result.use_direct_blit = Some(swf.header.use_direct_blit());
|
||||||
|
file_result.use_gpu = Some(swf.header.use_gpu());
|
||||||
|
file_result.use_network_sandbox = Some(swf.header.use_network_sandbox());
|
||||||
|
file_result.vm_type = Some(match swf.header.is_action_script_3() {
|
||||||
|
true => AvmType::Avm2,
|
||||||
|
false => AvmType::Avm1,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
file_result.error = Some(format!("Parse error: {}", e.to_string()));
|
file_result.error = Some(format!("Parse error: {}", e.to_string()));
|
||||||
|
|
|
@ -14,6 +14,23 @@ pub enum AvmType {
|
||||||
Avm2,
|
Avm2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub enum Compression {
|
||||||
|
None,
|
||||||
|
Zlib,
|
||||||
|
Lzma,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<swf::Compression> for Compression {
|
||||||
|
fn from(sc: swf::Compression) -> Self {
|
||||||
|
match sc {
|
||||||
|
swf::Compression::None => Compression::None,
|
||||||
|
swf::Compression::Zlib => Compression::Zlib,
|
||||||
|
swf::Compression::Lzma => Compression::Lzma,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A particular step in the scanner process.
|
/// A particular step in the scanner process.
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub enum Step {
|
pub enum Step {
|
||||||
|
@ -58,6 +75,30 @@ pub struct FileResults {
|
||||||
/// Any errors encountered while testing.
|
/// Any errors encountered while testing.
|
||||||
pub error: Option<String>,
|
pub error: Option<String>,
|
||||||
|
|
||||||
|
/// The compression type this SWF uses.
|
||||||
|
pub compression: Option<Compression>,
|
||||||
|
|
||||||
|
/// The file format version of this SWF.
|
||||||
|
pub version: Option<u8>,
|
||||||
|
|
||||||
|
/// The stage size of this SWF.
|
||||||
|
pub stage_size: Option<String>,
|
||||||
|
|
||||||
|
/// The frame rate of this SWF.
|
||||||
|
pub frame_rate: Option<f32>,
|
||||||
|
|
||||||
|
/// The number of frames this SWF claims to contain.
|
||||||
|
pub num_frames: Option<u16>,
|
||||||
|
|
||||||
|
/// Whether or not the SWF requests hardware-accelerated presentation.
|
||||||
|
pub use_direct_blit: Option<bool>,
|
||||||
|
|
||||||
|
/// Whether or not the SWF requests hardware-accelerated compositing.
|
||||||
|
pub use_gpu: Option<bool>,
|
||||||
|
|
||||||
|
/// Whether or not the SWF requests network access when ran locally.
|
||||||
|
pub use_network_sandbox: Option<bool>,
|
||||||
|
|
||||||
/// The AVM type of the movie.
|
/// The AVM type of the movie.
|
||||||
pub vm_type: Option<AvmType>,
|
pub vm_type: Option<AvmType>,
|
||||||
}
|
}
|
||||||
|
@ -76,6 +117,14 @@ impl FileResults {
|
||||||
progress: Step::Start,
|
progress: Step::Start,
|
||||||
testing_time: 0,
|
testing_time: 0,
|
||||||
error: None,
|
error: None,
|
||||||
|
compression: None,
|
||||||
|
version: None,
|
||||||
|
stage_size: None,
|
||||||
|
frame_rate: None,
|
||||||
|
num_frames: None,
|
||||||
|
use_direct_blit: None,
|
||||||
|
use_gpu: None,
|
||||||
|
use_network_sandbox: None,
|
||||||
vm_type: None,
|
vm_type: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,14 @@ pub fn scan_main(opt: ScanOpt) -> Result<(), std::io::Error> {
|
||||||
"Progress",
|
"Progress",
|
||||||
"Test Duration",
|
"Test Duration",
|
||||||
"Error",
|
"Error",
|
||||||
|
"Compression",
|
||||||
|
"SWF Version",
|
||||||
|
"Stage Size",
|
||||||
|
"Frame Rate",
|
||||||
|
"Number of Frames",
|
||||||
|
"Direct Blit",
|
||||||
|
"GPU",
|
||||||
|
"Network Sandbox",
|
||||||
"AVM Version",
|
"AVM Version",
|
||||||
])?;
|
])?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue