[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

Vb.net create a module and deny the debug inside

Hi ,

I have created a module with many functions and I like to deny the debug inside these functions.

There is a way to deny  the debug in one module in particular ?
0
luca345
Asked:
luca345
1 Solution
 
KeldenCommented:
Can cannot prevent somebody to debug your module.
I think what you need is an obfuscator so debugging is very hard.
Something like Obfuscar.
0
 
nepaluzCommented:
Add this at the begining ofthe sub
If Debugger.IsAttached Then Exit Sub

Open in new window

substitute to exit function where appropriate
0
 
Jacques Bourgeois (James Burger)Commented:
Depends on what you intend by denying debug.

Kelden solution is not one used to prevent debugging, it is one used to prevent reverse engineering. And obfuscators usually works on all the application. My understanding is that you want to act only on specific methods. Also unless you have an Express version of Visual Studio, there is an obfuscator built-in, so no need to to look outside of the box.

nepaluz solution works very well, but you usually use that technique to implements special things when debugging, not to exclude debugging. The instruction Debugger.IsAttached instruction ends up being compiled. Personnally, I do not like to have in my release version code that will do nothing. I would rather like to do what you want in a way that involves only the debugger, and is not executed uselessly everything the method is called in release. Personal taste here.

However, if you want to exclude specific lines of code inside of a method, and not exclude the whole method, this is the way to go.

If you simply want to prevent the debugger from entering in the code, you can add the DebuggerStepThrough attribute at the beginning of the methods that you want the debugger to skip:

 <System.Diagnostics.DebuggerStepThrough()> _
Public Function YourFunction As Something

If for some reason you need to debug the method, just comment out the line temporarily:

'<System.Diagnostics.DebuggerStepThrough()> _
Public Function YourFunction As Something
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
luca345Author Commented:
Excellent , this solution is exactly what I need !!!
0
 
luca345Author Commented:
0
 
Jacques Bourgeois (James Burger)Commented:
Done. Look in the other thread.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now