Esempio n. 1
0
//启动工作线程
	bool WorkerThread::Run()
	{
		do
		{
			//初始化管道
			if (!CreateNotifyFds())
				break;
			//初始化事件处理回调
			if (!InitEventHandler())
				break;
			try
			{
				shared_ptr_thread_.reset(new std::thread([this]
				{	event_base_loop(pthread_event_base_, 0);}));
			}
			catch (...)
			{
				break;
			}
			
			return true;
		}
		while (0);
		
		return false;
	}
RemotePhotoTool::CameraControl::SourceDevice::EnterReleaseControl()
{
   std::shared_ptr<::RemoteReleaseControl> spRemoteReleaseControl =
      m_sourceDevice->get()->EnterReleaseControl();

   auto remoteReleaseControl =
      gcnew RemotePhotoTool::CameraControl::RemoteReleaseControl(spRemoteReleaseControl);

   remoteReleaseControl->InitEventHandler();

   return remoteReleaseControl;
}
bool WorkerThread::Run()
{
	do{
		if(!CreateNotifyFds())
			break;
		if(!InitEventHandler())
			break;
		try{
		shared_ptr_thread_.reset(new std::thread([this]
			{event_base_loop(pthread_event_base_, 0);}
		));
		}catch(...)
		{
			break;
		}
		LOG(TRACE)<<"workerhread "<<thread_id_<<" run success";
		return true;
	}while(0);
	LOG(ERROR)<<"workerhread "<<thread_id_<<"run failed";
	return false;
}
Esempio n. 4
0
bool WorkerThread::Run()
{
	do{
		if(!CreateNotifyFds())
			break;
		if(!InitEventHandler())
			break;
		try{
			shared_ptr_thread_.reset(new std::thread([this]
													 {
                                                         pthread_info=this;//thread_local variable
														 event_base_loop(pthread_event_base_, 0);
													 }
										 ));
		}catch(...)
		{
			break;
		}
		return true;
	}while(0);
	return false;
}
Esempio n. 5
0
BOOLEAN InitCommonVars()
/*++

Routine Description:

	全局变量的初始化工作


Arguments:

	None.


Return Value:

	TRUE if successful, and FALSE if not.


Author:

	Fypher

--*/
{
	RTL_PROCESS_MODULE_INFORMATION SysModInfo;

	// InitRegKeys();

	ULONG_PTR g_ulpAddr;

	PAGED_CODE();

	g_pProtected = NULL;

	if (!InitEventHandler())
		return FALSE;

	if (!InitWhiteBlackHashTable())
		return FALSE;

	g_ulpKiSystemCall64 = __readmsr(0xC0000082);

	for (g_ulpAddr = g_ulpKiSystemCall64; g_ulpAddr != g_ulpKiSystemCall64 + PAGE_SIZE / 2; ++g_ulpAddr)
	{
		if (!MmIsAddressValid((PVOID)g_ulpAddr) || !MmIsAddressValid((PVOID)(g_ulpAddr + 32 * sizeof(ULONG_PTR)))) {
			break;
		}

		if (*(PUSHORT)g_ulpAddr == 0x8d4c && *(PUSHORT)(g_ulpAddr + 7) == 0x8d4c) {
			g_ulpKeServiceDescriptorTable = g_ulpAddr + *(PULONG)(g_ulpAddr + 3) + 7;
			g_ulpKeServiceDescriptorTableShadow = (g_ulpAddr + 7) + *(PULONG)(g_ulpAddr + 7 + 3) + 7;

			if (MmIsAddressValid((PVOID)g_ulpKeServiceDescriptorTable)) {
				g_ulpKiServiceTable = *(PULONG_PTR)g_ulpKeServiceDescriptorTable;
				g_ulServiceNumber = *(PULONG)(g_ulpKeServiceDescriptorTable + 2 * sizeof(ULONG_PTR));
			}

			if (MmIsAddressValid((PVOID)g_ulpKeServiceDescriptorTableShadow)) {
				g_ulpW32pServiceTable = *(PULONG_PTR)(g_ulpKeServiceDescriptorTableShadow + 4 * sizeof(ULONG_PTR));
				g_ulShadowServiceNumber = *(PULONG)(g_ulpKeServiceDescriptorTableShadow + 6 * sizeof(ULONG_PTR));
			}
		}

		if ( *(PULONG_PTR)g_ulpAddr == *(PULONG_PTR)g_Signature ) {
			g_ulpHookPoint = g_ulpAddr;
			g_ulpJmpBackPoint = g_ulpAddr + 17;	//!!

			*(PULONG)(g_HookCodes + 1) = (ULONG)((ULONG_PTR)SuperDetour & 0xFFFFFFFF);
			*(PULONG)(g_HookCodes + 9) = (ULONG)(((ULONG_PTR)SuperDetour >> 32) & 0xFFFFFFFF);

			break;
		}

	}