예제 #1
0
void DynamicLinkLibrary::Open(const wchar_t *pwszPath){
	UniqueHandle<X_LibraryFreer> hDll;
	if(!hDll.Reset(reinterpret_cast<X_LibraryFreer::Handle>(::LoadLibraryW(pwszPath)))){
		DEBUG_THROW(SystemError, "LoadLibraryW"_rcs);
	}

	x_hDll = std::move(hDll);
}
예제 #2
0
	xDelegate(std::size_t uInitCount, std::size_t uMaxCount, const wchar_t *pwszName){
		ASSERT((uInitCount <= LONG_MAX) && (uMaxCount <= LONG_MAX));

		xm_hSemaphore.Reset(::CreateSemaphoreW(nullptr, (long)uInitCount, (long)uMaxCount, pwszName));
		if(!xm_hSemaphore){
			MCF_THROW(::GetLastError(), L"CreateSemaphoreW() 失败。");
		}
	}
예제 #3
0
bool Script::sendMessage(unique_long handle, Packet* pPacket){
	UniqueHandle h = handle;
	unique_char t = h.getType();
	switch(t){
		case UNIQUE_HANDLER_ACCEPT:
		case UNIQUE_HANDLER_CLIENT:{
			return Epoll::getInstance()->sendPacket(handle, pPacket);
		}
		case UNIQUE_HANDLER_SCRIPT:{
			return ScriptManager::getInstance()->sendPacket(handle, pPacket);
		}
		default:{
			fprintf(stderr, "--Script::sendMessage handler type is not valid\n");
			break;
		}
	}
	return false;
}
예제 #4
0
	static UniqueHandle OpenProc(std::size_t processId, DWORD access)
	{
		UniqueHandle hProc;
		CLIENT_ID cid;
		cid.UniqueProcess = processId;
		cid.UniqueThread = 0;
		OBJECT_ATTRIBUTES attribs;
		std::memset(&attribs, 0, sizeof(attribs));
		attribs.Length = sizeof(attribs);
		NtOpenProcessFunc ntOpen = GetNtDll().GetProcAddress<NtOpenProcessFunc>("NtOpenProcess");
		NTSTATUS errorCheck = ntOpen(hProc.Ptr(), access, &attribs, &cid);
		if (errorCheck == ERROR_SUCCESS)
		{
			return hProc;
		}
		else
		{
			Win32Exception::ThrowFromNtError(errorCheck);
		}
	}