當前位置: 首頁>>代碼示例>>C++>>正文


C++ AddVectoredExceptionHandler函數代碼示例

本文整理匯總了C++中AddVectoredExceptionHandler函數的典型用法代碼示例。如果您正苦於以下問題:C++ AddVectoredExceptionHandler函數的具體用法?C++ AddVectoredExceptionHandler怎麽用?C++ AddVectoredExceptionHandler使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了AddVectoredExceptionHandler函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: RemoveVectoredExceptionHandler

PVOID dyn_AddVectoredExceptionHandler
(ULONG isFirst, PVECTORED_EXCEPTION_HANDLER handler)
{
   PVOID handlerHandle;
   if (isFirst) {
      RemoveVectoredExceptionHandler(fake_AVEH_handle);
      handlerHandle = AddVectoredExceptionHandler(isFirst,handler);
      fake_AVEH_handle = AddVectoredExceptionHandler
         (isFirst,(PVECTORED_EXCEPTION_HANDLER)dyn_trapHandler);
   }
   else {
      handlerHandle = AddVectoredExceptionHandler(isFirst,handler);
   }
   return handlerHandle;
}
開發者ID:aiaxun,項目名稱:patharmor,代碼行數:15,代碼來源:RTwinnt.c

示例2: ut_sigaction

/*
 * ut_sigaction -- a sigaction that cannot return < 0
 */
int
ut_sigaction(const char *file, int line, const char *func,
		int signum, struct sigaction *act, struct sigaction *oldact)
{
#ifndef _WIN32
	int retval = sigaction(signum, act, oldact);
	if (retval != 0)
		ut_fatal(file, line, func, "!sigaction: %s", strsignal(signum));
	return retval;
#else
	if (signum == SIGABRT) {
		DWORD dwMode = GetErrorMode();
		SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX |
			SEM_FAILCRITICALERRORS);
		_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
	}
	if (signum == SIGSEGV) {
		Sa_handler = act->sa_handler;
		Signum = signum;
		AddVectoredExceptionHandler(0, exception_handler);
	}

	_crt_signal_t retval = signal(signum, act->sa_handler);
	if (retval == SIG_ERR)
		ut_fatal(file, line, func, "!signal: %d", signum);

	if (oldact != NULL) {
		oldact->sa_handler = retval;
	}
	return 0;
#endif
}
開發者ID:JLLLinn,項目名稱:nvml,代碼行數:35,代碼來源:ut_signal.c

示例3: main

int main(int argc, char *argv[])
{
	if (argc != 2 && argc != 3) {
		fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
		return 1;
	}

	if (argc == 3)
		fault_count_fname = argv[2];
	else
		fault_count_fname = "fault_cnt.out";

	so_init_loader();

	if (AddVectoredExceptionHandler(HANDLER_CALL_FIRST,
					(PVECTORED_EXCEPTION_HANDLER)test_segv_handler) < 0) {
		fprintf(stderr, "cannot set signal handler\n");
		return 1;
	}

	so_execute(argv[1], argv+1);

	// Shouldn't reach here
	return 1;
}
開發者ID:murarugeorgec,項目名稱:so-assignments,代碼行數:25,代碼來源:run_test.c

示例4: DYNINSTinitializeTrapHandler

/* registers the trap handler by calling AddVectoredExceptionHandler
 */
int DYNINSTinitializeTrapHandler()
{
   fake_AVEH_handle = AddVectoredExceptionHandler
      (RT_TRUE, (PVECTORED_EXCEPTION_HANDLER)dyn_trapHandler);
   rtdebug_printf("RTLIB: added vectored trap handler\n");
   return fake_AVEH_handle != 0;
}
開發者ID:aiaxun,項目名稱:patharmor,代碼行數:9,代碼來源:RTwinnt.c

示例5: SetSignalHandler

