示例#1
0
	bool Container::_focusRequested( Hook * pBranch, Widget * pWidgetRequesting )
	{
		Hook * p = _hook();
		if( p )
			return p->_requestFocus(pWidgetRequesting);
		return false;
	}
示例#2
0
	bool Container::_focusReleased( Hook * pBranch, Widget * pWidgetReleasing )
	{
		Hook * p = _hook();
		if( p )
			return p->_releaseFocus(pWidgetReleasing);
		return false;
	}
示例#3
0
    bool ReplicaSetMonitor::_checkConnection( DBClientConnection * c , string& maybePrimary , bool verbose ) {
        bool isMaster = false;
        bool changed = false;
        try {
            BSONObj o;
            c->isMaster(isMaster, &o);

            log( ! verbose ) << "ReplicaSetMonitor::_checkConnection: " << c->toString() << ' ' << o << '\n';

            // add other nodes
            string maybePrimary;
            if ( o["hosts"].type() == Array ) {
                if ( o["primary"].type() == String )
                    maybePrimary = o["primary"].String();

                _checkHosts(o["hosts"].Obj(), changed);
            }
            if (o.hasField("passives") && o["passives"].type() == Array) {
                _checkHosts(o["passives"].Obj(), changed);
            }

            _checkStatus(c);
        }
        catch ( std::exception& e ) {
            log( ! verbose ) << "ReplicaSetMonitor::_checkConnection: caught exception " << c->toString() << ' ' << e.what() << endl;
        }

        if ( changed && _hook )
            _hook( this );

        return isMaster;
    }
示例#4
0
	void Container::_visibilityRequested( Hook * pBranch, const Rect& preferred, const Rect& prio )
	{
		Hook * p = _hook();
		if( p )
		{
			Coord ofs = pBranch->pos();
			p->_requestVisibility( preferred + ofs, prio + ofs);
		}
	}
