Jump to content
Tuts 4 You
Benjamin

Edit XAML in .NET Apps

Recommended Posts

Benjamin

I have done a lot of searches on this topic but there seems to be no satisfactory way to edit XAML in apps (through DnSpy or any other tools) when we don't have access to its original source code.

What I am trying to do is this: I want to be able to open an app in DnSpy that has a lot of XAML in it, edit the XAML portions and then save it so that it runs again. This seems to not possible at this time. When I try to do this, the app does not run. After checking out the issues section in the DnSpy's github repo, I see that it had been discussed multiple times with no satisfactory solution.

So I wanted to ask and see if anyone here could come up with a good solution, with or without the use DnSpy.

Share this post


Link to post
Kurapica

What error do you get after editing the XAML and running the application ? more details ?

Share this post


Link to post
BlackHat

 A better way to do this is - do all the change in Hex Format. 
Yes when you see in resources, you find xaml and you cant edit it. so just open file with hex editor and do changes !

  • Thanks 1

Share this post


Link to post
whoknows

The XAML compiled to BAML @ compiled exe. What u c @ dnSpy is the decompiled BAML to XAML. 

ref1

ref2

Share this post


Link to post
Benjamin
1 hour ago, Black Hat Anonymous said:

 A better way to do this is - do all the change in Hex Format. 
Yes when you see in resources, you find xaml and you cant edit it. so just open file with hex editor and do changes !

This is what I am doing at present but I wanted to know if there was a way to do so without doing direct hex edits.

@Kurapica The files containing the XAML simply refuse to run correctly (the same way exceptions are thrown if you make a random edit in the file and try to run it). So from this I could clearly understand that the saving and compilation after I make the changes is what is causing the issue. If I make the same changes with a hex editor it runs fine though.

 

20 minutes ago, whoknows said:

What u c @ dnSpy is the decompiled BAML to XAML.

I understand that. So that was why I asked how the XAML could be edited and saved back, since we see the XAML in the DnSpy decompilation window.

Share this post


Link to post
whoknows
Posted (edited)

drop an example assembly to play, I have to try it by 2016.

Edited by whoknows (see edit history)

Share this post


Link to post
Benjamin
2 hours ago, whoknows said:

drop an example assembly to play, I have to try it by 2016.

As @Black Hat Anonymous suggested, pretty much most of the executables containing XAML fail to run properly after editing in DnSpy (unless we do a hex edit of the resources).

Unfortunately I believe that I am not allowed to share my actual target file here as it is commercial. :(

Share this post


Link to post
whoknows

the scenario is @

A-target app

B-a test app by you

 

1-get the XAML by DNSPY or Reflector

2-@B use the XAML make any modification and compile the project

3-extract the BAML from @B

4-replace the namspace then add it @A

tested&working

 

a demonstration 

https://workupload.com/file/RHt7JeCJ
pass : b-at-s.info
format:RAR5

 

  • Like 2
  • Thanks 1

Share this post


Link to post
BlackHat

Exactly what i do now a days. 

Open your target app. find the xaml code in resource and save it... 

 

then create a wpf application into the visual studio and create a new test or dummy project.  insert the saved xaml code into your project that you created. 

modify all the changes into the xaml that you edit into the wpf app. then compile the project. 

now open your project in the dnspy and go to resource and you will see xaml resources as baml. dont save it directly. 

 

save it with raw save baml resources. 

 

now again go to your target app and then delete your resoueces which you wanna change and create a new system.io resource and select tghe raw baml file which you saved using dnspy from the test or demo wpf project.

 

now give the same name into the target and boom ///

 

it will work good. i tested it. 

  • Like 1

Share this post


Link to post
gagmeng
On 8/24/2019 at 11:21 PM, whoknows said:

the scenario is @

A-target app

B-a test app by you

 

1-get the XAML by DNSPY or Reflector

2-@B use the XAML make any modification and compile the project

3-extract the BAML from @B

4-replace the namspace then add it @A

tested&working

 

a demonstration 


https://workupload.com/file/RHt7JeCJ
pass : b-at-s.info
format:RAR5

 

which screen recorder too you used? Thanks

Share this post


Link to post
whoknows
Posted (edited)

Camtasia Studio v6.0.3.928_x64 developed @ 2009

best4me

Fastone.Capture (but u cant add captions) 

ZDSoft.ScreenRecorder 

 

-EDIT-

@Benjamin 12JUN

https://github.com/0xd4d/dnSpy/issues/171

spacer.png

Edited by whoknows (see edit history)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...