├── .gitignore
├── .gitmodules
├── LICENSE
├── PRIExplorer
├── App.config
├── App.xaml
├── App.xaml.cs
├── Assets
│ ├── LICENSE.txt
│ ├── blue-document-attribute-s.png
│ ├── blue-document-attribute-x.png
│ ├── blue-document-binary.png
│ ├── blue-document-code.png
│ ├── blue-document-xaml.png
│ ├── blue-document.png
│ ├── document.png
│ ├── folder-horizontal.png
│ └── folder.png
├── Controls
│ ├── CheckerboardImage.xaml
│ └── CheckerboardImage.xaml.cs
├── PRIExplorer.csproj
├── Properties
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── ViewModels
│ ├── BinaryPreviewViewModel.cs
│ ├── CandidateViewModel.cs
│ ├── EntryViewModel.cs
│ ├── ImagePreviewViewModel.cs
│ ├── MainViewModel.cs
│ ├── PathNotFoundPreviewViewModel.cs
│ ├── RelayCommand.cs
│ ├── TextPreviewViewModel.cs
│ └── XbfPreviewViewModel.cs
├── Views
│ ├── BinaryPreviewPage.xaml
│ ├── BinaryPreviewPage.xaml.cs
│ ├── ImagePreviewPage.xaml
│ ├── ImagePreviewPage.xaml.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── PathNotFoundPreviewPage.xaml
│ ├── PathNotFoundPreviewPage.xaml.cs
│ ├── ScopeDetailPage.xaml
│ ├── ScopeDetailPage.xaml.cs
│ ├── TextPreviewPage.xaml
│ ├── TextPreviewPage.xaml.cs
│ ├── XbfPreviewPage.xaml
│ └── XbfPreviewPage.xaml.cs
└── app.manifest
├── Package Resource Index File Format.md
├── PriFormat
├── ByteSpan.cs
├── DataItemSection.cs
├── DecisionInfoSection.cs
├── ExtensionMethods.cs
├── HierarchicalSchemaSection.cs
├── PriDescriptorSection.cs
├── PriFile.cs
├── PriFormat.csproj
├── ReferencedFileSection.cs
├── ResourceMapSection.cs
├── ReverseMapSection.cs
├── Section.cs
├── SubStream.cs
├── TocEntry.cs
└── UnknownSection.cs
├── PriInfo
├── App.config
├── PriInfo.csproj
└── Program.cs
├── PriTools.sln
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # ASP.NET Scaffolding
66 | ScaffoldingReadMe.txt
67 |
68 | # StyleCop
69 | StyleCopReport.xml
70 |
71 | # Files built by Visual Studio
72 | *_i.c
73 | *_p.c
74 | *_h.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.iobj
79 | *.pch
80 | *.pdb
81 | *.ipdb
82 | *.pgc
83 | *.pgd
84 | *.rsp
85 | *.sbr
86 | *.tlb
87 | *.tli
88 | *.tlh
89 | *.tmp
90 | *.tmp_proj
91 | *_wpftmp.csproj
92 | *.log
93 | *.tlog
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.)
298 | *.vbp
299 |
300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project)
301 | *.dsw
302 | *.dsp
303 |
304 | # Visual Studio 6 technical files
305 | *.ncb
306 | *.aps
307 |
308 | # Visual Studio LightSwitch build output
309 | **/*.HTMLClient/GeneratedArtifacts
310 | **/*.DesktopClient/GeneratedArtifacts
311 | **/*.DesktopClient/ModelManifest.xml
312 | **/*.Server/GeneratedArtifacts
313 | **/*.Server/ModelManifest.xml
314 | _Pvt_Extensions
315 |
316 | # Paket dependency manager
317 | .paket/paket.exe
318 | paket-files/
319 |
320 | # FAKE - F# Make
321 | .fake/
322 |
323 | # CodeRush personal settings
324 | .cr/personal
325 |
326 | # Python Tools for Visual Studio (PTVS)
327 | __pycache__/
328 | *.pyc
329 |
330 | # Cake - Uncomment if you are using it
331 | # tools/**
332 | # !tools/packages.config
333 |
334 | # Tabs Studio
335 | *.tss
336 |
337 | # Telerik's JustMock configuration file
338 | *.jmconfig
339 |
340 | # BizTalk build output
341 | *.btp.cs
342 | *.btm.cs
343 | *.odx.cs
344 | *.xsd.cs
345 |
346 | # OpenCover UI analysis results
347 | OpenCover/
348 |
349 | # Azure Stream Analytics local run output
350 | ASALocalRun/
351 |
352 | # MSBuild Binary and Structured Log
353 | *.binlog
354 |
355 | # NVidia Nsight GPU debugger configuration file
356 | *.nvuser
357 |
358 | # MFractors (Xamarin productivity tool) working folder
359 | .mfractor/
360 |
361 | # Local History for Visual Studio
362 | .localhistory/
363 |
364 | # Visual Studio History (VSHistory) files
365 | .vshistory/
366 |
367 | # BeatPulse healthcheck temp database
368 | healthchecksdb
369 |
370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
371 | MigrationBackup/
372 |
373 | # Ionide (cross platform F# VS Code tools) working folder
374 | .ionide/
375 |
376 | # Fody - auto-generated XML schema
377 | FodyWeavers.xsd
378 |
379 | # VS Code files for those working on multiple tools
380 | .vscode/*
381 | !.vscode/settings.json
382 | !.vscode/tasks.json
383 | !.vscode/launch.json
384 | !.vscode/extensions.json
385 | *.code-workspace
386 |
387 | # Local History for Visual Studio Code
388 | .history/
389 |
390 | # Windows Installer files from build outputs
391 | *.cab
392 | *.msi
393 | *.msix
394 | *.msm
395 | *.msp
396 |
397 | # JetBrains Rider
398 | *.sln.iml
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "XbfAnalyzer"]
2 | path = XbfAnalyzer
3 | url = https://github.com/chausner/XbfAnalyzer.git
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2016 Christoph Hausner
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/PRIExplorer/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/PRIExplorer/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/PRIExplorer/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace PRIExplorer;
4 |
5 | ///
6 | /// Interaktionslogik für "App.xaml"
7 | ///
8 | public partial class App : Application
9 | {
10 | }
11 |
--------------------------------------------------------------------------------
/PRIExplorer/Assets/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Fugue Icons
2 |
3 | (C) 2013 Yusuke Kamiyamane. All rights reserved.
4 |
5 | These icons are licensed under a Creative Commons
6 | Attribution 3.0 License.
7 |
8 |
9 | If you can't or don't want to provide attribution, please
10 | purchase a royalty-free license.
11 |
12 |
13 | I'm unavailable for custom icon design work. But your
14 | suggestions are always welcome!
15 |
16 |
17 | ------------------------------------------------------------
18 |
19 | All logos and trademarks in some icons are property of their
20 | respective owners.
21 |
22 | ------------------------------------------------------------
23 |
24 | - geotag
25 |
26 | (C) Geotag Icon Project. All rights reserved.
27 |
28 |
29 | Geotag icon is licensed under a Creative Commons
30 | Attribution-Share Alike 3.0 License or LGPL.
31 |
32 |
33 |
34 | - language
35 |
36 | (C) Language Icon Project. All rights reserved.
37 |
38 |
39 | Language icon is licensed under a Creative Commons
40 | Attribution-Share Alike 3.0 License.
41 |
42 |
43 | - open-share
44 |
45 | (C) Open Share Icon Project. All rights reserved.
46 |
47 |
48 | Open Share icon is licensed under a Creative Commons
49 | Attribution-Share Alike 3.0 License.
50 |
51 |
52 | - opml
53 |
54 | (C) OPML Icon Project. All rights reserved.
55 |
56 |
57 | OPML icon is licensed under a Creative Commons
58 | Attribution-Share Alike 2.5 License.
59 |
60 |
61 | - share
62 |
63 | (C) Share Icon Project. All rights reserved.
64 |
65 |
66 | Share icon is licensed under a GPL or LGPL or BSD or
67 | Creative Commons Attribution 2.5 License.
68 |
69 |
70 |
71 |
72 |
73 | - xfn
74 |
75 | (C) Wolfgang Bartelme. All rights reserved.
76 |
77 |
78 | XFN icon is licensed under a Creative Commons
79 | Attribution-Share Alike 2.5 License.
80 |
--------------------------------------------------------------------------------
/PRIExplorer/Assets/blue-document-attribute-s.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chausner/PriTools/02ac5c4dc1f1c5a1dd545742fc1685c7edfd18c9/PRIExplorer/Assets/blue-document-attribute-s.png
--------------------------------------------------------------------------------
/PRIExplorer/Assets/blue-document-attribute-x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chausner/PriTools/02ac5c4dc1f1c5a1dd545742fc1685c7edfd18c9/PRIExplorer/Assets/blue-document-attribute-x.png
--------------------------------------------------------------------------------
/PRIExplorer/Assets/blue-document-binary.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chausner/PriTools/02ac5c4dc1f1c5a1dd545742fc1685c7edfd18c9/PRIExplorer/Assets/blue-document-binary.png
--------------------------------------------------------------------------------
/PRIExplorer/Assets/blue-document-code.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chausner/PriTools/02ac5c4dc1f1c5a1dd545742fc1685c7edfd18c9/PRIExplorer/Assets/blue-document-code.png
--------------------------------------------------------------------------------
/PRIExplorer/Assets/blue-document-xaml.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chausner/PriTools/02ac5c4dc1f1c5a1dd545742fc1685c7edfd18c9/PRIExplorer/Assets/blue-document-xaml.png
--------------------------------------------------------------------------------
/PRIExplorer/Assets/blue-document.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chausner/PriTools/02ac5c4dc1f1c5a1dd545742fc1685c7edfd18c9/PRIExplorer/Assets/blue-document.png
--------------------------------------------------------------------------------
/PRIExplorer/Assets/document.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chausner/PriTools/02ac5c4dc1f1c5a1dd545742fc1685c7edfd18c9/PRIExplorer/Assets/document.png
--------------------------------------------------------------------------------
/PRIExplorer/Assets/folder-horizontal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chausner/PriTools/02ac5c4dc1f1c5a1dd545742fc1685c7edfd18c9/PRIExplorer/Assets/folder-horizontal.png
--------------------------------------------------------------------------------
/PRIExplorer/Assets/folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chausner/PriTools/02ac5c4dc1f1c5a1dd545742fc1685c7edfd18c9/PRIExplorer/Assets/folder.png
--------------------------------------------------------------------------------
/PRIExplorer/Controls/CheckerboardImage.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
35 |
36 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/PRIExplorer/Controls/CheckerboardImage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using System.Windows.Markup;
4 |
5 | namespace PRIExplorer.Controls;
6 |
7 | ///
8 | /// Interaktionslogik für CheckerboardImage.xaml
9 | ///
10 | [ContentProperty("AdditionalContent")]
11 | public partial class CheckerboardImage : UserControl
12 | {
13 | public object AdditionalContent
14 | {
15 | get => GetValue(AdditionalContentProperty);
16 | set => SetValue(AdditionalContentProperty, value);
17 | }
18 |
19 | public static readonly DependencyProperty AdditionalContentProperty =
20 | DependencyProperty.Register("AdditionalContent", typeof(object), typeof(CheckerboardImage), new PropertyMetadata(null));
21 |
22 | public CheckerboardImage()
23 | {
24 | InitializeComponent();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/PRIExplorer/PRIExplorer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0-windows
4 | WinExe
5 | false
6 | true
7 | true
8 |
9 |
10 | app.manifest
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 |
--------------------------------------------------------------------------------
/PRIExplorer/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Dieser Code wurde von einem Tool generiert.
4 | // Laufzeitversion: 4.0.30319.42000
5 | //
6 | // Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
7 | // der Code neu generiert wird.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PRIExplorer.Properties
12 | {
13 |
14 |
15 | ///
16 | /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
17 | ///
18 | // Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
19 | // über ein Tool wie ResGen oder Visual Studio automatisch generiert.
20 | // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
21 | // mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PRIExplorer.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
56 | /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/PRIExplorer/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/PRIExplorer/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PRIExplorer.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/PRIExplorer/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/PRIExplorer/ViewModels/BinaryPreviewViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace PRIExplorer.ViewModels;
4 |
5 | public class BinaryPreviewViewModel
6 | {
7 | public string Length { get; }
8 |
9 | public BinaryPreviewViewModel(byte[] data)
10 | {
11 | Length = Convert.ToString(data.Length);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/PRIExplorer/ViewModels/CandidateViewModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Win32;
2 | using PriFormat;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Diagnostics;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Text;
9 |
10 | namespace PRIExplorer.ViewModels;
11 |
12 | public class CandidateViewModel
13 | {
14 | PriFile priFile;
15 | Stream priStream;
16 | string resourceRootPath;
17 | ResourceMapItem resourceMapItem;
18 |
19 | public Candidate Candidate { get; }
20 |
21 | IReadOnlyList qualifiers;
22 |
23 | public string QualifiersDescription
24 | {
25 | get
26 | {
27 | if (qualifiers.Count == 0)
28 | return "(none)";
29 | else
30 | return string.Join(", ", qualifiers.Select(q => q.Type + "=" + q.Value));
31 | }
32 | }
33 |
34 | private string FullLocationPath
35 | {
36 | get
37 | {
38 | string rootPath;
39 |
40 | if (Candidate.SourceFile == null)
41 | rootPath = resourceRootPath;
42 | else
43 | rootPath = Path.GetDirectoryName(priFile.GetReferencedFileByRef(Candidate.SourceFile.Value).FullName);
44 |
45 | return Path.Combine(rootPath, locationPath);
46 | }
47 | }
48 |
49 | public bool SourceNotFound { get; private set; }
50 | public bool LocationNotFound { get; private set; }
51 |
52 | string locationPath;
53 |
54 | public string Location { get; }
55 |
56 | public RelayCommand GoToLocationCommand { get; }
57 | public RelayCommand SaveAsCommand { get; }
58 |
59 | public CandidateViewModel(PriFile priFile, Stream priStream, string resourceRootPath, ResourceMapItem resourceMapItem, Candidate candidate)
60 | {
61 | GoToLocationCommand = new RelayCommand(GoToLocationCommand_CanExecute, GoToLocationCommand_Execute);
62 | SaveAsCommand = new RelayCommand(SaveAsCommand_CanExecute, SaveAsCommand_Execute);
63 |
64 | this.priFile = priFile;
65 | this.priStream = priStream;
66 | this.resourceRootPath = resourceRootPath;
67 | this.resourceMapItem = resourceMapItem;
68 | Candidate = candidate;
69 |
70 | DecisionInfoSection decisionInfoSection =
71 | priFile.GetSectionByRef(priFile.PriDescriptorSection.DecisionInfoSections.First());
72 |
73 | qualifiers = decisionInfoSection.QualifierSets[candidate.QualifierSet].Qualifiers;
74 |
75 | if (candidate.Type == ResourceValueType.AsciiPath ||
76 | candidate.Type == ResourceValueType.Utf8Path ||
77 | candidate.Type == ResourceValueType.Path)
78 | {
79 | string path = (string)GetData();
80 |
81 | if (path != null)
82 | {
83 | locationPath = path;
84 | Location = path;
85 |
86 | if (!File.Exists(FullLocationPath))
87 | LocationNotFound = true;
88 | }
89 | else
90 | Location = "";
91 | }
92 | else
93 | Location = "(embedded)";
94 |
95 | if (candidate.SourceFile != null)
96 | {
97 | string sourcePath = priFile.GetReferencedFileByRef(candidate.SourceFile.Value).FullName;
98 |
99 | if (File.Exists(sourcePath))
100 | Location = sourcePath + ": " + Location;
101 | else
102 | {
103 | Location = sourcePath + " (not found)";
104 | SourceNotFound = true;
105 | }
106 | }
107 | }
108 |
109 | public object GetData()
110 | {
111 | byte[] data;
112 |
113 | if (Candidate.SourceFile == null)
114 | {
115 | ByteSpan byteSpan;
116 |
117 | if (Candidate.DataItem != null)
118 | byteSpan = priFile.GetDataItemByRef(Candidate.DataItem.Value);
119 | else
120 | byteSpan = Candidate.Data.Value;
121 |
122 | priStream.Seek(byteSpan.Offset, SeekOrigin.Begin);
123 |
124 | using (BinaryReader binaryReader = new BinaryReader(priStream, Encoding.Default, true))
125 | data = binaryReader.ReadBytes((int)byteSpan.Length);
126 | }
127 | else
128 | {
129 | string sourcePath = priFile.GetReferencedFileByRef(Candidate.SourceFile.Value).FullName;
130 |
131 | if (!File.Exists(sourcePath))
132 | return null;
133 |
134 | using (FileStream fileStream = File.OpenRead(sourcePath))
135 | {
136 | PriFile sourcePriFile = PriFile.Parse(fileStream);
137 | ByteSpan byteSpan = sourcePriFile.GetDataItemByRef(Candidate.DataItem.Value);
138 |
139 | fileStream.Seek(byteSpan.Offset, SeekOrigin.Begin);
140 |
141 | using (BinaryReader binaryReader = new BinaryReader(fileStream, Encoding.Default, true))
142 | data = binaryReader.ReadBytes((int)byteSpan.Length);
143 | }
144 | }
145 |
146 | switch (Candidate.Type)
147 | {
148 | case ResourceValueType.AsciiPath:
149 | case ResourceValueType.AsciiString:
150 | return Encoding.ASCII.GetString(data).TrimEnd('\0');
151 | case ResourceValueType.Utf8Path:
152 | case ResourceValueType.Utf8String:
153 | return Encoding.UTF8.GetString(data).TrimEnd('\0');
154 | case ResourceValueType.Path:
155 | case ResourceValueType.String:
156 | return Encoding.Unicode.GetString(data).TrimEnd('\0');
157 | case ResourceValueType.EmbeddedData:
158 | return data;
159 | default:
160 | throw new Exception();
161 | }
162 | }
163 |
164 | private bool GoToLocationCommand_CanExecute()
165 | {
166 | return locationPath != null;
167 | }
168 |
169 | private void GoToLocationCommand_Execute()
170 | {
171 | string fullLocationPath = FullLocationPath;
172 |
173 | Process.Start("explorer.exe", string.Format("/select,\"{0}\"", fullLocationPath));
174 | }
175 |
176 | private bool SaveAsCommand_CanExecute()
177 | {
178 | return true;
179 | }
180 |
181 | private void SaveAsCommand_Execute()
182 | {
183 | object data = GetData();
184 |
185 | if (data == null)
186 | return;
187 |
188 | byte[] byteData = null;
189 |
190 | string externalFilePath = null;
191 |
192 | switch (Candidate.Type)
193 | {
194 | case ResourceValueType.String:
195 | case ResourceValueType.AsciiString:
196 | case ResourceValueType.Utf8String:
197 | byteData = Encoding.UTF8.GetBytes((string)data);
198 | break;
199 | case ResourceValueType.Path:
200 | case ResourceValueType.AsciiPath:
201 | case ResourceValueType.Utf8Path:
202 | string rootPath;
203 |
204 | if (Candidate.SourceFile == null)
205 | rootPath = resourceRootPath;
206 | else
207 | rootPath = Path.GetDirectoryName(priFile.GetReferencedFileByRef(Candidate.SourceFile.Value).FullName);
208 |
209 | externalFilePath = Path.Combine(rootPath, (string)data);
210 | break;
211 | case ResourceValueType.EmbeddedData:
212 | byteData = (byte[])data;
213 | break;
214 | }
215 |
216 | SaveFileDialog saveFileDialog = new SaveFileDialog();
217 |
218 | saveFileDialog.Filter = "All files (*.*)|*.*";
219 |
220 | if (externalFilePath != null)
221 | saveFileDialog.FileName = Path.GetFileName(externalFilePath);
222 | else if (qualifiers.Any())
223 | saveFileDialog.FileName = Path.GetFileNameWithoutExtension(resourceMapItem.Name) +
224 | "." + string.Join("_", qualifiers.Select(q => $"{q.Type.ToString().ToLower()}-{q.Value.ToLower()}")) +
225 | Path.GetExtension(resourceMapItem.Name);
226 | else
227 | saveFileDialog.FileName = resourceMapItem.Name;
228 |
229 | if (saveFileDialog.ShowDialog() != true)
230 | return;
231 |
232 | if (externalFilePath != null)
233 | File.Copy(externalFilePath, saveFileDialog.FileName, true);
234 | else
235 | File.WriteAllBytes(saveFileDialog.FileName, byteData);
236 | }
237 | }
238 |
--------------------------------------------------------------------------------
/PRIExplorer/ViewModels/EntryViewModel.cs:
--------------------------------------------------------------------------------
1 | using PriFormat;
2 | using System.Collections.ObjectModel;
3 |
4 | namespace PRIExplorer.ViewModels;
5 |
6 | public class EntryViewModel
7 | {
8 | public ResourceMapEntry ResourceMapEntry { get; }
9 | public EntryType Type { get; }
10 | public string Icon { get; set; }
11 | public bool IsString { get; set; }
12 |
13 | public ObservableCollection Children { get; }
14 |
15 | public EntryViewModel(ResourceMapEntry resourceMapEntry)
16 | {
17 | ResourceMapEntry = resourceMapEntry;
18 | Type = resourceMapEntry is ResourceMapScope ? EntryType.Scope : EntryType.Item;
19 |
20 | Children = new ObservableCollection();
21 | }
22 |
23 | public string Name => ResourceMapEntry.Name;
24 | }
25 |
26 | public class StringEntryViewModel : EntryViewModel
27 | {
28 | public StringEntryViewModel(ResourceMapEntry resourceMapEntry, string name) : base(resourceMapEntry)
29 | {
30 | Name = name;
31 | Icon = "/Assets/blue-document-attribute-s.png";
32 | }
33 |
34 | public new string Name { get; }
35 | }
36 |
37 | public enum EntryType
38 | {
39 | Scope,
40 | Item
41 | }
42 |
--------------------------------------------------------------------------------
/PRIExplorer/ViewModels/ImagePreviewViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Windows.Media.Imaging;
3 |
4 | namespace PRIExplorer.ViewModels;
5 |
6 | public class ImagePreviewViewModel
7 | {
8 | public BitmapImage Image { get; }
9 | public string ImageSize { get; }
10 |
11 | public ImagePreviewViewModel(byte[] data)
12 | {
13 | BitmapImage bitmapImage = new BitmapImage();
14 |
15 | bitmapImage.BeginInit();
16 | bitmapImage.StreamSource = new MemoryStream(data, false);
17 | bitmapImage.EndInit();
18 |
19 | Image = bitmapImage;
20 | ImageSize = $"Size: {bitmapImage.PixelWidth} x {bitmapImage.PixelHeight}";
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/PRIExplorer/ViewModels/MainViewModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Win32;
2 | using PRIExplorer.Views;
3 | using PriFormat;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Collections.ObjectModel;
7 | using System.ComponentModel;
8 | using System.IO;
9 | using System.Linq;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 |
13 | namespace PRIExplorer.ViewModels;
14 |
15 | public class MainViewModel : INotifyPropertyChanged
16 | {
17 | public FileStream PriStream { get; private set; }
18 | public PriFile PriFile { get; private set; }
19 | public string ResourceRootPath { get; private set; }
20 |
21 | public ObservableCollection Entries { get; private set; }
22 | public ObservableCollection Candidates { get; private set; }
23 |
24 | object previewContent;
25 |
26 | EntryViewModel selectedEntry;
27 | CandidateViewModel selectedCandidate;
28 |
29 | public RelayCommand OpenCommand { get; }
30 | public RelayCommand CloseCommand { get; }
31 | public RelayCommand SetResourceRootPathCommand { get; }
32 |
33 | public event PropertyChangedEventHandler PropertyChanged;
34 |
35 | public MainViewModel()
36 | {
37 | OpenCommand = new RelayCommand(OpenCommand_Execute);
38 | CloseCommand = new RelayCommand(CloseCommand_Execute);
39 | SetResourceRootPathCommand = new RelayCommand(SetResourceRootPathCommand_CanExecute, SetResourceRootPathCommand_Execute);
40 |
41 | Entries = new ObservableCollection();
42 | Candidates = new ObservableCollection();
43 | }
44 |
45 | private void OpenCommand_Execute()
46 | {
47 | OpenFileDialog openFileDialog = new OpenFileDialog();
48 |
49 | openFileDialog.Filter = "Package Resource Index files (*.pri)|*.pri";
50 |
51 | if (openFileDialog.ShowDialog() != true)
52 | return;
53 |
54 | OpenPriFile(openFileDialog.FileName);
55 | }
56 |
57 | private void CloseCommand_Execute()
58 | {
59 | Application.Current.Shutdown();
60 | }
61 |
62 | private bool SetResourceRootPathCommand_CanExecute()
63 | {
64 | return PriFile != null;
65 | }
66 |
67 | private void SetResourceRootPathCommand_Execute()
68 | {
69 | OpenFolderDialog openFolderDialog = new OpenFolderDialog();
70 |
71 | openFolderDialog.Title = "Set resource path root";
72 | openFolderDialog.Multiselect = false;
73 | openFolderDialog.InitialDirectory = ResourceRootPath;
74 |
75 | if (openFolderDialog.ShowDialog() != true)
76 | return;
77 |
78 | ResourceRootPath = openFolderDialog.FolderName;
79 |
80 | GetEntries();
81 | }
82 |
83 | public void OpenPriFile(string path)
84 | {
85 | ClosePriFile();
86 |
87 | try
88 | {
89 | PriStream = File.OpenRead(path);
90 |
91 | PriFile = PriFile.Parse(PriStream);
92 | }
93 | catch
94 | {
95 | ClosePriFile();
96 | MessageBox.Show("Could not read file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
97 | return;
98 | }
99 |
100 | if (!PriFile.Sections.OfType().Any())
101 | {
102 | ClosePriFile();
103 | MessageBox.Show("Incompatible PRI file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
104 | return;
105 | }
106 |
107 | ResourceRootPath = Path.GetDirectoryName(path);
108 |
109 | GetEntries();
110 |
111 | SetResourceRootPathCommand.RaiseCanExecuteChanged();
112 | }
113 |
114 | private void ClosePriFile()
115 | {
116 | Entries.Clear();
117 | Candidates.Clear();
118 | PreviewContent = null;
119 |
120 | if (PriStream != null)
121 | {
122 | PriStream.Close();
123 | PriStream = null;
124 | }
125 |
126 | PriFile = null;
127 | ResourceRootPath = null;
128 |
129 | SetResourceRootPathCommand.RaiseCanExecuteChanged();
130 | }
131 |
132 | private void GetEntries()
133 | {
134 | Entries.Clear();
135 | Candidates.Clear();
136 |
137 | ResourceMapSection primaryResourceMapSection = PriFile.GetSectionByRef(PriFile.PriDescriptorSection.PrimaryResourceMapSection.Value);
138 | HierarchicalSchemaSection schemaSection = PriFile.GetSectionByRef(primaryResourceMapSection.SchemaSection);
139 |
140 | Dictionary entriesToViewModels = new Dictionary();
141 |
142 | bool parentMissing = false;
143 |
144 | do
145 | {
146 | foreach (ResourceMapScope scope in schemaSection.Scopes)
147 | {
148 | if (scope.FullName == string.Empty)
149 | continue;
150 |
151 | IList targetEntryCollection;
152 |
153 | if (scope.Parent == null)
154 | targetEntryCollection = Entries;
155 | else
156 | {
157 | EntryViewModel parentViewModel;
158 |
159 | if (scope.Parent.FullName == string.Empty)
160 | targetEntryCollection = Entries;
161 | else
162 | if (!entriesToViewModels.TryGetValue(scope.Parent, out parentViewModel))
163 | {
164 | parentMissing = true;
165 | continue;
166 | }
167 | else
168 | targetEntryCollection = parentViewModel.Children;
169 | }
170 |
171 | EntryViewModel entry = new EntryViewModel(scope);
172 |
173 | GetEntryType(entry);
174 |
175 | entriesToViewModels.Add(scope, entry);
176 |
177 | targetEntryCollection.Add(entry);
178 | }
179 | } while (parentMissing);
180 |
181 | foreach (ResourceMapItem item in schemaSection.Items)
182 | {
183 | EntryViewModel parentViewModel;
184 |
185 | if (!entriesToViewModels.TryGetValue(item.Parent, out parentViewModel))
186 | continue;
187 |
188 | parentViewModel.Children.Add(new EntryViewModel(item));
189 |
190 | GetEntryType(parentViewModel.Children.Last());
191 | }
192 |
193 | CollapseStringResources();
194 | }
195 |
196 | private IEnumerable EnumerateCandidates(ResourceMapItem resourceMapItem)
197 | {
198 | ResourceMapSection primaryResourceMapSection =
199 | PriFile.GetSectionByRef(PriFile.PriDescriptorSection.PrimaryResourceMapSection.Value);
200 |
201 | CandidateSet candidateSet;
202 |
203 | if (primaryResourceMapSection.CandidateSets.TryGetValue(resourceMapItem.Index, out candidateSet))
204 | foreach (Candidate candidate in candidateSet.Candidates)
205 | if (candidate != null)
206 | yield return candidate;
207 | }
208 |
209 | private void GetCandidates(ResourceMapItem resourceMapItem)
210 | {
211 | Candidates.Clear();
212 |
213 | foreach (Candidate candidate in EnumerateCandidates(resourceMapItem))
214 | {
215 | CandidateViewModel candidateViewModel = new CandidateViewModel(PriFile, PriStream, ResourceRootPath, resourceMapItem, candidate);
216 |
217 | Candidates.Add(candidateViewModel);
218 | }
219 | }
220 |
221 | private void GetEntryType(EntryViewModel entry)
222 | {
223 | if (entry.ResourceMapEntry is ResourceMapScope)
224 | entry.Icon = "/Assets/folder-horizontal.png";
225 | else
226 | {
227 | entry.Icon = "/Assets/blue-document.png";
228 |
229 | ResourceMapItem resourceMapItem = (ResourceMapItem)entry.ResourceMapEntry;
230 |
231 | CandidateViewModel[] candidates = EnumerateCandidates(resourceMapItem)
232 | .Select(candidate => new CandidateViewModel(PriFile, PriStream, ResourceRootPath, resourceMapItem, candidate)).ToArray();
233 |
234 | if (candidates.Length == 0)
235 | entry.Icon = "/Assets/document.png";
236 | else if (candidates.All(c => c.SourceNotFound || c.LocationNotFound))
237 | entry.Icon = "/Assets/blue-document-attribute-x.png";
238 | else if (candidates.All(
239 | c => c.Candidate.Type == ResourceValueType.String ||
240 | c.Candidate.Type == ResourceValueType.AsciiString ||
241 | c.Candidate.Type == ResourceValueType.Utf8String))
242 | {
243 | entry.Icon = "/Assets/blue-document-attribute-s.png";
244 | entry.IsString = true;
245 | }
246 | else if (resourceMapItem.Name.EndsWith(".xbf", StringComparison.OrdinalIgnoreCase) ||
247 | resourceMapItem.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase))
248 | entry.Icon = "/Assets/blue-document-xaml.png";
249 | }
250 | }
251 |
252 | private void CollapseStringResources()
253 | {
254 | foreach (EntryViewModel entry in Entries)
255 | if (entry.Type == EntryType.Scope)
256 | CollapseStringResources(entry);
257 | }
258 |
259 | private void CollapseStringResources(EntryViewModel entry)
260 | {
261 | if (ContainsOnlyStringResources(entry))
262 | {
263 | Dictionary strings = new Dictionary();
264 | CollectStringResources(entry, string.Empty, strings);
265 | entry.Children.Clear();
266 | foreach (KeyValuePair s in strings)
267 | entry.Children.Add(new StringEntryViewModel(s.Key.ResourceMapEntry, s.Value));
268 | }
269 | else
270 | foreach (EntryViewModel child in entry.Children)
271 | if (child.Type == EntryType.Scope)
272 | CollapseStringResources(child);
273 | }
274 |
275 | private bool ContainsOnlyStringResources(EntryViewModel entry)
276 | {
277 | foreach (EntryViewModel child in entry.Children)
278 | {
279 | if (child.Type == EntryType.Scope)
280 | {
281 | if (!ContainsOnlyStringResources(child))
282 | return false;
283 | }
284 | else
285 | if (!child.IsString)
286 | return false;
287 | }
288 |
289 | return true;
290 | }
291 |
292 | private void CollectStringResources(EntryViewModel entry, string prefix, Dictionary strings)
293 | {
294 | foreach (EntryViewModel child in entry.Children)
295 | if (child.Type == EntryType.Scope)
296 | CollectStringResources(child, (prefix != "" ? (prefix + ".") : "") + child.ResourceMapEntry.Name, strings);
297 | else
298 | strings.Add(child, (prefix != "" ? (prefix + ".") : "") + child.ResourceMapEntry.Name);
299 | }
300 |
301 | public EntryViewModel SelectedEntry
302 | {
303 | get => selectedEntry;
304 | set
305 | {
306 | if (selectedEntry != value)
307 | {
308 | selectedEntry = value;
309 | SelectedEntryChanged();
310 | }
311 | }
312 | }
313 |
314 | public CandidateViewModel SelectedCandidate
315 | {
316 | get => selectedCandidate;
317 | set
318 | {
319 | if (selectedCandidate != value)
320 | {
321 | selectedCandidate = value;
322 | SelectedCandidateChanged();
323 | }
324 | }
325 | }
326 |
327 | public object PreviewContent
328 | {
329 | get => previewContent;
330 | set
331 | {
332 | if (previewContent != value)
333 | {
334 | previewContent = value;
335 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PreviewContent)));
336 | }
337 | }
338 | }
339 |
340 | public void SelectedEntryChanged()
341 | {
342 | if (selectedEntry == null)
343 | {
344 | PreviewContent = null;
345 | return;
346 | }
347 |
348 | //if (selectedEntry.ResourceMapEntry is ResourceMapScope)
349 | //{
350 | // ResourceMapScope selectedScope = (ResourceMapScope)selectedEntry.ResourceMapEntry;
351 |
352 | // scopeDetailFrame.Navigate(new ScopeDetailPage(PriFile, PriStream, selectedScope));
353 |
354 | // scopeDetailFrame.Visibility = Visibility.Visible;
355 | //}
356 | //else
357 | //{
358 | // scopeDetailFrame.Visibility = Visibility.Hidden;
359 | // scopeDetailFrame.Navigate(null);
360 | //}
361 |
362 | if (selectedEntry.ResourceMapEntry is ResourceMapItem resourceMapItem)
363 | {
364 | GetCandidates(resourceMapItem);
365 |
366 | if (Candidates.Count > 0)
367 | SelectedCandidate = Candidates.First();
368 | else
369 | PreviewContent = null;
370 | }
371 | }
372 |
373 | public void SelectedCandidateChanged()
374 | {
375 | if (selectedCandidate == null)
376 | return;
377 |
378 | object data = selectedCandidate.GetData();
379 |
380 | if (data == null)
381 | {
382 | PreviewContent = null;
383 | return;
384 | }
385 |
386 | byte[] byteData = null;
387 |
388 | object previewContent = null;
389 |
390 | switch (selectedCandidate.Candidate.Type)
391 | {
392 | case ResourceValueType.Path:
393 | case ResourceValueType.AsciiPath:
394 | case ResourceValueType.Utf8Path:
395 | string rootPath;
396 |
397 | if (selectedCandidate.Candidate.SourceFile == null)
398 | rootPath = ResourceRootPath;
399 | else
400 | rootPath = Path.GetDirectoryName(PriFile.GetReferencedFileByRef(selectedCandidate.Candidate.SourceFile.Value).FullName);
401 |
402 | string externalFilePath = Path.Combine(rootPath, (string)data);
403 |
404 | if (File.Exists(externalFilePath))
405 | byteData = File.ReadAllBytes(externalFilePath);
406 | else
407 | previewContent = new PathNotFoundPreviewPage(new PathNotFoundPreviewViewModel(externalFilePath), this);
408 | break;
409 | case ResourceValueType.String:
410 | case ResourceValueType.AsciiString:
411 | case ResourceValueType.Utf8String:
412 | previewContent = data;
413 | break;
414 | case ResourceValueType.EmbeddedData:
415 | byteData = (byte[])data;
416 | break;
417 | }
418 |
419 | if (previewContent == null)
420 | {
421 | string itemName = selectedEntry?.ResourceMapEntry.Name ?? "";
422 |
423 | try
424 | {
425 | if (itemName.EndsWith(".xbf", StringComparison.OrdinalIgnoreCase))
426 | previewContent = new XbfPreviewPage(new XbfPreviewViewModel(byteData));
427 | else if (itemName.EndsWith(".bmp", StringComparison.OrdinalIgnoreCase) ||
428 | itemName.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) ||
429 | itemName.EndsWith(".jpeg", StringComparison.OrdinalIgnoreCase) ||
430 | itemName.EndsWith(".png", StringComparison.OrdinalIgnoreCase) ||
431 | itemName.EndsWith(".gif", StringComparison.OrdinalIgnoreCase) ||
432 | itemName.EndsWith(".ico", StringComparison.OrdinalIgnoreCase) ||
433 | itemName.EndsWith(".tif", StringComparison.OrdinalIgnoreCase) ||
434 | itemName.EndsWith(".tiff", StringComparison.OrdinalIgnoreCase))
435 | previewContent = new ImagePreviewPage(new ImagePreviewViewModel(byteData));
436 | else if ((byteData.Length >= 3 && byteData[0] == 0xEF && byteData[1] == 0xBB && byteData[2] == 0xBF) ||
437 | byteData.Length >= 2 && byteData[0] == 0xEF && byteData[1] == 0xFF ||
438 | byteData.Length >= 2 && byteData[0] == 0xFF && byteData[1] == 0xEF ||
439 | byteData.All(b => b >= 8 && b <= 127))
440 | previewContent = new TextPreviewPage(new TextPreviewViewModel(byteData));
441 | else
442 | previewContent = new BinaryPreviewPage(new BinaryPreviewViewModel(byteData));
443 | }
444 | catch (Exception ex)
445 | {
446 | TextBlock textBlock = new TextBlock();
447 |
448 | textBlock.Margin = new Thickness(8);
449 | textBlock.Text = ex.ToString();
450 |
451 | previewContent = textBlock;
452 | }
453 | }
454 |
455 | PreviewContent = previewContent;
456 | }
457 | }
458 |
--------------------------------------------------------------------------------
/PRIExplorer/ViewModels/PathNotFoundPreviewViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace PRIExplorer.ViewModels;
2 |
3 | public class PathNotFoundPreviewViewModel
4 | {
5 | public string Message { get; }
6 |
7 | public PathNotFoundPreviewViewModel(string path)
8 | {
9 | Message = $"Cound not find file: {path}";
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/PRIExplorer/ViewModels/RelayCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 |
4 | namespace PRIExplorer.ViewModels;
5 |
6 | public class RelayCommand : ICommand
7 | {
8 | public event EventHandler CanExecuteChanged;
9 |
10 | Func canExecute;
11 | Action execute;
12 |
13 | public RelayCommand(Action execute)
14 | {
15 | this.execute = execute;
16 | }
17 |
18 | public RelayCommand(Func canExecute, Action execute)
19 | {
20 | this.canExecute = canExecute;
21 | this.execute = execute;
22 | }
23 |
24 | public bool CanExecute(object parameter)
25 | {
26 | if (canExecute != null)
27 | return canExecute();
28 | else
29 | return true;
30 | }
31 |
32 | public void Execute(object parameter)
33 | {
34 | execute();
35 | }
36 |
37 | public void RaiseCanExecuteChanged()
38 | {
39 | CanExecuteChanged?.Invoke(this, EventArgs.Empty);
40 | }
41 | }
42 |
43 | class RelayCommand : ICommand
44 | {
45 | public event EventHandler CanExecuteChanged;
46 |
47 | Predicate canExecute;
48 | Action execute;
49 |
50 | public RelayCommand(Action execute)
51 | {
52 | this.execute = execute;
53 | }
54 |
55 | public RelayCommand(Predicate canExecute, Action execute)
56 | {
57 | this.canExecute = canExecute;
58 | this.execute = execute;
59 | }
60 |
61 | public bool CanExecute(object parameter)
62 | {
63 | if (canExecute != null)
64 | return canExecute((T)parameter);
65 | else
66 | return true;
67 | }
68 |
69 | public void Execute(object parameter)
70 | {
71 | execute((T)parameter);
72 | }
73 |
74 | public void RaiseCanExecuteChanged()
75 | {
76 | CanExecuteChanged?.Invoke(this, EventArgs.Empty);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/PRIExplorer/ViewModels/TextPreviewViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace PRIExplorer.ViewModels;
4 |
5 | public class TextPreviewViewModel
6 | {
7 | public string Text { get; }
8 |
9 | public TextPreviewViewModel(byte[] data)
10 | {
11 | Encoding encoding;
12 |
13 | if (data.Length >= 3 && data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF)
14 | encoding = Encoding.UTF8;
15 | else if (data.Length >= 2 && data[0] == 0xEF && data[1] == 0xFF ||
16 | data.Length >= 2 && data[0] == 0xFF && data[1] == 0xEF)
17 | encoding = Encoding.Unicode;
18 | else
19 | encoding = Encoding.ASCII;
20 |
21 | Text = encoding.GetString(data);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/PRIExplorer/ViewModels/XbfPreviewViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using XbfAnalyzer.Xbf;
4 |
5 | namespace PRIExplorer.ViewModels;
6 |
7 | public class XbfPreviewViewModel
8 | {
9 | public string Xaml { get; private set; }
10 |
11 | public XbfPreviewViewModel(byte[] data)
12 | {
13 | using (MemoryStream memoryStream = new MemoryStream(data))
14 | {
15 | XbfReader xbfReader = new XbfReader(memoryStream);
16 |
17 | if (xbfReader.Header.MajorFileVersion != 2)
18 | throw new Exception("Only XBF2 files can be decompiled.");
19 |
20 | Xaml = xbfReader.RootObject.ToString();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/PRIExplorer/Views/BinaryPreviewPage.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/PRIExplorer/Views/BinaryPreviewPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using PRIExplorer.ViewModels;
2 | using System.Windows.Controls;
3 |
4 | namespace PRIExplorer.Views;
5 |
6 | ///
7 | /// Interaktionslogik für BinaryPreviewPage.xaml
8 | ///
9 | public partial class BinaryPreviewPage : Page
10 | {
11 | public BinaryPreviewPage(BinaryPreviewViewModel viewModel)
12 | {
13 | InitializeComponent();
14 |
15 | DataContext = viewModel;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/PRIExplorer/Views/ImagePreviewPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/PRIExplorer/Views/ImagePreviewPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using PRIExplorer.ViewModels;
2 | using System.Windows.Controls;
3 |
4 | namespace PRIExplorer.Views;
5 |
6 | ///
7 | /// Interaktionslogik für ImagePreviewPage.xaml
8 | ///
9 | public partial class ImagePreviewPage : Page
10 | {
11 | public ImagePreviewPage(ImagePreviewViewModel viewModel)
12 | {
13 | InitializeComponent();
14 |
15 | DataContext = viewModel;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/PRIExplorer/Views/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
62 |
64 |
65 |
68 |
69 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/PRIExplorer/Views/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using PRIExplorer.ViewModels;
2 | using System.Windows;
3 |
4 | namespace PRIExplorer;
5 |
6 | ///
7 | /// Interaktionslogik für MainWindow.xaml
8 | ///
9 | public partial class MainWindow : Window
10 | {
11 | MainViewModel viewModel;
12 |
13 | public MainWindow()
14 | {
15 | InitializeComponent();
16 |
17 | viewModel = new MainViewModel();
18 |
19 | DataContext = viewModel;
20 | }
21 |
22 | private void resourceMapTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs