Example #1
0
// Constructor. Initializes to a handle.
ClsDC::ClsDC( HDC hDC )
{
	_ASSERT_VALID( hDC ); // Must be valid.

	// Clear handle.
	m_hDC = NULL;

	// Attach the handle.
	Attach( hDC );

	// Add us to the global list.
	global_dc_list.AddHead( this );
}
Example #2
0
CSysImageList::CSysImageList()
{
	SHFILEINFO ssfi;
	TCHAR windir[MAX_PATH];
	GetWindowsDirectory(windir, _countof(windir));  // MAX_PATH ok.
	HIMAGELIST hSystemImageList =
		(HIMAGELIST)SHGetFileInfo(
			windir,
			0,
			&ssfi, sizeof ssfi,
			SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
	Attach(hSystemImageList);
}
void Transmogrify::Spawn(float duration, int targetUUID)
{
	mDuration = duration;

	for (Explorer& e : Factory<Explorer>())
	{
		// Only affects clients who are not the target
		if (e.mNetworkID->mUUID == targetUUID && !e.mNetworkID->mHasAuthority)
		{
			Attach(&e);
		}
	}
}
Example #4
0
SOCKET Socket::CreateSocket(int af,int type, const std::string& protocol)
{
	struct protoent *p = NULL;
	SOCKET s;

#ifdef ENABLE_POOL
	m_socket_type = type;
	m_socket_protocol = protocol;
#endif
	if (protocol.size())
	{
		p = getprotobyname( protocol.c_str() );
		if (!p)
		{
			Handler().LogError(this, "getprotobyname", Errno, StrError(Errno), LOG_LEVEL_FATAL);
			SetCloseAndDelete();
#ifdef ENABLE_EXCEPTIONS
			throw Exception(std::string("getprotobyname() failed: ") + StrError(Errno));
#endif
			return INVALID_SOCKET;
		}
	}
	int protno = p ? p -> p_proto : 0;

	s = socket(af, type, protno);
	if (s == INVALID_SOCKET)
	{
		Handler().LogError(this, "socket", Errno, StrError(Errno), LOG_LEVEL_FATAL);
		SetCloseAndDelete();
#ifdef ENABLE_EXCEPTIONS
		throw Exception(std::string("socket() failed: ") + StrError(Errno));
#endif
		return INVALID_SOCKET;
	}
	Attach(s);
	OnOptions(af, type, protno, s);
	Attach(INVALID_SOCKET);
	return s;
}
Example #5
0
HRESULT Kernel::GetWaitChainInfo(WaitSnapshot& snapshot)
{
	_pCurrentSnapshot = &snapshot;
	HRESULT hr = Attach();
	if(SUCCEEDED(hr))
	{
		snapshot.Initialize(_KProcess, _OSProcessId);
		hr = ProcessHandles();
		hr = ProcessThreadWaitList();
	}
	_pCurrentSnapshot = NULL;
	return hr;
}
void LKWindowSurface::Create(Window& Wnd){
#ifdef WIN32
    HWND hWnd = Wnd.Handle();
    LKASSERT(hWnd);
    LKASSERT(::IsWindow(hWnd));

    if(!Attach(::GetDC(hWnd))) {
        LKASSERT(false);
    }
#else
    _pCanvas = new WindowCanvas(Wnd);
#endif
}
Example #7
0
// open the file
bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode)
{
    int flags = O_BINARY;

    switch ( mode )
    {
        case read:
            flags |= O_RDONLY;
            break;

        case write_append:
            if ( wxFile::Exists(szFileName) )
            {
                flags |= O_WRONLY | O_APPEND;
                break;
            }
            //else: fall through as write_append is the same as write if the
            //      file doesn't exist

        case write:
            flags |= O_WRONLY | O_CREAT | O_TRUNC;
            break;

        case write_excl:
            flags |= O_WRONLY | O_CREAT | O_EXCL;
            break;

        case read_write:
            flags |= O_RDWR;
            break;
    }

#ifdef __WINDOWS__
    // only read/write bits for "all" are supported by this function under
    // Windows, and VC++ 8 returns EINVAL if any other bits are used in
    // accessMode, so clear them as they have at best no effect anyhow
    accessMode &= wxS_IRUSR | wxS_IWUSR;
#endif // __WINDOWS__

    int fd = wxOpen( szFileName, flags ACCESS(accessMode));

    if ( fd == -1 )
    {
        wxLogSysError(_("can't open file '%s'"), szFileName);
        return false;
    }
    else {
        Attach(fd);
        return true;
    }
}
    Handle& Handle::operator=(Handle& h)
    {
        if (mHandle_ != h)
        {
            if (NULL != mHandle_)
            {
                Close();
            }

            Attach(h.Detach());
        }

        return *this;
    }
