Ejemplo n.º 1
0
void slowPoll( void )
	{
	RANDOM_STATE randomState;
	BYTE buffer[ RANDOM_BUFSIZE ];
	MODULEENTRY moduleEntry;
	GLOBALENTRY globalEntry;
	TASKENTRY taskEntry;
	int count;

	initRandomData( randomState, buffer, RANDOM_BUFSIZE );

	/* Walk the global heap getting information on each entry in it.  This
	   retrieves the objects linear address, size, handle, lock count, owner,
	   object type, and segment type */
	count = 0;
	globalEntry.dwSize = sizeof( GLOBALENTRY );
	if( GlobalFirst( &globalEntry, GLOBAL_ALL ) )
		do
			{
			addRandomData( randomState, &globalEntry, sizeof( GLOBALENTRY ) );
			count++;
			}
		while( count < 70 && GlobalNext( &globalEntry, GLOBAL_ALL ) );

	/* Walk the module list getting information on each entry in it.  This
	   retrieves the module name, handle, reference count, executable path,
	   and next module */
	count = 0;
	moduleEntry.dwSize = sizeof( MODULEENTRY );
	if( ModuleFirst( &moduleEntry ) )
		do
			{
			addRandomData( randomState, &moduleEntry, sizeof( MODULEENTRY ) );
			count++;
			}
		while( count < 20 && ModuleNext( &moduleEntry ) );

	/* Walk the task list getting information on each entry in it.  This
	   retrieves the task handle, parent task handle, instance handle, stack
	   segment and offset, stack size, number of pending events, task queue,
	   and the name of module executing the task.  We also call TaskGetCSIP()
	   for the code segment and offset of each task if it's safe to do so
	   (note that this call can cause odd things to happen in debuggers and
	   runtime code checkers because of the way TaskGetCSIP() is implemented) */
	count = 0;
	taskEntry.dwSize = sizeof( TASKENTRY );
	if( TaskFirst( &taskEntry ) )
		do
			{
			addRandomData( randomState, &taskEntry, sizeof( TASKENTRY ) );
			if( taskEntry.hTask != GetCurrentTask() )
				addRandomValue( randomState,
								TaskGetCSIP( taskEntry.hTask ) );
			count++;
			}
		while( count < 100 && TaskNext( &taskEntry ) );

	/* Flush any remaining data through */
	endRandomData( randomState, 100 );
	}
Ejemplo n.º 2
0
/*
 * doExitTask:
 *
 * handle NFY_EXITTASK notification
 *
 * If the task was the debuggee, we notify the debugger that the
 * debuggee has terminated.
 */
static BOOL doExitTask( DWORD data )
{
    data = data;

    if( TaskAtNotify == DebugeeTask ) {
        TerminateCSIP = TaskGetCSIP( DebugeeTask );
        PostAppMessage( DebuggerTask, WM_NULL, TASK_ENDED, MAGIC_COOKIE );
    }
    return( FALSE );

} /* doExitTask */
Ejemplo n.º 3
0
/*
 * GetRealCSIP - get the CS:IP of a stopped task, cuz microsoft only tells
 *               you that the task is stopped in the kernel (gee, that's
 *               useful!!)
 */
DWORD GetRealCSIP( HTASK htask, HMODULE *mod )
{
    DWORD               csip;
    STACKTRACEENTRY     se;
    GLOBALENTRY         ge;
    TASKENTRY           te;

    te.dwSize = sizeof( te );
    if( TaskFindHandle( &te, htask ) == NULL ) {
        return( 0L );
    }
    if( mod != NULL ) {
        *mod = te.hModule;
    }

    csip = TaskGetCSIP( htask );
    if( csip == 0L ) {
        return( 0L );
    }
    se.dwSize = sizeof( se );
    if( !StackTraceFirst( &se, htask ) ) {
        return( csip );
    }
    csip = MAKECSIP( se.wCS, se.wIP );
    while( 1 ) {
        se.dwSize = sizeof( se );
        if( !StackTraceNext( &se ) ) {
            break;
        }
        csip = MAKECSIP( se.wCS, se.wIP );
        ge.dwSize = sizeof( ge );
        if( GlobalEntryHandle( &ge, (HGLOBAL)se.wCS ) ) {
            if( ge.hOwner == te.hModule ) {
                break;
            }
        }
    }
    return( csip );

} /* GetRealCSIP */