Ejemplo n.º 1
0
void BaseWidget::setPosition(const QPoint *position)
{
  dReal xPos = position->x();
  dReal yPos = position->y();
  
  // Update ODE's position
  dGeomSetPosition(geometry, RELATIVE(xPos), RELATIVE(yPos), 0);
  qDebug("Moved to %f, %f", xPos, yPos);

  // Update Qt's position
  move(*position);
}
Ejemplo n.º 2
0
/*! .

	\param [in]
	\param [out]
	\param [in,out]

	\pre
	\post
	\return

*/
NTSTATUS
FlTimerThreadStop()
{
    LARGE_INTEGER tend_timeout;


    DBGPRINT("[flmonflt] Stopping timer thread.\n");

    tend_timeout.QuadPart = RELATIVE(SECONDS(8));
    TimerThreadStopExec = TRUE;


    KeCancelTimer(DriverInfoData->Timer);
    KeSetEvent(DriverInfoData->TimerThreadSleepWakeup, 0, FALSE);

    DBGPRINT("[flmonflt] Waiting for thread to exit.\n");
    KeWaitForSingleObject(DriverInfoData->TimerThread, Executive, KernelMode, TRUE, &tend_timeout);

    DBGPRINT("[flmonflt] Thread exited, dereferencing object.\n");
    ObDereferenceObject(DriverInfoData->TimerThread);

    DBGPRINT("[flmonflt] Thread dereferenced.\n");

    return STATUS_SUCCESS;
}
Ejemplo n.º 3
0
//--------------------------------------------------------------------------------------
VOID DriverEntryContinueThread(PVOID Param)
{
    LARGE_INTEGER Timeout = { 0 };
    Timeout.QuadPart = RELATIVE(SECONDS(3));    
    
    DbgMsg(__FILE__, __LINE__, "Unloading old driver...\n");

    NTSTATUS ns = ZwUnloadDriver(&m_RegistryPath);
    if (NT_SUCCESS(ns))
    {
        DbgMsg(__FILE__, __LINE__, "OK\n");
    }
    else
    {
        DbgMsg(__FILE__, __LINE__, "ZwUnloadDriver() fails; status: 0x%.8x\n", ns);
    }

    while (true)
    {
        DbgPrint(__FUNCTION__"(): I'm allive!\n");

        // sleep
        KeDelayExecutionThread(KernelMode, FALSE, &Timeout);        
    }
}
Ejemplo n.º 4
0
static
VOID
NTAPI
  DriverUnload(
	__in PDRIVER_OBJECT DriverObject
	)
{
	LARGE_INTEGER Interval = {0};

	if (g_ServerSocket != NULL) {
		CloseSocket(g_ServerSocket);
		g_ServerSocket = NULL;
	}

	// Shut down ServerThread() thread

	KeWaitForSingleObject(g_ServerThread, Executive, KernelMode, FALSE, NULL);
	ObDereferenceObject(g_ServerThread);

	// Wait for the clients' threads

	Interval.QuadPart = RELATIVE(MILLISECONDS(100));
	while (g_ClientsCount)
		KeDelayExecutionThread(KernelMode, FALSE, &Interval);

	SocketsDeinit();
}
Ejemplo n.º 5
0
static VOID NTAPI ScanWindowsThread(PVOID Param)
{
	LARGE_INTEGER	Interval;


	Interval.QuadPart=RELATIVE(MILLISECONDS(10));

	while (STATUS_TIMEOUT==KeWaitForSingleObject(
							&g_ShutdownEvent,
							Executive,
							KernelMode,
							FALSE,
							&Interval)) {

		PrintData();
	}


	DbgPrint("ScanWindowsThread(): Shutting down\n");

	PsTerminateSystemThread(STATUS_SUCCESS);
}
Ejemplo n.º 6
0
static int
write_file(char **r_linknam, int a_ctrl, mode_t a_mode, char *a_file)
{
	int		len;
	int		fd = -1;
	static char	loc_link[PATH_MAX];

	/* entry debugging */

	echoDebug(DBG_WRITEFILE_ENTRY, a_ctrl, a_mode, a_file);

	/* reset pointer to returned 'temporary file name' */

	*r_linknam = (char *)NULL;

	/*
	 * If we are overwriting an existing file, arrange to replace
	 * it transparently.
	 */

	if (access(a_file, F_OK) == 0) {
		/*
		 * link the file to be copied to a temporary name in case
		 * it is executing or it is being written/used (e.g., a shell
		 * script currently being executed
		 */

		if (!RELATIVE(a_file)) {
			len = snprintf(loc_link, sizeof (loc_link),
					"%sXXXXXX", a_file);
			if (len > sizeof (loc_link)) {
				progerr(ERR_CREATE_PATH_2, a_file, "XXXXXX");
			}
		} else {
			logerr(WRN_RELATIVE, a_file);
			len = snprintf(loc_link, sizeof (loc_link),
					"./%sXXXXXX", a_file);
			if (len > sizeof (loc_link)) {
				progerr(ERR_CREATE_PATH_3, "./", a_file,
					"XXXXXX");
			}
		}

		/* create and open temporary file */

		fd = mkstemp(loc_link);
		if (fd == -1) {
			progerr(ERR_MKTEMP, loc_link, errno, strerror(errno));
			return (-1);
		}

		/* remember name of temporary file */

		*r_linknam = loc_link;

		/* make sure temporary file has correct mode */

		if (fchmod(fd, a_mode) < 0) {
			progerr(ERR_FCHMOD, loc_link, a_mode, errno,
				strerror(errno));
		}

		return (fd);
	}

	/*
	 * We are not overwriting an existing file, create a new one directly.
	 */

	fd = open(a_file, O_WRONLY | O_CREAT | O_TRUNC, a_mode);
	if (fd == -1) {
		if (create_path(a_ctrl, a_file) == 0) {
			fd = open(a_file, O_WRONLY | O_CREAT | O_TRUNC, a_mode);
		}
	}

	if (fd == -1) {
		progerr(ERR_OPEN_WRITE, a_file, errno, strerror(errno));
	}

	return (fd);
}
Ejemplo n.º 7
0
/*! .

	\param [in]
	\param [out]
	\param [in,out]

	\pre
	\post
	\return

*/
void
TimerThreadExecRoutine(
    __in  PVOID StartContext
)
{
    UNREFERENCED_PARAMETER(StartContext);


    DBGPRINT("[flmonflt] Starting timer thread.\n");

    DriverInfoData->TimerDueTime.QuadPart = RELATIVE(MILLISECONDS(TIMER_THREAD_LIST_TIMEOUT_MS));


    while(!TimerThreadStopExec)
    {
        // wait for event, thread will sleep until its set.
        KeWaitForSingleObject(DriverInfoData->TimerThreadSleepWakeup,
                              Executive, KernelMode, FALSE, NULL);

        if (TimerThreadStopExec)
        {
            DBGPRINT("[flmonflt] Terminating timer thread with TimerThreadSleepWakeup.\n");
            break;
        }




        DBGPRINT("[flmonflt] Waiting for timer to elapse.\n");

        //DriverInfoData->TrackerLastEntryValid = FALSE;
        KeSetTimer(DriverInfoData->Timer, DriverInfoData->TimerDueTime, NULL);
        KeWaitForSingleObject(DriverInfoData->Timer, Executive, KernelMode, FALSE, NULL);


        DBGPRINT("[flmonflt] Timer elapsed.\n");

        FlTrackerSetLastEntry(DriverInfoData);
        //DriverInfoData->TrackerLastEntryValid = TRUE;



        DBGPRINT("[flmonflt] *************** Timer elapsed. ***************\n");
        FlTrackerEntryPrint(FlTrackerGetBestEntry(DriverInfoData->Tracker));
        DBGPRINT("[flmonflt] **********************************************\n");
        FlTrackerPrintListDbg(DriverInfoData->Tracker);
        DBGPRINT("[flmonflt] ----------------------------------------------\n");


        FlTrackerInfoToUserspace(DriverInfoData, TRUE);

        FlTrackerClean(DriverInfoData->Tracker);


        // clear event to nonsignaled
        KeClearEvent(DriverInfoData->TimerThreadSleepWakeup);
    }

    DBGPRINT_ARG1("[flmonflt] Terminating timer thread, Stop=%d.\n", TimerThreadStopExec);
    PsTerminateSystemThread(STATUS_SUCCESS);
}