-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_project.rs
More file actions
134 lines (128 loc) · 4.05 KB
/
parse_project.rs
File metadata and controls
134 lines (128 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//! Example showing how to parse a VB6 project file from raw bytes.
//! This example uses a hardcoded string, but in a real application,
//! you would typically read the bytes from a `.vbp` file on disk.
//!
use vb6parse::{
files::common::ObjectReference, files::project::ProjectReference, ProjectFile, SourceFile,
};
fn main() {
let input = r#"Type=Exe
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\Windows\System32\stdole2.tlb#OLE Automation
Object={00020430-0000-0000-C000-000000000046}#2.0#0; stdole2.tlb
Module=Module1; Module1.bas
Class=Class1; Class1.cls
Form=Form1.frm
Form=Form2.frm
UserControl=UserControl1.ctl
UserDocument=UserDocument1.uds
ExeName32="Project1.exe"
Command32=""
Path32=""
Name="Project1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
DebugStartupOption=0
NoControlUpgrade=0
ServerSupportFiles=0
VersionCompanyName="Company Name"
VersionFileDescription="File Description"
VersionLegalCopyright="Copyright"
VersionLegalTrademarks="Trademark"
VersionProductName="Product Name"
VersionComments="Comments"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
CondComp=""
ResFile32=""
IconForm=""
Startup="Form1"
HelpFile=""
Title="Project1"
[MS Transaction Server]
AutoRefresh=1
"#;
// Decode the source file from the byte array.
// The filename is provided for reference in error messages.
// In a real application, use the actual filename.
// Decode with replacement to handle any invalid characters gracefully.
let source_file = SourceFile::decode_with_replacement("Project1.vbp", input.as_bytes())
.expect("Unable to decode the sourcefile with replacements.");
// Parse the project file from the decoded source file.
let project = ProjectFile::parse(&source_file).unwrap_or_fail();
// Print out some information about the parsed project file.
println!("Project Name: {}", project.properties.name);
println!("Project Type: {:?}", project.project_type);
println!("Files in Project:");
for reference in project.references() {
match reference {
ProjectReference::Compiled {
uuid,
unknown1,
unknown2,
path,
description,
} => {
println!("Reference - Compiled: {uuid} {unknown1} {unknown2} {path} {description}");
}
ProjectReference::SubProject { path } => {
println!("Reference - SubProject: {path}",);
}
}
}
for object in project.objects() {
match object {
ObjectReference::Compiled {
uuid,
version,
unknown1,
file_name,
} => {
println!("Object Reference - Compiled: {uuid} {version} {unknown1} {file_name}");
}
ObjectReference::Project { path } => {
println!("Object Reference - Project: {path}");
}
}
}
for module in project.modules() {
println!("Module: {} (Path: {})", module.name, module.path);
}
for class in project.classes() {
println!("Class: {} (Path: {})", class.name, class.path);
}
for related_document_path in project.related_documents() {
println!("Related Document - Path: {related_document_path}");
}
for user_document_path in project.user_documents() {
println!("User Document - Path: {user_document_path}");
}
for form_path in project.forms() {
println!("Form - Path: {form_path}");
}
for user_control_path in project.user_controls() {
println!("User Control - Path: {user_control_path}");
}
for property_group in &project.other_properties {
println!("Property Group: {}", property_group.0);
for property in property_group.1 {
println!(" {} = {}", property.0, property.1);
}
}
}