Name: proto-extractor
Owner: HearthSim
Description: Program to extract protobufs compiled for C#
Created: 2015-03-29 21:32:54.0
Updated: 2018-03-17 20:14:00.0
Pushed: 2017-08-28 14:29:20.0
Homepage: https://hearthsim.info
Size: 717
Language: C#
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A C# program to extract Protocol Buffer definitions compiled with Google Protos or SilentOrbit.
The file
protobin_to_proto.py
is discussed below.
There are 2 versions of the extractor project. Both projects have the same purpose, but target a different framework each.
Compile and run the
Extractor
project!
You can get the .Net Core compilation tools through 2 channels;
Download the (CLI) binaries by downloading directly from the site. When using the dotnet CLI to build the project, make sure to restore dependant packages first!
OR
Update your Visual Studio 2017 installation to include the .Net Core cross-platform development
, which can be found under section Other toolsets
.
Using Visual Studio 2017 is recommended because it handles dependancies and builds the project correctly for YOU. There is a community version which is free to install and use.
Compile and run the
Mono-Extractor
project!
You can download the Mono tools from their site. Their msbuild
executable should automatically restore dependant packages.
Compile the program. Give it the library files you want to decompile and if you want proto2 or proto3 syntax.
The program will do the following actions automatically:
Basic usage example:
o-extractor --libPath "%HS_LOCATION%/Hearthstone_Data/Managed"
tPath "./proto-out"
_LOCATION%/Hearthstone_Data/Managed/Assembly-CSharp.dll"
_LOCATION%/Hearthstone_Data/Managed/Assembly-CSharp-firstpass.dll"
Extended usage example:
This command is used to generate protobuffer files for HS proto repository
o-extractor --libPath "%HS_LOCATION%/Hearthstone_Data/Managed"
tPath "./proto-out" --proto2 --automatic-packaging --manual-package-file "%REPO%/hscode-proto-packaging.ini"
_LOCATION%/Hearthstone_Data/Managed/Assembly-CSharp.dll"
_LOCATION%/Hearthstone_Data/Managed/Assembly-CSharp-firstpass.dll"
The section
Options
explains all parameters. The executable will write parameter parsing errors on standard outstream.
The option --proto3
will use the proto3 compiler to generate .proto files with protobuffer 3 syntax.
Defaults to False.
The option --resolve-circular-dependancies
will run a processor object that detects and solves circular dependancies for you. Both circular dependancies between types and namespaces are detected.
Defaults to True.
The option --resolve-name-collisions
will run a processor object that detects and solves all kinds of name collisions for you. See the processor code for more details.
Defaults to True.
The option --automatic-packaging
will try to group namespaces under the same namespace if their names show similarities. The used algorithm is longest substring matching, with anchorpoint at the beginning of the string. Half-words are cut to the nearest namespace component.
Defaults to False.
The option --manual-package-file "PATH-TO-INI-FILE"
can be used manually move content of namespaces or specific types to other/new namespaces. See the file hscode-proto-packaging.ini
in the root of the repo for examples.
It's important to keep the order of processing algorithms in mind! We shouldn't try to manually compensate the behaviour of the automatic dependancy resolver. This has to do with trying to keep a consistent layout of outputted protobuffer files regarding the absolute dependancy on the source material.
Defaults to “” (empty string) -> nothing will happen.
The execution order of processing algorithms is always as follows:
Use the
protobin_to_proto.py
file!
At the root of the repository you'll find a python3 script that extracts protobuffer files from arbitrary binary files.
This only works on proto files which have been compiled with the Google Protobuffer compiler tool (protoc)! Use the proto-extractor project (see above) for hearthstone related proto files.
The only requirement for this script is the Google Protobuffer package which you can install through pip. A quick setup guide is given below.
pip3 install virtualenv
py -3 -m virtualenv ./.env
./env/Scripts/activate
pip install protobuf
python protobin_to_proto.py -o [out-dir] [inputfile [inputfiles ..]]
Proto-extractor is licensed under the terms of the MIT license.
The full license text is available in the LICENSE
file.
proto-extractor is a HearthSim project. All development
happens on our IRC channel #hearthsim
on Freenode.
Contributions are welcome. Make sure to read through the CONTRIBUTING.md
first.