dnSpyEx / dnSpy

Unofficial revival of the well known .NET debugger and assembly editor, dnSpy
GNU General Public License v3.0
6.14k stars 412 forks source link

Modify and reassemble BAML files #324

Open adryd325 opened 1 month ago

adryd325 commented 1 month ago

Problem Description

It's very difficult to modify BAML files. At the moment I export the raw BAML, edit in a hex editor, and then re-add to the resource bundle.

Proposal

A built in way to modify or re-assemble the BAML assembly generated by dnSpy would solve this problem and make editing BAML much more accessible

Alternatives

No response

Additional Context

To clarify, this is not to hoping to compile the decompiled XAML output, this is to reassemble the disassembled BAML dnSpy offers. I figure compiling the decompiled XAML output might not be possible

Additionally, if anyone has any other suggestions on editing compiled BAML, those suggestions would be much appreciated

adryd325 commented 1 month ago

Another note: I've found some super basic tools taking advantage of ConfuserEx's BAML implementation

ElektroKill commented 1 month ago

Hello,

Editing the BAML record structure is definitely a feature I will consider. The major roadblock here would be designing an appropriate UX for this. If you have any suggestions for this, feel free to share! The actual part of writing BAML is already incorporated in the BAML decompiler component.

Another note: I've found some super basic tools taking advantage of ConfuserEx's BAML implementation

dnSpy's BAML reader/writer implementation is a modified version of the ConfuserEx implementation. It can be found here: https://github.com/dnSpyEx/dnSpy/tree/master/Extensions/dnSpy.BamlDecompiler/Baml

I figure compiling the decompiled XAML output might not be possible

Yep, this is not something that can be done in a 100% reliable way.

adryd325 commented 1 month ago

The way I had gone about doing my edits was adding a toJson and fromJson method to each of the record types, and exporting to an intermediary file. It's definitely not optimal but it did the trick for one of the things I wanted to do.

Something that would resolve references would be nice. Also incrementing values that need to be incremented when adding elements automatically would be nice.

Otherwise I'm not super familiar with BAML/XAML and wouldn't be able to give that many pointers