Personal blog and homepage.

Tools for extracting Company of Heroes 3 (Pre-alpha) and Age of Empires IV SGA archives

Release of CoH3.ArchiveViewer tool to view and extract the contents of Company of Heroes 3 SGA archives.

Table of contents

History

Tools

Research

Modifying Archive Viewer

Downloads

Tips and tricks

References

Footnotes

Company of Heroes 3 was announced on July 13th, 2021. A public pre-alpha build of the game was made available via https://companyofheroes.com/ for 3 weeks. The public pre-alpha is distributed via Steam.

History

SGA format, which is the archive format used by Relic games for game assets. Dawn of War 1 used version 2 SGA files, Company of Heroes used version 4 and Dawn of War II uses version 5 (for completeness, I think Impossible Creatures used version 1, some unreleased project or The Outfit used version 3, and Company of Heroes Online used version 4.1). 1

Version Products
10 Company of Heroes 3, Age of Empires IV
9 Dawn of War III
8 Unknown 2
7 Company of Heroes 2
6 Unknown 2
5 Dawn of War II
4.1 Company of Heroes Online 1
4 Company of Heroes
3 some unreleased project or The Outfit 1
2 Dawn of War I 1
1 Impossible Creatures 1

Tools

Official Company of Heroes 2 modding tools include Archive Viewer , which allows browsing and extracting the contents of SGA archives between versions 4 and 7 . The Archive Viewer is a .NET application. This makes decompiling the application into source code that can be recompiled, with possible modifications, relatively easy. Sometimes the decompilation process is not perfect but usually it’s good enough to at least view the decompiled source code.

One of these .NET decompilation tools is https://github.com/dnSpy/dnSpy .

Research

Archive Viewer parses the contents of SGA archives via RelicCore.dll . This library is also a .NET binary. Luckily Company of Heroes 3 Pre-alpha files contain a similar .NET library: \steamapps\common\Company of Heroes 3 - Pre-Alpha Preview\dev\mstest\TestProjects\Essence.Rpc.FunctionalTests.Anvil\Essence.Core.dll . The namespaces have been changed but the API for reading SGA archives seems to have remained unchanged when compared to Company of Heroes 2’s RelicCore.dll .

This should make it possible to modify the Archive Viewer to use use Essence.Core.dll instead of RelicCore.dll .

Modifying Archive Viewer

Archive Viewer was first exported to a Visual Studio project using DnSpy. The decompilation process wasn’t perfect which lead to having to manually fix tens of xaml related issues. Once the decompiled Archive Viewer successfully recompiled and worked, the reference to RelicCore.dll was replaced with Essence.Core.dll .

After changing the referenced library all changed namespace references were made to various source files to work with Essence.Core.dll .

The final result was a successfully compiling and starting version of Archive Viewer.

Downloads

Tips and tricks

You can assign CoH3.ArchiveViewer.exe to be default application for .sga files by doing the following:

  1. Right-click any .sga file and select Open with -> Choose another app
  2. Check the Always use this app to open .sga files
  3. Click More apps and browse down the list until the option Look for another app on this PC becomes visible, and click it
  4. Browse to where you’ve extracted CoH3.ArchiveViewer.exe and select it
  5. Done! You can now double-click any .sga file to quickly open it in CoH3.ArchiveViewer.exe

References

Footnotes

  1. https://www.corsix.org/content/sga4to5 2 3 4 5

  2. If you know, post a comment below! 2


Commenting is based on https://disqus.com/ - a commonly used 3rd party commenting service for websites and blogs. It will most certainly add cookies to your browser and track you. It will not be loaded until the user clicks the button above.