Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/exploits/CVE-2010-0232/common/common.h
Views: 11784
#ifndef _ESCALATE_COMMON_H1#define _ESCALATE_COMMON_H23/*! @brief When defined, debug output is enabled on Windows builds. */4//#define DEBUGTRACE 156#ifdef DEBUGTRACE7#include <stdio.h>8#include <stdarg.h>9#include <string.h>10#define dprintf(...) real_dprintf(__VA_ARGS__)11#else12#define dprintf(...) do{}while(0);13#endif1415/*! @brief Sets `dwResult` to the return value of `GetLastError()`, prints debug output, then does `break;` */16#define BREAK_ON_ERROR( str ) { dwResult = GetLastError(); dprintf( "%s. error=%d", str, dwResult ); break; }17/*! @brief Sets `dwResult` to `error`, prints debug output, then `break;` */18#define BREAK_WITH_ERROR( str, err ) { dwResult = err; dprintf( "%s. error=%d", str, dwResult ); break; }19/*! @brief Sets `dwResult` to the return value of `WASGetLastError()`, prints debug output, then does `break;` */20#define BREAK_ON_WSAERROR( str ) { dwResult = WSAGetLastError(); dprintf( "%s. error=%d", str, dwResult ); break; }21/*! @brief Sets `dwResult` to the return value of `GetLastError()`, prints debug output, then does `continue;` */22#define CONTINUE_ON_ERROR( str ) { dwResult = GetLastError(); dprintf( "%s. error=%d", str, dwResult ); continue; }2324/*! @brief Close a service handle if not already closed and set the handle to NULL. */25#define CLOSE_SERVICE_HANDLE( h ) if( h ) { CloseServiceHandle( h ); h = NULL; }26/*! @brief Close a handle if not already closed and set the handle to NULL. */27#define CLOSE_HANDLE( h ) if( h ) { DWORD dwHandleFlags; if(GetHandleInformation( h , &dwHandleFlags)) CloseHandle( h ); h = NULL; }2829#ifdef DEBUGTRACE30/*!31* @brief Output a debug string to the debug console.32* @details The function emits debug strings via `OutputDebugStringA`, hence all messages can be viewed33* using Visual Studio's _Output_ window, _DebugView_ from _SysInternals_, or _Windbg_.34*/35static void real_dprintf(char *format, ...) {36va_list args;37char buffer[1024];38va_start(args,format);39vsnprintf_s(buffer, sizeof(buffer), sizeof(buffer)-3, format,args);40strcat_s(buffer, sizeof(buffer), "\r\n");41OutputDebugStringA(buffer);42}43#endif4445#endif4647