Debugging functions : How to debug an application without any debugger?

Using OutputDebugString

If the application has no debugger, the system debugger displays the string if the filter mask allows it. (Note that this function calls the DbgPrint function to display the string. For details on how the filter mask controls what the system debugger displays, see the DbgPrint function in the Windows Driver Kit on MSDN.) If the application has no debugger and the system debugger is not active, OutputDebugString does nothing.

If you use this function, it sends a string to the debugger for display.

Communicating with the debugger

The OutputDebugString function sends a string from the process being debugged to the debugger by generating an OUTPUT_DEBUG_STRING_EVENT debugging event. A process can detect whether it is being debugged by calling the IsDebuggerPresent function.

The DebugBreak function causes a breakpoint exception in the current process. A breakpoint is a location in a program where execution is stopped to allow the developer to examine the program's code, variables, and register values and, as necessary, to make changes, continue execution, or terminate execution.

The FatalExit function terminates the current process and gives execution control to the debugger, but unlike DebugBreak, it does not generate an exception. This function should only be used as a last resort, because it does not always free the process's memory or close its files.

Ok, till now we saw Outputdebugstring, debugbreak, fatalexit and isdebuggerpresent functions. So, where can i find the other debugging functions?

You can get it from the following :

Function

Description

CheckRemoteDebuggerPresent

Determines whether the specified process is being debugged.

ContinueDebugEvent

Enables a debugger to continue a thread that previously reported a debugging event.

DebugActiveProcess

Enables a debugger to attach to an active process and debug it.

DebugActiveProcessStop

Stops the debugger from debugging the specified process.

DebugBreak

Causes a breakpoint exception to occur in the current process.

DebugBreakProcess

Causes a breakpoint exception to occur in the specified process.

DebugSetProcessKillOnExit

Sets the action to be performed when the calling thread exits.

FatalExit

Transfers execution control to the debugger.

FlushInstructionCache

Flushes the instruction cache for the specified process.

GetThreadContext

Retrieves the context of the specified thread.

GetThreadSelectorEntry

Retrieves a descriptor table entry for the specified selector and thread.

IsDebuggerPresent

Determines whether the calling process is being debugged by a user-mode debugger.

OutputDebugString

Sends a string to the debugger for display.

ReadProcessMemory

Reads data from an area of memory in a specified process.

SetThreadContext

Sets the context for the specified thread.

WaitForDebugEvent

Waits for a debugging event to occur in a process being debugged.

Wow64GetThreadContext

Retrieves the context of the specified WOW64 thread.

Wow64SetThreadContext

Sets the context of the specified WOW64 thread.

WriteProcessMemory

Writes data to an area of memory in a specified process.