void SetSignalHandler(const FuzzingOptions& Options) {
  HandlerOpt = &Options;

  if (Options.UnitTimeoutSec > 0)
    Timer.SetTimer(Options.UnitTimeoutSec / 2 + 1);

  if (Options.HandleInt || Options.HandleTerm)
    if (!SetConsoleCtrlHandler(CtrlHandler, TRUE)) {
      DWORD LastError = GetLastError();
      Printf("libFuzzer: SetConsoleCtrlHandler failed (Error code: %lu).\n",
        LastError);
      exit(1);
    }

  if (Options.HandleSegv || Options.HandleBus || Options.HandleIll ||
      Options.HandleFpe)
    if (!AddVectoredExceptionHandler(1, ExceptionHandler)) {
      Printf("libFuzzer: AddVectoredExceptionHandler failed.\n");
      exit(1);
    }

  if (Options.HandleAbrt)
    if (SIG_ERR == signal(SIGABRT, CrashHandler)) {
      Printf("libFuzzer: signal failed with %d\n", errno);
      exit(1);
    }
}
開發者ID:anupam128,項目名稱:llvm,代碼行數:27,代碼來源:FuzzerUtilWindows.cpp

示例6: main

int main(int argc, char **argv) {
  std::set_new_handler([]() {
    errs() << "new: " << strerror(errno) << '\n';
    exit(1);
  });

  sys::PrintStackTraceOnErrorSignal(argv[0], true);
  PrettyStackTraceProgram _(argc, argv);

#ifdef _WIN32
  AddVectoredExceptionHandler(0, stackOverflow);
#endif

  cl::AddExtraVersionPrinter([](raw_ostream &os) {
    os << "Ayane (https://github.com/russellw/ayane):\n";
    os << "  Ayane version " version "\n";
#ifndef __OPTIMIZE__
    os << "  DEBUG build";
#else
    os << "  Optimized build";
#endif
#ifndef NDEBUG
    os << " with assertions";
#endif
    os << ".\n";
  });
  cl::ParseCommandLineOptions(argc, argv);

  for (auto filename : inputFilenames) {
    parsePython(filename);
    outs() << filename << '\n';
    outs().flush();
  }
  return 0;
}
開發者ID:russellw,項目名稱:ayane,代碼行數:35,代碼來源:main.cpp

示例7: HookInt3

    /// <summary>
    /// Perform int3 hook
    /// </summary>
    /// <returns>true on success</returns>
    bool HookInt3()
    {
        this->_newCode[0] = 0xCC;
        this->_origSize = sizeof( this->_newCode[0] );

        // Setup handler
        if (this->_vecHandler == nullptr)
            this->_vecHandler = AddVectoredExceptionHandler( 1, &DetourBase::VectoredHandler );

        if (!this->_vecHandler)
            return false;

        this->_breakpoints.insert( std::make_pair( this->_original, (DetourBase*)this ) );

        // Save original code
        memcpy( this->_origCode, this->_original, this->_origSize );

        // Write break instruction
        DWORD flOld = 0;
        VirtualProtect( this->_original, this->_origSize, PAGE_EXECUTE_READWRITE, &flOld );
        memcpy( this->_original, this->_newCode, this->_origSize );
        VirtualProtect( this->_original, this->_origSize, flOld, &flOld );

        WriteProcessMemory( GetCurrentProcess(), this->_original, this->_newCode, this->_origSize, NULL );

        return this->_hooked = TRUE;
    }
開發者ID:AnyMaster,項目名稱:Blackbone,代碼行數:31,代碼來源:LocalHook.hpp

示例8: DllMain

