Benjamin Posted August 24, 2019 Share Posted August 24, 2019 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. Link to comment Share on other sites More sharing options...
Kurapica Posted August 24, 2019 Share Posted August 24, 2019 What error do you get after editing the XAML and running the application ? more details ? Link to comment Share on other sites More sharing options...
BlackHat Posted August 24, 2019 Share Posted August 24, 2019 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 ! 1 Link to comment Share on other sites More sharing options...
whoknows Posted August 24, 2019 Share Posted August 24, 2019 The XAML compiled to BAML @ compiled exe. What u c @ dnSpy is the decompiled BAML to XAML. ref1 ref2 Link to comment Share on other sites More sharing options...
Benjamin Posted August 24, 2019 Author Share Posted August 24, 2019 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. Link to comment Share on other sites More sharing options...
whoknows Posted August 24, 2019 Share Posted August 24, 2019 (edited) drop an example assembly to play, I have to try it by 2016. Edited August 24, 2019 by whoknows Link to comment Share on other sites More sharing options...
Benjamin Posted August 24, 2019 Author Share Posted August 24, 2019 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. Link to comment Share on other sites More sharing options...
whoknows Posted August 24, 2019 Share Posted August 24, 2019 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 2 1 Link to comment Share on other sites More sharing options...
BlackHat Posted August 24, 2019 Share Posted August 24, 2019 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. 1 Link to comment Share on other sites More sharing options...
gagmeng Posted August 26, 2019 Share Posted August 26, 2019 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 Link to comment Share on other sites More sharing options...
whoknows Posted August 26, 2019 Share Posted August 26, 2019 (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 Edited August 26, 2019 by whoknows Link to comment Share on other sites More sharing options...
whoknows Posted September 3, 2022 Share Posted September 3, 2022 Finally, edit BAML github.com/SoheilMV/dnlib.BAML Link to comment Share on other sites More sharing options...
whoknows Posted September 3, 2022 Share Posted September 3, 2022 edit_XAML_and_basics https://workupload.com/file/B2MjtjT2Caj Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now