本文整理汇总了C++中IsDebuggerPresent函数的典型用法代码示例。如果您正苦于以下问题:C++ IsDebuggerPresent函数的具体用法?C++ IsDebuggerPresent怎么用?C++ IsDebuggerPresent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsDebuggerPresent函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ShouldBreak
bool ShouldBreak() {
return !!IsDebuggerPresent();
}
开发者ID:KGE-INC,项目名称:modplus,代码行数:3,代码来源:test.cpp
示例2: system_debugger_attached
bool system_debugger_attached( void )
{
return IsDebuggerPresent();
}
开发者ID:NocturnDragon,项目名称:foundation_lib,代码行数:4,代码来源:system.c
示例3: lock
VOID
IN_PROCESS_APPLICATION::ShutDownInternal()
{
DWORD dwThreadStatus = 0;
DWORD dwTimeout = m_pConfig->QueryShutdownTimeLimitInMS();
HANDLE handle = NULL;
WIN32_FIND_DATA fileData;
if (IsDebuggerPresent())
{
dwTimeout = INFINITE;
}
if (m_fShutdownCalledFromNative ||
m_status == APPLICATION_STATUS::STARTING ||
m_status == APPLICATION_STATUS::FAIL)
{
return;
}
{
SRWLockWrapper lock(m_srwLock);
if (m_fShutdownCalledFromNative ||
m_status == APPLICATION_STATUS::STARTING ||
m_status == APPLICATION_STATUS::FAIL)
{
return;
}
// We need to keep track of when both managed and native initiate shutdown
// to avoid AVs. If shutdown has already been initiated in managed, we don't want to call into
// managed. We still need to wait on main exiting no matter what. m_fShutdownCalledFromNative
// is used for detecting redundant calls and blocking more requests to OnExecuteRequestHandler.
m_fShutdownCalledFromNative = TRUE;
m_status = APPLICATION_STATUS::SHUTDOWN;
if (!m_fShutdownCalledFromManaged)
{
// We cannot call into managed if the dll is detaching from the process.
// Calling into managed code when the dll is detaching is strictly a bad idea,
// and usually results in an AV saying "The string binding is invalid"
if (!g_fProcessDetach)
{
m_ShutdownHandler(m_ShutdownHandlerContext);
m_ShutdownHandler = NULL;
}
}
// Release the lock before we wait on the thread to exit.
}
if (!m_fShutdownCalledFromManaged)
{
if (m_hThread != NULL &&
GetExitCodeThread(m_hThread, &dwThreadStatus) != 0 &&
dwThreadStatus == STILL_ACTIVE)
{
// wait for graceful shutdown, i.e., the exit of the background thread or timeout
if (WaitForSingleObject(m_hThread, dwTimeout) != WAIT_OBJECT_0)
{
// if the thread is still running, we need kill it first before exit to avoid AV
if (GetExitCodeThread(m_hThread, &dwThreadStatus) != 0 && dwThreadStatus == STILL_ACTIVE)
{
// Calling back into managed at this point is prone to have AVs
// Calling terminate thread here may be our best solution.
TerminateThread(m_hThread, STATUS_CONTROL_C_EXIT);
}
}
}
}
CloseHandle(m_hThread);
m_hThread = NULL;
s_Application = NULL;
CloseStdErrHandles();
if (m_pStdFile != NULL)
{
fflush(stdout);
fflush(stderr);
fclose(m_pStdFile);
}
if (m_hLogFileHandle != INVALID_HANDLE_VALUE)
{
m_Timer.CancelTimer();
CloseHandle(m_hLogFileHandle);
m_hLogFileHandle = INVALID_HANDLE_VALUE;
}
// delete empty log file
handle = FindFirstFile(m_struLogFilePath.QueryStr(), &fileData);
if (handle != INVALID_HANDLE_VALUE &&
fileData.nFileSizeHigh == 0 &&
fileData.nFileSizeLow == 0) // skip check of nFileSizeHigh
{
FindClose(handle);
// no need to check whether the deletion succeeds
//.........这里部分代码省略.........
开发者ID:akrisiun,项目名称:IISIntegration,代码行数:101,代码来源:inprocessapplication.cpp
示例4: vlc_exception_filter
/*****************************************************************************
* vlc_exception_filter: handles unhandled exceptions, like segfaults
*****************************************************************************/
LONG WINAPI vlc_exception_filter(struct _EXCEPTION_POINTERS *lpExceptionInfo)
{
if(IsDebuggerPresent())
{
//If a debugger is present, pass the exception to the debugger with EXCEPTION_CONTINUE_SEARCH
return EXCEPTION_CONTINUE_SEARCH;
}
else
{
fprintf( stderr, "unhandled vlc exception\n" );
wchar_t * wdir = (wchar_t *)malloc(sizeof(wchar_t)*MAX_PATH);
get_crashdump_path(wdir);
FILE * fd = _wfopen ( wdir, L"w, ccs=UTF-8" );
free((void *)wdir);
if( !fd )
{
fprintf( stderr, "\nerror while opening file" );
exit( 1 );
}
OSVERSIONINFO osvi;
ZeroMemory( &osvi, sizeof(OSVERSIONINFO) );
osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
GetVersionEx( &osvi );
fwprintf( fd, L"[version]\nOS=%d.%d.%d.%d.%s\nVLC=" VERSION_MESSAGE, osvi.dwMajorVersion,
osvi.dwMinorVersion,
osvi.dwBuildNumber,
osvi.dwPlatformId,
osvi.szCSDVersion);
const CONTEXT *const pContext = (const CONTEXT *)lpExceptionInfo->ContextRecord;
const EXCEPTION_RECORD *const pException = (const EXCEPTION_RECORD *)lpExceptionInfo->ExceptionRecord;
/*No nested exceptions for now*/
fwprintf( fd, L"\n\n[exceptions]\n%08x at %08x",pException->ExceptionCode,
pException->ExceptionAddress );
if( pException->NumberParameters > 0 )
{
unsigned int i;
for( i = 0; i < pException->NumberParameters; i++ )
fwprintf( fd, L" | %08x", pException->ExceptionInformation[i] );
}
fwprintf( fd, L"\n\n[context]\nEDI:%08x\nESI:%08x\n" \
"EBX:%08x\nEDX:%08x\nECX:%08x\nEAX:%08x\n" \
"EBP:%08x\nEIP:%08x\nESP:%08x\n",
pContext->Edi,pContext->Esi,pContext->Ebx,
pContext->Edx,pContext->Ecx,pContext->Eax,
pContext->Ebp,pContext->Eip,pContext->Esp );
fwprintf( fd, L"\n[stacktrace]\n#EIP|base|module\n" );
wchar_t module[ 256 ];
MEMORY_BASIC_INFORMATION mbi ;
VirtualQuery( (DWORD *)pContext->Eip, &mbi, sizeof( mbi ) ) ;
HINSTANCE hInstance = mbi.AllocationBase;
GetModuleFileName( hInstance, module, 256 ) ;
fwprintf( fd, L"%08x|%s\n", pContext->Eip, module );
DWORD pEbp = pContext->Ebp;
DWORD caller = *((DWORD*)pEbp + 1);
unsigned i_line = 0;
do
{
VirtualQuery( (DWORD *)caller, &mbi, sizeof( mbi ) ) ;
HINSTANCE hInstance = mbi.AllocationBase;
GetModuleFileName( hInstance, module, 256 ) ;
fwprintf( fd, L"%08x|%s\n", caller, module );
pEbp = *(DWORD*)pEbp ;
caller = *((DWORD*)pEbp + 1) ;
i_line++;
/*The last EBP points to NULL!*/
}while(caller && i_line< 100);
fclose( fd );
fflush( stderr );
exit( 1 );
}
}
开发者ID:cobr123,项目名称:qtVlc,代码行数:85,代码来源:winvlc.c
示例5: if
//.........这里部分代码省略.........
SetParent(hWnd, ghWnd);
bInFixStyle = false;
hParent = ghWnd;
}
DWORD curStyle = GetWindowLong(hWnd, GWL_STYLE);
if ((curStyle & CRITICAL_DCWND_STYLES) != (pVCon->mn_WndDCStyle & CRITICAL_DCWND_STYLES))
{
// DC window styles was changed externally!
bInFixStyle = true;
_ASSERTEX(((curStyle & CRITICAL_DCWND_STYLES) != (pVCon->mn_WndDCStyle & CRITICAL_DCWND_STYLES)));
SetWindowLongPtr(hWnd, GWL_STYLE, (LONG_PTR)(DWORD_PTR)pVCon->mn_WndDCStyle);
bInFixStyle = false;
}
}
if (messg >= WM_MOUSEFIRST && messg <= WM_MOUSELAST)
{
POINT pt = {LOWORD(lParam),HIWORD(lParam)};
MapWindowPoints(hWnd, hParent, &pt, 1);
lParam = MAKELONG(pt.x,pt.y);
}
result = gpConEmu->WndProc(hParent, messg, wParam, lParam);
}
break;
case WM_IME_NOTIFY:
break;
case WM_INPUTLANGCHANGE:
case WM_INPUTLANGCHANGEREQUEST:
{
#ifdef _DEBUG
if (IsDebuggerPresent())
{
WCHAR szMsg[128];
_wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"InChild %s(CP:%i, HKL:0x%08X)\n",
(messg == WM_INPUTLANGCHANGE) ? L"WM_INPUTLANGCHANGE" : L"WM_INPUTLANGCHANGEREQUEST",
(DWORD)wParam, (DWORD)lParam);
DEBUGSTRLANG(szMsg);
}
#endif
result = DefWindowProc(hWnd, messg, wParam, lParam);
} break;
#ifdef _DEBUG
case WM_WINDOWPOSCHANGING:
{
WINDOWPOS* pwp = (WINDOWPOS*)lParam;
result = DefWindowProc(hWnd, messg, wParam, lParam);
}
return result;
case WM_WINDOWPOSCHANGED:
{
WINDOWPOS* pwp = (WINDOWPOS*)lParam;
result = DefWindowProc(hWnd, messg, wParam, lParam);
}
break;
#endif
case WM_SETCURSOR:
{
gpConEmu->WndProc(hWnd, messg, wParam, lParam);
//if (!result)
// result = DefWindowProc(hWnd, messg, wParam, lParam);
}
开发者ID:havocbane,项目名称:ConEmu,代码行数:67,代码来源:VConChild.cpp
示例6: va_start
void CDynPatcher::Error(const char *File, const char *Func, int Line, bool IsCritical, char *Fmt, ...)
{
static char Buff[0x1000];
int len=0;
len+=_snprintf(&Buff[len],sizeof(Buff)-len-1,"[CDynPatcher] %serror",IsCritical?"critical":"");
if(File&&Func&&Line&&strlen(File)<MAX_PATH&&strlen(Func)<300)
{
len+=_snprintf(&Buff[len],sizeof(Buff)-len-1," at %s(%s:%i)",CSectionData::GetFileName(File),Func,Line);
}
len+=_snprintf(&Buff[len],sizeof(Buff)-len-1,":");
va_list marker;
if(!Fmt)
{
len+=_snprintf(&Buff[len],sizeof(Buff)-len-1,"(NO DESCRIPTION)\r\n");
}
else
{
va_start( marker, Fmt );
len+=_vsnprintf(&Buff[len],sizeof(Buff)-len-1, Fmt, marker );
}
len+=_snprintf(&Buff[len],sizeof(Buff)-len-1,"\r\n");
printf("%s",Buff);
if(IsCritical)
{
#ifdef WIN32
__asm{int 3};
if(!IsDebuggerPresent())
{
exit(0);
}
#else
exit(0);
#endif
}
}
void CDynPatcher::Message(const char *File, const char *Func, int Line, char *Fmt, ...)
{
static char Buff[0x1000];
int len=0;
len+=_snprintf(&Buff[len],sizeof(Buff)-len-1,"[CDynPatcher]");
if(File&&Func&&Line&&strlen(File)<MAX_PATH&&strlen(Func)<300)
{
len+=_snprintf(&Buff[len],sizeof(Buff)-len-1," at %s(%s:%i)",CSectionData::GetFileName(File),Func,Line);
}
len+=_snprintf(&Buff[len],sizeof(Buff)-len-1,":");
va_list marker;
if(!Fmt)
{
len+=_snprintf(&Buff[len],sizeof(Buff)-len-1,"(NO DESCRIPTION)\r\n");
}
else
{
va_start( marker, Fmt );
len+=_vsnprintf(&Buff[len],sizeof(Buff)-len-1, Fmt, marker );
}
len+=_snprintf(&Buff[len],sizeof(Buff)-len-1,"\r\n");
printf("%s",Buff);
}
bool CDynPatcher::Init(const char *LibName,bool ForceLoad)
{
if (!LibName)
{
szLibName = "<<===NO LIBRARY NAME===>>";
return false;
}
if(!LoadLib(LibName,ForceLoad))
{
DynErr(false,"Unable to load \"%s\"",LibName);
return false;
}
#ifdef WIN32
if(!ParseGenericDllData_PE())
{
DynErr(false,"Failed to parse \"%s\"",szLibName);
return false;
}
DynMsg("\"%s\" parsed",szLibName);
#else
FILE *fl = fopen(szLibName, "rb");
int LibSize;
void* LibBuf;
if (fl == NULL)
{
DynErr(false,"Failed to open '%s' for read\n", szLibName);
return false;
}
fseek(fl, 0, SEEK_END);
LibSize = ftell(fl);
fseek(fl, 0, SEEK_SET);
if (LibSize < 0)
LibSize = 0;
//.........这里部分代码省略.........
开发者ID:Chuvi-w,项目名称:DynamicPatcher,代码行数:101,代码来源:CDynPatcher.cpp
示例7: vlc_exception_filter
/*****************************************************************************
* vlc_exception_filter: handles unhandled exceptions, like segfaults
*****************************************************************************/
LONG WINAPI vlc_exception_filter(struct _EXCEPTION_POINTERS *lpExceptionInfo)
{
if(IsDebuggerPresent())
{
//If a debugger is present, pass the exception to the debugger
//with EXCEPTION_CONTINUE_SEARCH
return EXCEPTION_CONTINUE_SEARCH;
}
else
{
fprintf( stderr, "unhandled vlc exception\n" );
FILE * fd = _wfopen ( crashdump_path, L"w, ccs=UTF-8" );
if( !fd )
{
fprintf( stderr, "\nerror while opening file" );
exit( 1 );
}
OSVERSIONINFO osvi;
ZeroMemory( &osvi, sizeof(OSVERSIONINFO) );
osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
GetVersionEx( &osvi );
fwprintf( fd, L"[version]\nOS=%d.%d.%d.%d.%s\nVLC=" VERSION_MESSAGE,
osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber,
osvi.dwPlatformId, osvi.szCSDVersion);
const CONTEXT *const pContext = (const CONTEXT *)
lpExceptionInfo->ContextRecord;
const EXCEPTION_RECORD *const pException = (const EXCEPTION_RECORD *)
lpExceptionInfo->ExceptionRecord;
/* No nested exceptions for now */
fwprintf( fd, L"\n\n[exceptions]\n%08x at %px",
pException->ExceptionCode, pException->ExceptionAddress );
for( unsigned int i = 0; i < pException->NumberParameters; i++ )
fwprintf( fd, L" | %p", pException->ExceptionInformation[i] );
#ifdef _WIN64
fwprintf( fd, L"\n\n[context]\nRDI:%px\nRSI:%px\n" \
"RBX:%px\nRDX:%px\nRCX:%px\nRAX:%px\n" \
"RBP:%px\nRIP:%px\nRSP:%px\nR8:%px\n" \
"R9:%px\nR10:%px\nR11:%px\nR12:%px\n" \
"R13:%px\nR14:%px\nR15:%px\n",
pContext->Rdi,pContext->Rsi,pContext->Rbx,
pContext->Rdx,pContext->Rcx,pContext->Rax,
pContext->Rbp,pContext->Rip,pContext->Rsp,
pContext->R8,pContext->R9,pContext->R10,
pContext->R11,pContext->R12,pContext->R13,
pContext->R14,pContext->R15 );
#else
fwprintf( fd, L"\n\n[context]\nEDI:%px\nESI:%px\n" \
"EBX:%px\nEDX:%px\nECX:%px\nEAX:%px\n" \
"EBP:%px\nEIP:%px\nESP:%px\n",
pContext->Edi,pContext->Esi,pContext->Ebx,
pContext->Edx,pContext->Ecx,pContext->Eax,
pContext->Ebp,pContext->Eip,pContext->Esp );
#endif
fwprintf( fd, L"\n[stacktrace]\n#EIP|base|module\n" );
#ifdef _WIN64
LPCVOID caller = (LPCVOID)pContext->Rip;
LPVOID *pBase = (LPVOID*)pContext->Rbp;
#else
LPVOID *pBase = (LPVOID*)pContext->Ebp;
LPCVOID caller = (LPCVOID)pContext->Eip;
#endif
for( unsigned frame = 0; frame <= 100; frame++ )
{
MEMORY_BASIC_INFORMATION mbi;
wchar_t module[ 256 ];
VirtualQuery( caller, &mbi, sizeof( mbi ) ) ;
GetModuleFileName( mbi.AllocationBase, module, 256 );
fwprintf( fd, L"%p|%s\n", caller, module );
/*The last BP points to NULL!*/
caller = *(pBase + 1);
if( !caller )
break;
pBase = *pBase;
}
HANDLE hpid = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
FALSE, GetCurrentProcessId());
if (hpid) {
HMODULE mods[1024];
DWORD size;
if (EnumProcessModules(hpid, mods, sizeof(mods), &size)) {
fwprintf( fd, L"\n\n[modules]\n" );
for (unsigned int i = 0; i < size / sizeof(HMODULE); i++) {
wchar_t module[ 256 ];
GetModuleFileName(mods[i], module, 256);
fwprintf( fd, L"%p|%s\n", mods[i], module);
}
//.........这里部分代码省略.........
开发者ID:Aseeker,项目名称:vlc,代码行数:101,代码来源:winvlc.c
示例8: isDebuggerActive
bool isDebuggerActive() {
return IsDebuggerPresent() != 0;
}
开发者ID:17twenty,项目名称:Catch,代码行数:3,代码来源:catch_debugger.hpp
示例9: main
int main(int argc, char** argv)
{
gn_argc = argc; gp_argv = argv;
int iRc = 0;
HMODULE hConEmu = NULL;
wchar_t szErrInfo[200];
DWORD dwErr;
typedef int (__stdcall* ConsoleMain2_t)(BOOL abAlternative);
ConsoleMain2_t lfConsoleMain2;
#ifdef _DEBUG
HMODULE hConEmuHk = GetModuleHandle(WIN3264TEST(L"ConEmuHk.dll",L"ConEmuHk64.dll"));
_ASSERTE(hConEmuHk==NULL && "Hooks must not be loaded into ConEmuC[64].exe!");
#endif
#if defined(SHOW_STARTED_MSGBOX)
if (!IsDebuggerPresent())
{
wchar_t szTitle[100]; _wsprintf(szTitle, SKIPLEN(countof(szTitle)) WIN3264TEST(L"ConEmuC",L"ConEmuC64") L" Loaded (PID=%i)", GetCurrentProcessId());
const wchar_t* pszCmdLine = GetCommandLineW();
MessageBox(NULL,pszCmdLine,szTitle,0);
}
#endif
// Обязательно, иначе по CtrlC мы свалимся
SetConsoleCtrlHandler((PHANDLER_ROUTINE)HandlerRoutine, true);
#ifdef _DEBUG
UnitTests();
#endif
// Some command we can process internally
if (ProcessCommandLine(iRc, hConEmu))
{
// Done, exiting
goto wrap;
}
// Otherwise - do the full cycle
if (!hConEmu)
hConEmu = LoadLibrary(WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"));
dwErr = GetLastError();
if (!hConEmu)
{
_wsprintf(szErrInfo, SKIPLEN(countof(szErrInfo))
L"Can't load library \"%s\", ErrorCode=0x%08X\n",
WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"),
dwErr);
_wprintf(szErrInfo);
_ASSERTE(FALSE && "LoadLibrary failed");
iRc = CERR_CONEMUHK_NOTFOUND;
goto wrap;
}
// Загрузить функи из ConEmuHk
lfConsoleMain2 = (ConsoleMain2_t)GetProcAddress(hConEmu, "ConsoleMain2");
gfHandlerRoutine = (PHANDLER_ROUTINE)GetProcAddress(hConEmu, "HandlerRoutine");
if (!lfConsoleMain2 || !gfHandlerRoutine)
{
dwErr = GetLastError();
_wsprintf(szErrInfo, SKIPLEN(countof(szErrInfo))
L"Procedure \"%s\" not found in library \"%s\"",
lfConsoleMain2 ? L"HandlerRoutine" : L"ConsoleMain2",
WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"));
_wprintf(szErrInfo);
_ASSERTE(FALSE && "GetProcAddress failed");
FreeLibrary(hConEmu);
iRc = CERR_CONSOLEMAIN_NOTFOUND;
goto wrap;
}
// Main dll entry point for Server & ComSpec
iRc = lfConsoleMain2(0/*WorkMode*/);
// Exiting
gfHandlerRoutine = NULL;
//FreeLibrary(hConEmu); -- Shutdown Server/Comspec уже выполнен
wrap:
//-- bottle neck: relatively long deinitialization
ExitProcess(iRc);
return iRc;
}
开发者ID:jslilly,项目名称:ConEmu,代码行数:84,代码来源:ConEmuC.cpp
示例10: main
//.........这里部分代码省略.........
if (iscore && (optind < argc-1)) {
printf("Note: command line arguments are ignored when loading core\n");
}
get_winver(0);
cygwin_conv_to_full_posix_path(argv[0], linexec_exe);
if ((len = strlen(chroot_path)) > 0) {
/* cygwin_conv_to_full_posix_path seems to convert '.' to '/path/.', so
strip the trailing period */
if ('.' == chroot_path[len-1]) {
len--;
chroot_path[len] = '\0';
}
if (0 != strncmp(linexec_exe, chroot_path, len)) {
char *msg = "Linexec.exe is not in the chroot()ed filesystem";
log_warning(LOG_LINEXEC_MISC, msg);
linexec_exe[0] = '\0';
} else {
if ('/' == chroot_path[len-1]) {
len--;
}
my_print("[linexec_exe]+++ %s\n", linexec_exe);
memmove(linexec_exe, linexec_exe+len, strlen(linexec_exe)-len+1);
my_print("[linexec_exe]--- %s\n", linexec_exe);
}
}
// printf("linexec_exe is (%s), chroot is (%s)\n", linexec_exe, chroot_path);
dlfork(FORK_RELOAD);
/*
* Note that the core is loaded before ASM_DISPATCH_SYSCALL. This is because
* you probably aren't actaully be running under LINE when loading a coredump
*/
if (iscore) {
loadcore(argv[optind]);
return -1;
}
log_debug(LOG_LINEXEC_MISC, "Running %s", argv[optind]);
/*
* Tell LINE about the Linexec syscall handler.
*/
#ifndef __DEBUG__
if (lineDebugger && !IsDebuggerPresent()) {
printf("LINE debugger not detected. Refusing to continue.\n");
return -1;
}
ASM_DISPATCH_SYSCALL;
#endif
pInfo.lineDebugger = lineDebugger;
if (isroot) {
pInfo.root_pid = getpid();
}
nso_setup(linexec_exe);
if (mmap_setup() < 0) {
//printf("\n[Press ENTER to exit...]\n");
//getchar();
return -1;
}
binfmt_setup();
ASM_SAVE_ESP;
//printf("optind = %d\n", optind);
//for( index = 0; index < argc; index++ )
// printf("argv[%d] = %s\n", index, argv[index]);
/* start the executable */
if (optind >= argc-1) {
char *fake_argv[optind];
fake_argv[0] = argv[optind];
fake_argv[1] = NULL;
ret = do_exec(argv[optind], fake_argv, envp);
} else {
ret = do_exec(argv[optind], &argv[optind], envp);
}
printf("linexec: error running %s: %d\n", argv[optind], ret);
if (isroot) {
//printf("\n[Press ENTER to exit...]\n");
//getchar();
}
return ret;
}
开发者ID:hackpascal,项目名称:line-is-not-emulator,代码行数:101,代码来源:linexec.c
示例11: main
void __cdecl main(int argc, char **argv)
{
HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
int running = 1;
#ifdef WIN32
if (IsDebuggerPresent())
{
// turn on floating-point exceptions
unsigned int prev;
_clearfp();
_controlfp_s(&prev, 0, _EM_ZERODIVIDE|_EM_INVALID);
}
#endif
// check the correct BASS was loaded
if (HIWORD(BASS_GetVersion()) != BASSVERSION)
{
fprintf(stderr, "An incorrect version of BASS.DLL was loaded");
return;
}
// set the window title
SetConsoleTitle(TEXT(title_text));
// set the console buffer size
static const COORD bufferSize = { 80, 50 };
SetConsoleScreenBufferSize(hOut, bufferSize);
// set the console window size
static const SMALL_RECT windowSize = { 0, 0, 79, 49 };
SetConsoleWindowInfo(hOut, TRUE, &windowSize);
// clear the window
Clear(hOut);
// hide the cursor
static const CONSOLE_CURSOR_INFO cursorInfo = { 100, FALSE };
SetConsoleCursorInfo(hOut, &cursorInfo);
// set input mode
SetConsoleMode(hIn, 0);
// 10ms update period
const DWORD STREAM_UPDATE_PERIOD = 10;
BASS_SetConfig(BASS_CONFIG_UPDATEPERIOD, STREAM_UPDATE_PERIOD);
// initialize BASS sound library
const DWORD STREAM_FREQUENCY = 48000;
if (!BASS_Init(-1, STREAM_FREQUENCY, BASS_DEVICE_LATENCY, 0, NULL))
Error("Can't initialize device");
// get device info
BASS_GetInfo(&info);
// if the device's output rate is unknown default to stream frequency
if (!info.freq) info.freq = STREAM_FREQUENCY;
// debug print info
DebugPrint("frequency: %d (min %d, max %d)\n", info.freq, info.minrate, info.maxrate);
DebugPrint("device latency: %dms\n", info.latency);
DebugPrint("device minbuf: %dms\n", info.minbuf);
DebugPrint("ds version: %d (effects %s)\n", info.dsver, info.dsver < 8 ? "disabled" : "enabled");
// default buffer size = update period + 'minbuf' + 1ms extra margin
BASS_SetConfig(BASS_CONFIG_BUFFER, STREAM_UPDATE_PERIOD + info.minbuf + 1);
DebugPrint("using a %dms buffer\r", BASS_GetConfig(BASS_CONFIG_BUFFER));
// create a stream, stereo so that effects sound nice
stream = BASS_StreamCreate(info.freq, 2, BASS_SAMPLE_FLOAT, (STREAMPROC*)WriteStream, 0);
// set channel to apply effects
fx_channel = stream;
#ifdef BANDLIMITED_SAWTOOTH
// initialize bandlimited sawtooth tables
InitSawtooth();
#endif
// initialize waves
InitWave();
// enable the first oscillator
osc_config[0].enable = true;
// reset all controllers
Control::ResetAll();
// start playing the audio stream
BASS_ChannelPlay(stream, FALSE);
// get the number of midi devices
UINT midiInDevs = Midi::Input::GetNumDevices();
DebugPrint("MIDI input devices: %d\n", midiInDevs);
// print device names
for (UINT i = 0; i < midiInDevs; ++i)
{
MIDIINCAPS midiInCaps;
//.........这里部分代码省略.........
开发者ID:eriser,项目名称:mini-synth-1,代码行数:101,代码来源:synth.cpp
示例12: wxRadioBox
void LogConfigWindow::CreateGUIControls()
{
// Verbosity
wxArrayString wxLevels, wxLevelsUse;
wxLevels.Add(_("Notice"));
wxLevels.Add(_("Error"));
wxLevels.Add(_("Warning"));
wxLevels.Add(_("Info"));
wxLevels.Add(_("Debug"));
for (int i = 0; i < MAX_LOGLEVEL; ++i)
wxLevelsUse.Add(wxLevels[i]);
m_verbosity = new wxRadioBox(this, wxID_ANY, _("Verbosity"),
wxDefaultPosition, wxDefaultSize, wxLevelsUse, 0, wxRA_SPECIFY_ROWS);
m_verbosity->Bind(wxEVT_RADIOBOX, &LogConfigWindow::OnVerbosityChange, this);
// Options
m_writeFileCB = new wxCheckBox(this, wxID_ANY, _("Write to File"));
m_writeFileCB->Bind(wxEVT_CHECKBOX, &LogConfigWindow::OnWriteFileChecked, this);
m_writeConsoleCB = new wxCheckBox(this, wxID_ANY, _("Write to Console"));
m_writeConsoleCB->Bind(wxEVT_CHECKBOX, &LogConfigWindow::OnWriteConsoleChecked, this);
m_writeWindowCB = new wxCheckBox(this, wxID_ANY, _("Write to Window"));
m_writeWindowCB->Bind(wxEVT_CHECKBOX, &LogConfigWindow::OnWriteWindowChecked, this);
m_writeDebuggerCB = nullptr;
#ifdef _MSC_VER
if (IsDebuggerPresent())
{
m_writeDebuggerCB = new wxCheckBox(this, wxID_ANY, _("Write to Debugger"));
m_writeDebuggerCB->Bind(wxEVT_CHECKBOX, &LogConfigWindow::OnWriteDebuggerChecked, this);
}
#endif
wxButton *btn_toggle_all = new wxButton(this, wxID_ANY, _("Toggle All Log Types"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
btn_toggle_all->Bind(wxEVT_BUTTON, &LogConfigWindow::OnToggleAll, this);
m_checks = new wxCheckListBox(this, wxID_ANY);
m_checks->Bind(wxEVT_CHECKLISTBOX, &LogConfigWindow::OnLogCheck, this);
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
m_checks->Append(StrToWxStr(m_LogManager->GetFullName((LogTypes::LOG_TYPE)i)));
// Sizers
wxStaticBoxSizer* sbOutputs = new wxStaticBoxSizer(wxVERTICAL, this, _("Logger Outputs"));
sbOutputs->Add(m_writeFileCB, 0, wxDOWN, 1);
sbOutputs->Add(m_writeConsoleCB, 0, wxDOWN, 1);
#ifdef _MSC_VER
if (m_writeDebuggerCB)
{
sbOutputs->Add(m_writeWindowCB, 0, wxDOWN, 1);
sbOutputs->Add(m_writeDebuggerCB, 0);
}
else
#endif
{
sbOutputs->Add(m_writeWindowCB, 0);
}
wxStaticBoxSizer* sbLogTypes = new wxStaticBoxSizer(wxVERTICAL, this, _("Log Types"));
sbLogTypes->Add(m_checks, 1, wxEXPAND);
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
sMain->Add(m_verbosity, 0, wxEXPAND | wxLEFT | wxRIGHT, 5);
sMain->Add(sbOutputs, 0, wxEXPAND | wxLEFT | wxRIGHT, 5);
sMain->Add(btn_toggle_all, 0, wxEXPAND | wxLEFT | wxRIGHT, 5);
sMain->Add(sbLogTypes, 1, wxEXPAND | wxLEFT | wxRIGHT, 5);
SetSizer(sMain);
Layout();
}
开发者ID:crudelios,项目名称:dolphin,代码行数:67,代码来源:LogConfigWindow.cpp
示例13: main
int main(int argc, char** argv)
{
int iRc = 0;
HMODULE hConEmu;
char szErrInfo[512];
DWORD dwErr, dwOut;
typedef int (__stdcall* ConsoleMain2_t)(BOOL abAlternative);
ConsoleMain2_t lfConsoleMain2;
#if defined(SHOW_STARTED_MSGBOX)
if (!IsDebuggerPresent())
{
wchar_t szTitle[100]; _wsprintf(szTitle, SKIPLEN(countof(szTitle)) WIN3264TEST(L"ConEmuC",L"ConEmuC64") L" Loaded (PID=%i)", GetCurrentProcessId());
const wchar_t* pszCmdLine = GetCommandLineW();
MessageBox(NULL,pszCmdLine,szTitle,0);
}
#endif
// Обязательно, иначе по CtrlC мы свалимся
SetConsoleCtrlHandler((PHANDLER_ROUTINE)HandlerRoutine, true);
#ifdef _DEBUG
UnitTests();
#endif
hConEmu = LoadLibrary(WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"));
dwErr = GetLastError();
if (!hConEmu)
{
_wsprintfA(szErrInfo, SKIPLEN(countof(szErrInfo))
"Can't load library \"%s\", ErrorCode=0x%08X\n",
WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"),
dwErr);
WriteConsoleA(GetStdHandle(STD_ERROR_HANDLE), szErrInfo, lstrlenA(szErrInfo), &dwOut, NULL);
return CERR_CONEMUHK_NOTFOUND;
}
// Загрузить функи из ConEmuHk
lfConsoleMain2 = (ConsoleMain2_t)GetProcAddress(hConEmu, "ConsoleMain2");
gfHandlerRoutine = (PHANDLER_ROUTINE)GetProcAddress(hConEmu, "HandlerRoutine");
if (!lfConsoleMain2 || !gfHandlerRoutine)
{
dwErr = GetLastError();
_wsprintfA(szErrInfo, SKIPLEN(countof(szErrInfo))
"Procedure \"%s\" not found in library \"%s\"",
lfConsoleMain2 ? "HandlerRoutine" : "ConsoleMain2",
WIN3264TEST(L"ConEmuCD.dll",L"ConEmuCD64.dll"));
WriteConsoleW(GetStdHandle(STD_ERROR_HANDLE), szErrInfo, lstrlenA(szErrInfo), &dwOut, NULL);
FreeLibrary(hConEmu);
return CERR_CONSOLEMAIN_NOTFOUND;
}
// Main dll entry point for Server & ComSpec
iRc = lfConsoleMain2(0/*WorkMode*/);
// Exiting
gfHandlerRoutine = NULL;
//FreeLibrary(hConEmu); -- Shutdown Server/Comspec уже выполнен
ExitProcess(iRc);
return iRc;
}
开发者ID:mirror,项目名称:conemu,代码行数:63,代码来源:ConEmuC.cpp
示例14: init
static void init()
{
bool error = true;
HANDLE hMapping = OpenFileMapping(FILE_MAP_READ,FALSE,_T("__kkapture_parameter_block"));
if(hMapping == 0) // no parameter block available.
return;
InitializeCriticalSection(&shuttingDown);
// initialize params with all zero (ahem)
initLog();
printLog("main: initializing...\n");
memset(¶ms,0,sizeof(params));
// get file mapping containing capturing info
ParameterBlock *block = (ParameterBlock *) MapViewOfFile(hMapping,FILE_MAP_READ,0,0,sizeof(ParameterBlock));
if(block)
{
// correct version
if(block->VersionTag == PARAMVERSION)
{
memcpy(¶ms,block,sizeof(params));
error = false;
}
UnmapViewOfFile(block);
}
CloseHandle(hMapping);
// if kkapture is being debugged, wait for the user to attach the debugger to this process
if(params.IsDebugged)
{
// create message window
HWND waiting = CreateWindowEx(0,"STATIC",
"Please attach debugger now.",WS_POPUP|WS_DLGFRAME|SS_CENTER|SS_CENTERIMAGE,0,0,240,50,0,0,
GetModuleHandle(0),0);
SendMessage(waiting,WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT),TRUE);
// center it
RECT rcWork,rcDlg;
SystemParametersInfo(SPI_GETWORKAREA,0,&rcWork,0);
GetWindowRect(waiting,&rcDlg);
SetWindowPos(waiting,0,(rcWork.left+rcWork.right-rcDlg.right+rcDlg.left)/2,
(rcWork.top+rcWork.bottom-rcDlg.bottom+rcDlg.top)/2,-1,-1,SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
// show it and wait for user to attach debugger
ShowWindow(waiting,SW_SHOW);
while(!IsDebuggerPresent())
{
MSG msg;
while(PeekMessage(&msg,0,0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Sleep(10);
}
// user has attached the debugger, bring window to foreground then destroy it
SetForegroundWindow(waiting);
ShowWindow(waiting,SW_HIDE);
MessageBox(waiting,"Debugger attached, set any breakpoints etc. you need to and press OK.","kkapture",
MB_ICONINFORMATION|MB_OK);
DestroyWindow(waiting);
}
// rest of initialization code
initTiming(true);
initVideo();
initSound();
initProcessIntercept();
printLog("main: all main components initialized.\n");
if(error)
{
printLog("main: couldn't access parameter block or wrong version\n");
frameRateScaled = 1000;
frameRateDenom = 100;
encoder = new DummyVideoEncoder;
}
else
{
printLog("main: reading parameter block...\n");
frameRateScaled = params.FrameRateNum;
frameRateDenom = params.FrameRateDenom;
encoder = 0;
}
// install our hook so we get notified of process exit (hopefully)
HookFunction(&Real_ExitProcess, Mine_ExitProcess);
hHookThread = (HANDLE) _beginthread(HookThreadProc,0,0);
//.........这里部分代码省略.........
开发者ID:TinkerWorX,项目名称:kkapture,代码行数:101,代码来源:main.cpp
示例15: __declspec
extern "C" __declspec (dllexport) inline BOOL IsDebuggerAttached()
{
BOOL remoteDebugger;
CheckRemoteDebuggerPresent(GetCurrentProcess(), &remoteDebugger);
return IsDebuggerPresent() || remoteDebugger;
}
开发者ID:JoshuaKennedy,项目名称:project-magic,代码行数:6,代码来源:DebugAPI.cpp
示例16: main
int main(int argc, char* argv[])
{
// Enable memory leak checks and heap validation.
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);
_CrtSetBreakAlloc(-1);
int exitCode = EXIT_SUCCESS;
// Create the memory debugger.
PMemoryDebugger::create();
PActivity* activity = PNEW(PActivity(argc, argv));
if (!activity->initialize())
{
PDELETE(activity);
return EXIT_FAILURE;
}
pMain(argc, argv);
// Set console title.
SetConsoleTitle(L"Console");
// Disable the close button of the console window.
HWND hConsoleWindow = GetConsoleWindow();
if (hConsoleWindow != NULL)
{
HMENU hMenu = GetSystemMenu(hConsoleWindow, 0);
if (hMenu != NULL)
{
DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
DrawMenuBar(hConsoleWindow);
}
}
PContext* context = activity->findContext(puint32(0));
PASSERT(context != P_NULL);
if (context == P_NULL)
{
exitCode = EXIT_FAILURE;
PDELETE(activity);
return exitCode;
}
PWin32Window window(context);
if (!window.create())
{
exitCode = EXIT_FAILURE;
PDELETE(activity);
return exitCode;
}
// Initialize the context.
context->setState(P_CONTEXT_STATE_UNINITIALIZED);
if (!context->initialize(context->properties()->m_windowWidth, context->properties()->m_windowHeight))
{
exitCode = EXIT_FAILURE;
}
else
{
if (!context->onInitialized())
{
context->setState(P_CONTEXT_STATE_ERROR);
}
else
{
PLOG_DEBUG("Starting program main loop");
context->setState(P_CONTEXT_STATE_RUNNING);
}
if (context->state() == P_CONTEXT_STATE_ERROR)
{
exitCode = EXIT_FAILURE;
}
// The mainloop of window.
window.run();
// Right before destroy the context, user might have
// something to do.
context->onDestroy();
}
context->destroy();
// Destroy native window.
window.destroy();
// Destroy the activity
activity->uninitialize();
PDELETE(activity);
// Destroy the memory debugger.
PMemoryDebugger::destroy();
// If debugger is present, a pause is required to keep the console output
// visible. Otherwise the pause is automatic.
if (IsDebuggerPresent())
{
//.........这里部分代码省略.........
开发者ID:alonecat06,项目名称:FutureInterface,代码行数:101,代码来源:main.cpp
示例17: main
int main(int argc, char* argv[])
{
int exitCode = EXIT_SUCCESS;
PActivity* activity = pNew(PActivity(argc, argv));
// Enable memory leak checks and heap validation.
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);
_CrtSetBreakAlloc(-1);
pMain(argc, argv);
// Set console title.
SetConsoleTitle(L"protoss debug console");
// Disable the close button of the console window.
HWND hConsoleWindow = GetConsoleWindow();
if (hConsoleWindow != NULL)
{
HMENU hMenu = GetSystemMenu(hConsoleWindow, 0);
if (hMenu != NULL)
{
DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
DrawMenuBar(hConsoleWindow);
}
}
PContext* context = activity->findContext(pUint32(0));
pAssert(context != P_NULL);
if (context == P_NULL)
{
exitCode = EXIT_FAILURE;
pDelete(activity);
return exitCode;
}
PWin32Window window(context);
if (!window.create())
{
exitCode = EXIT_FAILURE;
pDelete(activity);
return exitCode;
}
// Initialize the context.
// kzaPlatformSetInstanceHandle(context, GetModuleHandle(NULL));
context->setState(P_CONTEXT_STATE_UNINITIALIZED);
if (!context->initialize())
{
exitCode = EXIT_FAILURE;
}
if (!context->onInitialized())
{
context->setState(P_CONTEXT_STATE_ERROR);
}
else
{
pLogDebug("Starting program main loop");
context->setState(P_CONTEXT_STATE_RUNNING);
}
if (context->getState() == P_CONTEXT_STATE_ERROR)
{
exitCode = EXIT_FAILURE;
}
// The mainloop of window.
window.run();
// Right before destroy the context, user might have
// something to do.
context->onDestroy();
context->destroy();
// Destroy native window.
window.destroy();
// Destroy the activity
pDelete(activity);
// If debugger is present, a pause is required to keep the console output
// visible. Otherwise the pause is automatic.
if (IsDebuggerPresent())
{
system("pause");
}
return exitCode;
}
开发者ID:suyu0925,项目名称:backup,代码行数:92,代码来源:main.cpp
示例18: process_start
int process_start(char *name, char *part, process_info_t *p) {
HANDLE file = INVALID_HANDLE_VALUE;
HANDLE nul = INVALID_HANDLE_VALUE;
WCHAR path[MAX_PATH], filename[MAX_PATH];
WCHAR image[MAX_PATH + 1];
WCHAR args[MAX_PATH * 2];
STARTUPINFOW si;
PROCESS_INFORMATION pi;
DWORD result;
DWORD creation_flags;
if (GetTempPathW(sizeof(path) / sizeof(WCHAR), (WCHAR*)&path) == 0)
goto error;
if (GetTempFileNameW((WCHAR*)&path, L"uv", 0, (WCHAR*)&filename) == 0)
goto error;
file = CreateFileW((WCHAR*)filename,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE,
NULL);
if (file == INVALID_HANDLE_VALUE)
goto error;
if (!SetHandleInformation(file, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
goto error;
nul = CreateFileA("nul",
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (nul == INVALID_HANDLE_VALUE)
goto error;
if (!SetHandleInformation(nul, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
goto error;
result = GetModuleFileNameW(NULL, (WCHAR*)&image, sizeof(image) / sizeof(WCHAR));
if (result == 0
|
请发表评论