Example #9
0
///////////////////////////////////////////////////////////////////////////////
// AttachFromVariant: Attach a Variant SafeArray
bool CSafeArrayHelper::AttachFromVariant(VARIANT* pVariant)
{
	if (NULL != pVariant)
	{
		if (pVariant->vt & VT_ARRAY)
		{
			LPSAFEARRAY psa = pVariant->parray;
			if (pVariant->vt & VT_BYREF)	// VB use this...
				psa = *pVariant->pparray;
			return Attach( psa );
		}
	}
	return false;
}
DemoEntity::DemoEntity(DemoEntityManager& world, const dScene* scene, dScene::dTreeNode* rootSceneNode, dTree<DemoMesh*, dScene::dTreeNode*>& 	 	meshCache, DemoEntityManager::EntityDictionary& entityDictionary, DemoEntity* parent)
	:dClassInfo()
	,dHierarchy<DemoEntity>() 
	,m_matrix(GetIdentityMatrix()) 
	,m_curPosition (0.0f, 0.0f, 0.0f, 1.0f)
	,m_nextPosition (0.0f, 0.0f, 0.0f, 1.0f)
	,m_curRotation (1.0f, 0.0f, 0.0f, 0.0f)
	,m_nextRotation (1.0f, 0.0f, 0.0f, 0.0f)
	,m_lock (0)
	,m_mesh (NULL)
{
	// add this entity to the dictionary
	entityDictionary.Insert(this, rootSceneNode);

	// if this is a child mesh set it as child of th entity
	dMatrix parentMatrix (GetIdentityMatrix());
	if (parent) {
		Attach (parent);

		dScene::dTreeNode* parentNode = scene->FindParentByType(rootSceneNode, dSceneNodeInfo::GetRttiType());
		dSceneNodeInfo* parentInfo = (dSceneNodeInfo*) parentNode;
		parentMatrix = parentInfo->GetTransform();
	}

	dSceneNodeInfo* info = (dSceneNodeInfo*) scene->GetInfoFromNode (rootSceneNode);
//	SetMatrix(info->GetTransform() * parentMatrix.Inverse4x4());
	dMatrix matrix (info->GetTransform() * parentMatrix.Inverse4x4());
	dQuaternion rot (matrix);

	// set the matrix twice in oder to get cur and next position
	SetMatrix(world, rot, matrix.m_posit);
	SetMatrix(world, rot, matrix.m_posit);


	// if this node has a mesh, find it and attach it to this entity
	dScene::dTreeNode* meshNode = scene->FindChildByType(rootSceneNode, dMeshNodeInfo::GetRttiType());
	if (meshNode) {
		DemoMesh* mesh = meshCache.Find(meshNode)->GetInfo();
		SetMesh(mesh);
	}

	// add all of the children nodes as child nodes
	for (void* child = scene->GetFirstChild(rootSceneNode); child; child = scene->GetNextChild (rootSceneNode, child)) {
		dScene::dTreeNode* node = scene->GetNodeFromLink(child);
		dNodeInfo* info = scene->GetInfoFromNode(node);
		if (info->GetTypeId() == dSceneNodeInfo::GetRttiType()) {
			new DemoEntity (world, scene, node, meshCache, entityDictionary, this);
		}
	}
}
Example #11
0
    __checkReturn HRESULT Create(__in DWORD threadCount)
    {
        Attach(::CreateIoCompletionPort(INVALID_HANDLE_VALUE,
                                        0, // no existing port
                                        0, // ignored
                                        threadCount));

        if (0 == m_h)
        {
            return HRESULT_FROM_WIN32(::GetLastError());
        }

        return S_OK;
    }
Example #12
0
bool CMutex::Create() {

#if ( configUSE_MUTEXES == 1 )

	SemaphoreHandle_t handle;

	handle = xSemaphoreCreateMutex();

	if (handle != NULL)
		Attach(handle);
#endif

	return IsValid();
}
Example #13
0
    ///////////////////////////////////////////////////////////////////////
    ///  Function: AttachBlackOfScreen
    ///
    ///    Author: $author$
    ///      Date: 2/8/2013
    ///////////////////////////////////////////////////////////////////////
    virtual XosError AttachBlackOfScreen(Screen* xScreen, bool onlyFreed=false) 
    {
        XosError error = XOS_ERROR_FAILED;
        XosError error2;

        if ((error2 = Freed(onlyFreed)))
            return error2;

        if ((xScreen)) {
            Attach(XBlackPixelOfScreen(xScreen));
            error = XOS_ERROR_NONE;
        }
        return error;
    }
