Solved

Vb.net create a module and deny the debug inside

Posted on 2012-03-24
6
331 Views
Last Modified: 2012-03-25
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
Comment
Question by:luca345
6 Comments
 
LVL 2

Expert Comment

by:Kelden
ID: 37761292
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
 
LVL 17

Expert Comment

by:nepaluz
ID: 37761322
Add this at the begining ofthe sub
If Debugger.IsAttached Then Exit Sub

Open in new window

substitute to exit function where appropriate
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 37763606
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Closing Comment

by:luca345
ID: 37763641
Excellent , this solution is exactly what I need !!!
0
 

Author Comment

by:luca345
ID: 37763645
0
 
LVL 40
ID: 37764035
Done. Look in the other thread.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now