BOOL APIENTRY DllMain ( HMODULE hModule, DWORD  reason, LPVOID lpReserved ) {
    if ( reason == DLL_PROCESS_ATTACH ) {
        Offsets.Initialize();

        Engine.Initialize();

		CreateHackMenu();

        HMODULE aCI = GetModuleHandleA ( "libnp.dll" );
		
        if ( aCI != NULL ) {
            MessageBoxA ( NULL, "This Hack doesn't support this game version", "Game Version Not Supported", MB_OK | MB_ICONERROR );
            exit ( 1 );
        }
		aCI = GetModuleHandleA ( "teknomw3.dll" );
		if ( aCI != NULL ) {
            MessageBoxA ( NULL, "This Hack doesn't support this game version", "Game Version Not Supported", MB_OK | MB_ICONERROR );
            exit ( 1 );
        }
		
		MessageBoxA(NULL, "Hack sucesfully injected. Press INSERT or DELETE do show up the menu.\nIf it doesn't work... IDK what could be wwrong...", "Sucess", MB_OK);

        Engine.UiShowList = ( tUiShowList ) Hook.DetourFunction ( ( BYTE* ) Offsets.UIShowList_OFFS, ( BYTE* ) &hkUIShowList, 5 );
		
		AddVectoredExceptionHandler(1,pVectoredExceptionHandler); 
		*(DWORD*)Offsets.dwDVar = 0x0; //Set DVar to 0 so that an exception happens at 0x5A14F7
    }
    return TRUE;
}
開發者ID:vice655,項目名稱:c-knowledge,代碼行數:29,代碼來源:DllMain.cpp

示例9: c_to_factor_toplevel

void c_to_factor_toplevel(CELL quot)
{
	if(!AddVectoredExceptionHandler(0, (void*)exception_handler))
		fatal_error("AddVectoredExceptionHandler failed", 0);
	c_to_factor(quot);
	RemoveVectoredExceptionHandler((void*)exception_handler);
}
開發者ID:ehird,項目名稱:factor,代碼行數:7,代碼來源:os-windows-nt.c

示例10: assert

void CEeExecutor::AddExceptionHandler()
{
    assert(g_eeExecutor == nullptr);
    g_eeExecutor = this;

#if defined(_WIN32)
    m_handler = AddVectoredExceptionHandler(TRUE, &CEeExecutor::HandleException);
    assert(m_handler != NULL);
#elif defined(__ANDROID__)
    struct sigaction sigAction;
    sigAction.sa_handler	= nullptr;
    sigAction.sa_sigaction	= &HandleException;
    sigAction.sa_flags		= SA_SIGINFO;
    sigemptyset(&sigAction.sa_mask);
    int result = sigaction(SIGSEGV, &sigAction, nullptr);
    assert(result >= 0);
#elif defined(__APPLE__)
    kern_return_t result = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &m_port);
    assert(result == KERN_SUCCESS);

    m_handlerThread = std::thread([this] () {
        HandlerThreadProc();
    });

    result = mach_port_insert_right(mach_task_self(), m_port, m_port, MACH_MSG_TYPE_MAKE_SEND);
    assert(result == KERN_SUCCESS);

    result = thread_set_exception_ports(mach_thread_self(), EXC_MASK_BAD_ACCESS, m_port, EXCEPTION_STATE | MACH_EXCEPTION_CODES, STATE_FLAVOR);
    assert(result == KERN_SUCCESS);

    result = mach_port_mod_refs(mach_task_self(), m_port, MACH_PORT_RIGHT_SEND, -1);
    assert(result == KERN_SUCCESS);
#endif
}
開發者ID:SirNade,項目名稱:Play-,代碼行數:34,代碼來源:EeExecutor.cpp

示例11: main

int main(int argc, char **argv)
{
		int tid1 = 10, tid2 = 30;
		AddVectoredExceptionHandler(1, CustomExceptionHandler);
		
		if ((hThreads[0] = CreateThread(NULL, 0, thredFunc, &tid1, 0, NULL)) == NULL)
		{
			printf ("Thread1 cannot be created! Error: %d", GetLastError());
			return -1;
		}
		if ((hThreads[1] = CreateThread(NULL, 0, thredFunc, &tid2, 0, NULL)) == NULL)
		{
			printf ("Thread2 cannot be created! Error: %d", GetLastError());
			return -1;
		}
		printf("Threads created!\n");
		Sleep(6000);
/*		
		printf("Queueing user APCs...\n");
		QueueUserAPC(threadAPC, hThreads[0], tid1);
		QueueUserAPC(threadAPC, hThreads[1], tid2);
		Sleep(3000);
*/
		printf("Raising exception in all threads!\n");
		RaiseExceptionInThread(hThreads[0], throwCustomException);
		RaiseExceptionInThread(hThreads[1], throwCustomException);

		WaitForMultipleObjects(2, hThreads, TRUE, INFINITE);

		return 0;
}
開發者ID:alexsardan,項目名稱:MTCP-windows,代碼行數:31,代碼來源:main.c