int ProfilerHandler::Load() {
  amx_path_ = fileutils::ToUnixPath(amx_path_finder_->Find(amx()));
  amx_name_ = fileutils::GetDirectory(amx_path_)
            + "/"
            + fileutils::GetBaseName(amx_path_);

  if (amx_path_.empty()) {
    Printf("Could not find AMX file (try setting AMX_PATH?)");
  }
  if (ShouldBeProfiled(amx_path_)) {
    Attach();
  }
  return AMX_ERR_NONE;
}
Example #15
0
    HRESULT Initialize(PCWSTR serverName,
                       INTERNET_PORT portNumber,
                       const WinHttpSession& session)
    {
        if (!Attach(::WinHttpConnect(session.m_handle,
                                     serverName,
                                     portNumber,
                                     0))) // reserved
        {
            return HRESULT_FROM_WIN32(::GetLastError());
        }

        return S_OK;
    }
SelectionKeyImpl::SelectionKeyImpl(
    /* [in] */ IAbstractSelectableChannel* channel,
    /* [in] */ Int32 ops,
    /* [in] */ IObject* attachment,
    /* [in] */ IAbstractSelector* selector)
{
    REFCOUNT_ADD(channel);
    this->mChannel = channel;
    this->mInterestOps = ops;
    REFCOUNT_ADD(selector);
    this->mSelector = selector;
    AutoPtr<IObject> tempObj;
    Attach(attachment, (IObject**)&tempObj);
}
Example #17
0
void UdpSocket::SendToBuf(SocketAddress& ad, const char *data, int len, int flags)
{
	if (GetSocket() == INVALID_SOCKET)
	{
		Attach(CreateSocket(ad.GetFamily(), SOCK_DGRAM, "udp"));
	}
	if (GetSocket() != INVALID_SOCKET)
	{
		SetNonblocking(true);
		if ((m_last_size_written = sendto(GetSocket(), data, len, flags, ad, ad)) == -1)
		{
			Handler().LogError(this, "sendto", Errno, StrError(Errno), LOG_LEVEL_ERROR);
		}
	}
}
Example #18
0
		BOOL CULDateTimePicker::Create(HWND hParentWnd,WORD wID,int x,int y,int cx,int cy,DWORD dwStyle)
		{
			m_hWnd = CreateWindowEx(0,
				DATETIMEPICK_CLASS,
				NULL,
				dwStyle,
				x,y,cx,cy,
				hParentWnd,
				(HMENU)wID,
				ULOther::ULGetResourceHandle(),
				this);
			if(!m_hWnd)
				return FALSE;
			return Attach(m_hWnd);
		}
Example #19
0
BOOL CVisualBoyHandler::RefreshAddressList(VOID)
{
	BOOL	bResult = IsValid();

	if(!bResult)
	{
		bResult = Attach();
	}
	else
	{
		bResult = SearchForPtrStruct();
	}

	return bResult;
}
Example #20
0
CBlockEvaluator::CBlockEvaluator(FlwNode * pNd,
                                 DWORD Options,
                                 CReactionBase * pRB,
                                 CHXBase *pHX,
                                 CEnvironHXBase * pEHX,
                                 CVLEBase * pVLE,
                                 CEvapBase * pEvap) :
  CBlockEvalStateSemantics(false)
  {
  m_pNd             = pNd;
  m_Options         = Options;
  //m_bAllowStateSemantics = false;
  
  Attach((Options & BEO_StateSemantics)!=0, pRB, pHX, pEHX, pVLE, pEvap);
  };
