Red Gate forums :: View topic - Debugging Obsfuscated Code
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 6
SmartAssembly 6 forum

Debugging Obsfuscated Code

Search in SmartAssembly 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
JohnRedGater



Joined: 27 Jun 2011
Posts: 10

PostPosted: Mon Jul 18, 2011 12:17 pm    Post subject: Debugging Obsfuscated Code Reply with quote

Apparently there is a way of debugging obfuscated code using the generated PDB file and VS 2010, but I can't seem to find out how to do this. Is there any documentation on how to do this? If not, what are the steps to do this. I'm getting errors that only occur after the code has been obsfuscated.
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6678

PostPosted: Tue Jul 19, 2011 1:42 pm    Post subject: Reply with quote

Hi John,

It's pretty easy - just use the "generate debugging information" option when you build in SmartAssembly. That will make a PDB that contains information relevant to the source code before the assembly was processed with SA. Once you have the PDB, you can attach Visual Studio or your debugger of choice to the process when you run it, set breakpoints, and do the normal things you usually do to troubleshoot regular debug builds.
Back to top
View user's profile Send private message
JohnRedGater



Joined: 27 Jun 2011
Posts: 10

PostPosted: Tue Jul 19, 2011 4:39 pm    Post subject: Reply with quote

Thanks for the information. I'll try it. If I integrate the obfuscation project in the release mode of my build in VS 2010, I should be able to debug it, correct?
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6678

PostPosted: Tue Jul 19, 2011 4:54 pm    Post subject: Reply with quote

Yes, as long as you generate debugging information, you can debug any SA-protected assembly, provided you copy the PDB that SA produced with the output.
Back to top
View user's profile Send private message
JohnRedGater



Joined: 27 Jun 2011
Posts: 10

PostPosted: Thu Jul 21, 2011 5:36 am    Post subject: Reply with quote

I modified my VS2010 project file to perform the obfuscation which replaces the .exe and the PDB.

I am able to start in debugging mode, but I can't watch any of the variables. It displays "The name 'xxxx' does not exist in the current context.

Also, the debugging behavior is strange. I can't step into a line of code and stepping over a line sometimes brings up a source not available. Is there something I may be doing wrong.

I made sure not to obfuscate source code URLs in the resulting PDB file.
Here's the relevant modifications to my Visual Studio 2010 project file:

<UsingTask TaskName="SmartAssembly.MSBuild.Tasks.Build" AssemblyName=" SmartAssembly.MSBuild.Tasks, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57" />
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
<SmartAssembly.MSBuild.Tasks.Build ProjectFile="Tester.saproj" output="$(OutDir)$(TargetName)$(TargetExt)"/>
</Target>
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6678

PostPosted: Thu Jul 21, 2011 1:59 pm    Post subject: Reply with quote

Admittedly, there are some problems with the PDB generated by SmartAssembly. No workarounds at this point.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group