示例12: swprintf

CPipeServer::CPipeServer(void)
{
	attached=FALSE;
	swprintf(datapipename, 256,L"\\\\.\\pipe\\cemonodc_pid%d", GetCurrentProcessId());
	//swprintf(eventpipename, 256,L"\\\\.\\pipe\\cemonodc_pid%d_events", GetCurrentProcessId());

	AddVectoredExceptionHandler(1, ErrorFilter);
}
開發者ID:Akheon23,項目名稱:cheat-engine,代碼行數:8,代碼來源:PipeServer.cpp

示例13: Interrupt_3

BOOL Interrupt_3()
{
	PVOID Handle = AddVectoredExceptionHandler(1, VectoredHandler);
	SwallowedException = TRUE;
	__debugbreak();
	RemoveVectoredExceptionHandler(Handle);
	return SwallowedException;
}
開發者ID:security-geeks,項目名稱:al-khaser,代碼行數:8,代碼來源:Interrupt_3.cpp

示例14: HwDetourAttach

BOOL HwDetourAttach( DWORD dwLineAddress, DWORD dwType, DWORD dwMonitorLen, DWORD dwExceptionHandler)
{
	HANDLE hThreadSnap;
	THREADENTRY32 te32;
	static BOOL bExceptionHandlerSet = FALSE;

	if (bExceptionHandlerSet == FALSE)
	{
		g_hVectorHandle = 
			AddVectoredExceptionHandler(1, (PVECTORED_EXCEPTION_HANDLER)VectoredHandler);
		bExceptionHandlerSet = !bExceptionHandlerSet;
	}


	BOOL bHaveFreeDbgBreak = FALSE;
	for(int i = 0; i < 4; i++)
	{
		if( TRUE == g_ExceptionInfo[i].bIsFree)
		{
			bHaveFreeDbgBreak = TRUE;
			break;
		}
	}
	if (bHaveFreeDbgBreak == FALSE)
	{
		return FALSE;
	}
	hThreadSnap =  CreateToolhelp32Snapshot(  TH32CS_SNAPTHREAD, NULL  );
	if(  hThreadSnap == INVALID_HANDLE_VALUE  ) 
		return FALSE; 
	te32.dwSize = sizeof(  THREADENTRY32  ); 
	if(  Thread32First(  hThreadSnap, &te32 ) )
	{
		do
		{  
			if(  te32.th32OwnerProcessID != GetCurrentProcessId() || 
				 te32.th32ThreadID		 == GetCurrentThreadId() )
				continue;

			InstDbgBreak2Thrd(  te32.th32ThreadID, dwLineAddress, dwType, dwMonitorLen );


		} while(  Thread32Next(  hThreadSnap, &te32 ) );
	}

	for(int i = 0; i < 4; i++)
	{
		if( TRUE == g_ExceptionInfo[i].bIsFree)
		{
			g_ExceptionInfo[i].bIsFree = FALSE;
			g_ExceptionInfo[i].dwLineAddr = dwLineAddress;
			g_ExceptionInfo[i].dwAccessType = dwType;
			g_ExceptionInfo[i].dwExceptionHanler = dwExceptionHandler;
			break;
		}
	}
	return TRUE;
}
開發者ID:danieljiang0415,項目名稱:gh,代碼行數:58,代碼來源:dbghook.cpp

示例15: _fork_override_cygwin_exceptions

int
_fork_override_cygwin_exceptions()
{
    HANDLE hr;
    hr = AddVectoredExceptionHandler(1, &_fork_cygwin_exception_handler);
    assert(hr != NULL);
    hr = AddVectoredContinueHandler(1, &_fork_cygwin_continue_handler);
    assert(hr != NULL);
}
開發者ID:talos-vulndev,項目名稱:afl-cygwin,代碼行數:9,代碼來源:winapi.c


注:本文中的AddVectoredExceptionHandler函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。