Example #21
0
//*******************************************************************************
BOOL CMPCPngImage::LoadFromFile(LPCTSTR lpszPath)
{
    BOOL bRes = FALSE;

    if (m_pImage == nullptr) {
        m_pImage = DEBUG_NEW CImage;
        ENSURE(m_pImage != nullptr);
    }

    if (m_pImage->Load(lpszPath) == S_OK) {
        bRes = Attach(m_pImage->Detach());
    }

    return bRes;
}
Example #22
0
void COleDataObject::EnsureClipboardObject()
{
	ASSERT(AfxIsValidAddress(this, sizeof(COleDataObject)));

	if (m_bClipboard && m_lpDataObject == NULL)
	{
		// get clipboard using OLE API
		LPDATAOBJECT lpDataObject;
		SCODE sc = ::OleGetClipboard(&lpDataObject);

		// attach COleDataObject wrapper to IDataObject from clipboard
		if (sc == S_OK)
			Attach(lpDataObject, TRUE);
	}
}
Example #23
0
cDevice *cServerConnection::GetDevice(const cChannel *Channel, int Priority) 
{
	// turn off the streams of this connection
	Detach();
	// This call may detach receivers of the device it returns
	cDevice *device = cDevice::GetDevice(Channel, Priority, false);

 	if (device && !device->IsTunedToTransponder(Channel)
			&& UsedByLiveTV(device)) {
		// now we would have to switch away live tv...let's see if live tv
		// can be handled by another device
#if VDRVERSNUM >= 10516
		cDevice::SetAvoidDevice(device);
		if (!Channels.SwitchTo(cDevice::CurrentChannel())) {
			if (StreamdevServerSetup.SuspendMode == smAlways) {
				Channels.SwitchTo(Channel->Number());
				Skins.QueueMessage(mtInfo, tr("Streaming active"));
			}
			else {
				dsyslog("streamdev: GetDevice: Live TV not suspended");
				device = NULL;
			}
		}
#else
		const cChannel *current = Channels.GetByNumber(cDevice::CurrentChannel());
		cDevice *newdev = current ? CheckDevice(current, 0, true, device) : NULL;
		if (newdev) {
			dsyslog("streamdev: GetDevice: Trying to move live TV to device %d", newdev->CardIndex());
			newdev->SwitchChannel(current, true);
		}
		else if (StreamdevServerSetup.SuspendMode == smAlways) {
			Channels.SwitchTo(Channel->Number());
			Skins.QueueMessage(mtInfo, tr("Streaming active"));
		}
		else {
			dsyslog("streamdev: GetDevice: Live TV not suspended");
			device = NULL;
		}
#endif
	}

	if (!device) {
		// can't switch - continue the current stream
		Attach();
		dsyslog("streamdev: GetDevice failed for channel %d (%s) at priority %d (PrimaryDevice=%d, ActualDevice=%d)", Channel->Number(), Channel->Name(), Priority, cDevice::PrimaryDevice()->CardIndex(), cDevice::ActualDevice()->CardIndex());
	}
	return device;
}
Example #24
0
void VoxelTerrain::OnUpdate()
{
	//Make some chunks
	if (m_vChunks.size() == 0) {
		Wish_Asset_LoadTexture("wald", "./data/textures/wald.png");
		for (size_t x = 0; x < 8; x++) {
			for (size_t y = 0; y < 8; y++) {
				VoxelChunk* pChunk = new VoxelChunk(x, y);
				m_vChunks.push_back(0);
				Attach(pChunk);
				printf("Attached transform.");
				pChunk->Build();
			}
		}
	}
}
Example #25
0
void TaskManager::UpdateProcesses(Uint32 deltaMs)
{
    TaskPtr next;
    for (auto current : task_list) {
        if (current->IsDead()) {
            next = current->GetNext();
            if (next) {
                current->SetNext(TaskPtr(nullptr));
                Attach(next);
            }
            Detach(current);
        } else if (current->IsActive() && !current->IsPaused()) {
            current->OnUpdate(deltaMs);
        }
    }
}
Example #26
0
 void
 TerminalDisplay::DisplayInfo(const std::vector<std::string>& Options) {
   char infoColIdx = 0;
   if (GetContext()->GetColorizer()) {
      infoColIdx = GetContext()->GetColorizer()->GetInfoColor();
   }
   WriteRawString("\n", 1);
   for (size_t i = 0, n = Options.size(); i < n; ++i) {
     Text t(Options[i], infoColIdx);
     WriteWrappedElement(t, 0, 0, (size_t) -1);
     WriteRawString("\n", 1);
   }
   // Reset position
   Detach();
   Attach();
 }
