4

With this code:

 Dim sf As New StackFrame(0, True)
 MessageBox.Show("Module: " & sf.GetFileName & " -Line: " & sf.GetFileLineNumber.ToString)

I can get Class and Line number where an Unhandled Exception occurred (in ApplicationEvents.vb, Sub MyApplication_UnhandledException(...) Handles Me.UnhandledException)

But if I obfuscate the code using EazFuscator (and maybe with any others) I lose the data: I get a NullString and 0 for line number.

Inserting the code:

<Assembly: Obfuscation(Feature:="encrypt symbol names with password XXXX", Exclude:=False)>

nothing changes. I can decompile the e.message, but the lines are lost. How can I get the line for an error in obfuscated code?

2 Answers 2

6

No it is not possible, and this is intended. Unhandled exceptions are a source of information for a potential attacker. Normally you should only ever apply obfuscation on a production build, after the first round of tests have passed. Don't try to debug an obfuscated assembly, it's obfuscated specifically to prevent debugging, among other things.

I should add that the real reason why you cannot get the information is that the debug symbols have been stripped from the assembly by the obfuscation process. That information should be shown as long as you have a valid PDB file for your assembly.

0

You can get the line numbers in your stack traces. They are stored in .pdb files. By default, Eazfuscator.NET sanitizes .pdb files by making them essentially empty. That's why you don't see the line numbers for obfuscated assemblies.

But you can instruct Eazfuscator.NET to process .pdb files so that the line numbers are preserved:

<Assembly: Obfuscation(Feature:="debug [relative_file_paths secure]", Exclude:=False)>

Once the directive is in place, you will see the lines in stack traces of an obfuscated assembly. Thanks to secure flag, the .pdb file remains encrypted and thus does not pose a security risk.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.