示例#5
0
void SQInstance::Finalize() 
{
	// call release hook before remove class
	_uiRef++;
	if (_hook) { _hook(_userpointer,0); _hook=NULL; }
	_uiRef--;
	SQUnsignedInteger nvalues = _class->_defaultvalues.size();
	__ObjRelease(_class);
	for(SQUnsignedInteger i = 0; i < nvalues; i++) {
		_values[i] = _null_;
	}
}
示例#6
0
文件: drv.c 项目: escoand/socksswitch
BOOL WINAPI new_SetWindowText(HWND h, LPCTSTR text) {
    BOOL rc;
    DEBUG_ENTER;
#if defined(_DEBUG) || defined(_DEBUG_)
    TRACE_VERBOSE("org title: %s\n", text);
#endif
    /* update title */
    if (strstr((char *) text, TITLE_APPEND) == NULL)
	text = strcat((char *) text, TITLE_APPEND);
#if defined(_DEBUG) || defined(_DEBUG_)
    TRACE_VERBOSE("new title: %s\n", text);
#endif
    /* set window text */
    _unhook(3);
    rc = SetWindowText(h, text);
    _hook(3);
    DEBUG_LEAVE;
    return rc;
}
示例#7
0
文件: drv.c 项目: escoand/socksswitch
BOOL WINAPI DllMain(HINSTANCE hinstDLL,
		    DWORD fdwReason, LPVOID lpvReserved) {
    DWORD protect, jmp_size;
    HWND h;
    int i, pid;
    char txt[1024] = "";

#if defined(_DEBUG) || defined(_DEBUG_)
    putenv("LOGFILE=c:\\socksswitchdrv.log");
    putenv("TRACE=4");
    putenv("DUMP=1");
#endif

    DEBUG_ENTER;

    switch (fdwReason) {

	/* hook */
    case DLL_PROCESS_ATTACH:

	/* init */
	for (i = 0; i < COUNT; i++) {
	    memset(bytes[i], 0, SIZE);
	    memcpy(jmp[i], "\xE9\x90\x90\x90\x90\xC3", SIZE);
	}

	/* function address */
	addr[0] = GetProcAddress(GetModuleHandle("ws2_32.dll"), "connect");
	addr[1] =
	    GetProcAddress(GetModuleHandle("ws2_32.dll"), "WSAConnect");
	addr[2] =
	    GetProcAddress(GetModuleHandle("user32.dll"),
			   "SetWindowTextA");
	addr_new[0] = new_connect;
	addr_new[1] = new_WSAConnect;
	addr_new[2] = new_SetWindowText;

#if defined(_DEBUG) || defined(_DEBUG_)
	for (i = 0; i < COUNT; i++) {
	    TRACE_VERBOSE("pid:%i org:%p new:%p\n", GetCurrentProcessId(),
			  addr[i], addr_new[i]);
	}
#endif

	/* save bytes */
	for (i = 0; i < COUNT; i++) {
	    if (addr[i] != NULL) {
		VirtualProtect(addr[i], SIZE,
			       PAGE_EXECUTE_READWRITE, &protect);
		memcpy(bytes[i], addr[i], SIZE);
		VirtualProtect(addr[i], SIZE, protect, NULL);
		jmp_size = (DWORD) addr_new[i] - (DWORD) addr[i] - 5;
		memcpy(&jmp[i][1], &jmp_size, 4);
	    }
	}

	_hook(0);

	/* window text */
	h = GetTopWindow(0);
	while (h) {
	    GetWindowThreadProcessId(h, (PDWORD) & pid);
	    if (pid == GetCurrentProcessId() && IsWindow(h)
		&& IsWindowVisible(h)) {
		GetWindowText(h, txt, sizeof(txt));
		SetWindowText(h, txt);
	    }
	    h = GetNextWindow(h, GW_HWNDNEXT);
	}

	for (i = 0; i < COUNT; i++) {
	    DUMP(bytes[i], SIZE);
	    DUMP(jmp[i], SIZE);
	}

	break;

	/* unhook */
    case DLL_PROCESS_DETACH:
	_unhook(0);
	break;

    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
	break;
    }

    DEBUG_LEAVE;

    return TRUE;
}
示例#8
0
文件: drv.c 项目: escoand/socksswitch
int WINAPI new_WSAConnect(SOCKET s,
			  const struct sockaddr *name,
			  int namelen,
			  LPWSABUF lpCallerData,
			  LPWSABUF lpCalleeData,
			  LPQOS lpSQOS, LPQOS lpGQOS) {
    int rc, err;
    struct sockaddr_in in_addr;
    struct sockaddr_in out_addr;
    char buf[256];
    fd_set set;

    DEBUG_ENTER;

    memcpy(&in_addr, name, sizeof(in_addr));

    /* change non-local */
    if (in_addr.sin_addr.s_addr != inet_addr("127.0.0.1")) {
	DEBUG;
	out_addr.sin_family = AF_INET;
	out_addr.sin_port = htons(1080);
	out_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
    }

    DEBUG;

    /* connect */
    _unhook(2);
    rc = WSAConnect(s, (struct sockaddr *) (&out_addr),
		    sizeof(struct sockaddr_in), lpCallerData,
		    lpCalleeData, lpSQOS, lpGQOS);
    err = WSAGetLastError();
#if defined(_DEBUG) || defined(_DEBUG_)
    TRACE_NO("connect (rc:%i err:%i pid:%i): %s\n", rc, err,
	     GetCurrentProcessId(), socketError());
#endif
    _hook(2);
    if (rc != 0 && err != WSAEWOULDBLOCK) {
	closesocket(s);
	DEBUG_LEAVE;
	return rc;
    }

    /* pass through local */
    if (in_addr.sin_addr.s_addr == inet_addr("127.0.0.1")) {
	DEBUG_LEAVE;
	return rc;
    }

    /* fd_set */
    FD_ZERO(&set);
    FD_SET(s, &set);
    /* sock5 handshake */
    select(s + 1, NULL, &set, NULL, 0);
    rc = send(s, "\x05\x01\x00", 3, 0);
#if defined(_DEBUG) || defined(_DEBUG_)
    TRACE_VERBOSE("send (rc:%i err:%i pid:%i): %s\n", rc,
		  WSAGetLastError(), GetCurrentProcessId(), socketError());
#endif
    if (rc != 3) {
	closesocket(s);
	DEBUG_LEAVE;
	return SOCKET_ERROR;
    }

    /* socks5 ack */
    select(s + 1, &set, NULL, NULL, 0);
    rc = recv(s, buf, 256, 0);
#if defined(_DEBUG) || defined(_DEBUG_)
    TRACE_VERBOSE("recv (rc:%i err:%i pid:%i): %s\n", rc,
		  WSAGetLastError(), GetCurrentProcessId(), socketError());
    DUMP(buf, rc);
#endif
    if (rc != 2) {
	closesocket(s);
	DEBUG_LEAVE;
	return SOCKET_ERROR;
    }

    /* socks5 request */
    memcpy(buf, "\x05\x01\x00\x01", 4);
    memcpy(buf + 4, &in_addr.sin_addr.s_addr, 4);
    memcpy(buf + 8, &in_addr.sin_port, 2);
    select(s + 1, NULL, &set, NULL, 0);
    rc = send(s, buf, 10, 0);
#if defined(_DEBUG) || defined(_DEBUG_)
    TRACE_VERBOSE("send (rc:%i err:%i pid:%i): %s\n", rc,
		  WSAGetLastError(), GetCurrentProcessId(), socketError());
#endif
    if (rc != 10) {
	closesocket(s);
	DEBUG_LEAVE;
	return SOCKET_ERROR;
    }

    /* socks5 ack */
    select(s + 1, &set, NULL, NULL, 0);
    rc = recv(s, buf, 256, 0);
#if defined(_DEBUG) || defined(_DEBUG_)
    TRACE_VERBOSE("recv (rc:%i err:%i pid:%i): %s\n", rc,
		  WSAGetLastError(), GetCurrentProcessId(), socketError());
    DUMP(buf, rc);
#endif
    if (rc != 10) {
	closesocket(s);
	DEBUG_LEAVE;
	return SOCKET_ERROR;
    }

    DEBUG_LEAVE;
    return 0;
}