Esempio n. 1
0
/**
 * Creates a proxy_connection if a client wants to connect
 *
 * @access  public
 * @param   fd_set *master
 * @param	connection_context *ctx
 * @param	int hListen
 * @return  int newsocket
 */
int create_proxy_connection(fd_set *master, connection_context *ctx, int hListen) {
	struct sockaddr_in remoteaddr;
	proxy_connection *conn;
	int addrlen;
	int newfd;
	
	addrlen= sizeof (remoteaddr);
	if (-1 == (newfd= accept(hListen, (struct sockaddr *)&remoteaddr, &addrlen))) {
		ERR("Could not accept new connection");
		return -1;
	}
	
	alloc_connection(&conn);
	conn->hClient= newfd;
	add_connection(ctx, conn);

	/* Add socket to fdset */
	FD_SET (newfd, master);
	
	_dump_context (ctx);
	
	LOG("New client connected");
	return newfd;
}
Esempio n. 2
0
static VOID
PrintStackTrace(IN PEXCEPTION_POINTERS ExceptionInfo)
{
    PVOID StartAddr;
    CHAR szMod[128] = "", *szModFile;
    PEXCEPTION_RECORD ExceptionRecord = ExceptionInfo->ExceptionRecord;
    PCONTEXT ContextRecord = ExceptionInfo->ContextRecord;

    /* Print a stack trace */
    DbgPrint("Unhandled exception\n");
    DbgPrint("ExceptionCode:    %8x\n", ExceptionRecord->ExceptionCode);

    if (ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION &&
        ExceptionRecord->NumberParameters == 2)
    {
        DbgPrint("Faulting Address: %8x\n", ExceptionRecord->ExceptionInformation[1]);
    }

    _dump_context(ContextRecord);
    _module_name_from_addr(ExceptionRecord->ExceptionAddress, &StartAddr, szMod, sizeof(szMod), &szModFile);
    DbgPrint("Address:\n<%s:%x> (%s@%x)\n",
             szModFile,
             (ULONG_PTR)ExceptionRecord->ExceptionAddress - (ULONG_PTR)StartAddr,
             szMod,
             StartAddr);
#ifdef _M_IX86
    DbgPrint("Frames:\n");

    _SEH2_TRY
    {
        UINT i;
        PULONG Frame = (PULONG)ContextRecord->Ebp;

        for (i = 0; Frame[1] != 0 && Frame[1] != 0xdeadbeef && i < 128; i++)
        {
            if (IsBadReadPtr((PVOID)Frame[1], 4))
            {
                DbgPrint("<%s:%x>\n", "[invalid address]", Frame[1]);
            }
            else
            {
                _module_name_from_addr((const void*)Frame[1], &StartAddr,
                                       szMod, sizeof(szMod), &szModFile);
                DbgPrint("<%s:%x> (%s@%x)\n",
                         szModFile,
                         (ULONG_PTR)Frame[1] - (ULONG_PTR)StartAddr,
                         szMod,
                         StartAddr);
            }

            if (IsBadReadPtr((PVOID)Frame[0], sizeof(*Frame) * 2))
                break;

            Frame = (PULONG)Frame[0];
        }
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
        DbgPrint("<error dumping stack trace: 0x%x>\n", _SEH2_GetExceptionCode());
    }
    _SEH2_END;
#endif
}