Example #27
0
FX_BOOL CFX_QuartzDevice::Create(FX_INT32 width, FX_INT32 height, FXDIB_Format format)
{
    if ((FX_BYTE)format < 32) {
        return FALSE;
    }
    CFX_DIBitmap* pBitmap = FX_NEW CFX_DIBitmap;
    if (!pBitmap) {
        return FALSE;
    }
    if (!pBitmap->Create(width, height, format)) {
        delete pBitmap;
        return FALSE;
    }
    m_bOwnedBitmap = TRUE;
    return Attach(pBitmap);
}
Example #28
0
// Constructor.
SpaceVisualizer::SpaceVisualizer(beScene::ResourceManager &resources, beScene::EffectDrivenRenderer &renderer)
	: m_world( new_resource bees::World("WidgetWorld") ),
	m_simulation( new_resource bees::Simulation("WidgetSimulation") )
{
	m_data[WidgetType::Arrow] = createWidgetData("Static/UI/TranslateWidget.mesh", "Materials/Widget.fx", "", resources, renderer);
	m_data[WidgetType::Circle] = createWidgetData("Static/UI/RotateWidget.mesh", "Materials/Widget.fx", "DARKEN_SPHERE_BACK", resources, renderer);
	m_data[WidgetType::Plug] = createWidgetData("Static/UI/ScaleWidget.mesh", "Materials/Widget.fx", "", resources, renderer);

	m_scene = new besc::RenderingController(renderer.Pipeline, nullptr);
	m_world->Controllers().AddControllerKeep(m_scene);

	m_meshes = besc::CreateMeshControllers(&m_world->PersistentIDs()).detach();
	m_world->Controllers().AddControllerKeep(m_meshes);

	Attach(m_world, m_simulation);
}
Example #29
0
void CInventoryItem::OnEvent (NET_Packet& P, u16 type)
{
	switch (type)
	{
	case GE_ADDON_ATTACH:
		{
			u32 ItemID;
			P.r_u32			(ItemID);
			CInventoryItem*	 ItemToAttach	= smart_cast<CInventoryItem*>(Level().Objects.net_Find(ItemID));
			if (!ItemToAttach) break;
			Attach(ItemToAttach,true);
			CActor* pActor = smart_cast<CActor*>(object().H_Parent());
			if (pActor && pActor->inventory().ActiveItem() == this)
			{
				pActor->inventory().SetPrevActiveSlot(pActor->inventory().GetActiveSlot());
				pActor->inventory().Activate(NO_ACTIVE_SLOT);
				
			}
		}break;
	case GE_ADDON_DETACH:
		{
			string64			i_name;
			P.r_stringZ			(i_name);
			Detach(i_name, true);
			CActor* pActor = smart_cast<CActor*>(object().H_Parent());
			if (pActor && pActor->inventory().ActiveItem() == this)
			{
				pActor->inventory().SetPrevActiveSlot(pActor->inventory().GetActiveSlot());
				pActor->inventory().Activate(NO_ACTIVE_SLOT);
			};
		}break;	
	case GE_CHANGE_POS:
		{
			Fvector p; 
			P.r_vec3(p);
			CPHSynchronize* pSyncObj = NULL;
			pSyncObj = object().PHGetSyncItem(0);
			if (!pSyncObj) return;
			SPHNetState state;
			pSyncObj->get_State(state);
			state.position = p;
			state.previous_position = p;
			pSyncObj->set_State(state);

		}break;
	}
}
Example #30
0
int main(int argc, char *argv[])
{
	HIJACK *hijack;
	FUNC *func;
	unsigned long addr;
	PLT *plts, *plt;
	
	if (argc != 2)
		usage(argv[0]);
	
	hijack = InitHijack();
    ToggleFlag(hijack, F_DEBUG);
    ToggleFlag(hijack, F_DEBUG_VERBOSE);
	AssignPid(hijack, atoi(argv[1]));
	
	if (Attach(hijack) != ERROR_NONE)
	{
		fprintf(stderr, "[-] Couldn't attach!\n");
		exit(EXIT_FAILURE);
	}

	if (LocateAllFunctions(hijack) != ERROR_NONE)
	{
		fprintf(stderr, "[-] Couldn't locate all functions!\n");
		exit(EXIT_FAILURE);
	}

    if (LocateSystemCall(hijack) != ERROR_NONE) {
        fprintf(stderr, "[-] Couldn't locate system call!\n");
        exit(EXIT_FAILURE);
    }

    addr = MapMemory(hijack, NULL, 8192, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_SHARED);
    if (GetErrorCode(hijack) != ERROR_NONE) {
        fprintf(stderr, "[-] %s\n", GetErrorString(hijack));
        perror("ptrace");
    }
	
	printf("[*] PLT/GOT @ 0x%016lx\n", hijack->pltgot);
	printf("[*] Baseaddr @ 0x%016lx\n", hijack->baseaddr);
    printf("[*] Syscall @ 0x%016lx\n", hijack->syscalladdr);
    printf("[*] addr @ 0x%016lx\n", addr);

	Detach(hijack);
	
	return 0;
}