Beispiel #1
0
/*
 * NotifyHandler - call back routine for notifications
 */
BOOL __export FAR PASCAL NotifyHandler( WORD id, DWORD data )
{
    notify      *ptr;

    if( id == NFY_TASKIN || id == NFY_TASKOUT ) {
        if( GetCurrentTask() == ourTask ) {
            if( id == NFY_TASKIN ) {
                UnPauseSampler();
            } else {
                PauseSampler();
            }
        }
        return( FALSE );
    }
    PauseSampler();

    ptr = getNotifyData( data );

    switch( id ) {
    case NFY_STARTDLL:
        _fmemcpy( &ptr->startdll, (LPVOID) data, sizeof( NFYSTARTDLL ) );
        MyModuleFindHandle( &ptr->me, ptr->startdll.hModule );
        HandleLibLoad( SAMP_CODE_LOAD, ptr->startdll.hModule );
        break;
    case NFY_STARTTASK:
        if( ourTask == NULL ) { // handle spawned tasks
            ourTask = GetCurrentTask();
            MyTaskFindHandle( &ptr->te, ptr->task );
            MyModuleFindHandle( &ptr->me, ptr->te.hModule );
            HandleLibLoad( SAMP_MAIN_LOAD, ptr->te.hModule );
            StartSampler();
        } else {
            MyTaskFindHandle( &ptr->te, ptr->task );
            MyModuleFindHandle( &ptr->me, ptr->te.hModule );
            HandleLibLoad( SAMP_CODE_LOAD, ptr->te.hModule );
        }
        break;
    case NFY_EXITTASK:
        if( GetCurrentTask() == ourTask ) { // handle spawned tasks
            QuitSampler( &TotalTime );
            SharedMemory->TaskEnded = TRUE;
        }
        break;
    }
    UnPauseSampler();
    return( FALSE );

} /* NotifyHandler */
Beispiel #2
0
/*
 * NotifyHandler - call back routine for notifications
 */
BOOL __export FAR PASCAL NotifyHandler( WORD id, DWORD data )
{
    BOOL        rc;
    LPSTR       src;
    notify      *ptr;

    ptr = getNotifyData( data );

    switch( id ) {
    case NFY_OUTSTR:
        src = (LPSTR) data;
        while( *src ) {
            if( outPos < MAX_STR-1 ) {
                outBuff[ outPos++ ] = *src;
            }
            src++;
        }
        break;
    case NFY_STARTDLL:
        memcpy( &ptr->startdll, (LPVOID) data, sizeof( NFYSTARTDLL ) );
        MyModuleFindHandle( &ptr->me, ptr->startdll.hModule );
        break;
    case NFY_DELMODULE:
        MyModuleFindHandle( &ptr->me, (HMODULE)data );
        break;
    case NFY_RIP:
        memcpy( &ptr->rip, (LPVOID) data, sizeof( NFYRIP ) );
        MyTaskFindHandle( &ptr->te, ptr->task );
        MyModuleFindHandle( &ptr->me, ptr->te.hModule );
        break;
    case NFY_STARTTASK:
        MyTaskFindHandle( &ptr->te, ptr->task );
        MyModuleFindHandle( &ptr->me, ptr->te.hModule );
        break;
    }
    PostMessage( MainWindow, WM_USER, id, (LPARAM)ptr );
    rc = 0;
    if( id == NFY_INCHAR ) {
        rc = 'i';
    }
    if( WDebug386 && !AlwaysRespondToDebugInChar ) {
        if( IsDebuggerExecuting != NULL && IsDebuggerExecuting() ) {
            rc = 0;
        }
    }
    return( rc );

} /* NotifyHandler */
Beispiel #3
0
/*
 * HandleLibLoad - process library loaded
 */
void HandleLibLoad( int type, HANDLE hmod )
{
    static MODULEENTRY          me;

    if( MyModuleFindHandle( &me, hmod ) ) {
        newModule( hmod, me.szExePath, type );
    }

} /* HandleLibLoad */
Beispiel #4
0
/*
 * FindModuleName - find the name of the owner of a piece of memory.
 *                  modhdl may be a task id or a module id so we try both
 */
static void FindModuleName( char *buf, HANDLE modhdl ) {

    MODULEENTRY         me;
    TASKENTRY           te;

    if( MyModuleFindHandle( &me, modhdl ) ) {
        strcpy( buf, me.szModule );
        buf[MAX_MODULE_NAME]=0;
    } else if( MyTaskFindHandle( &te, modhdl ) ) {
        strcpy( buf, te.szModule );
        buf[MAX_MODULE_NAME]=0;
    } else {
        buf[0] = '\0';
    }
}
Beispiel #5
0
BOOL GetDGroupItem( char *owner, heap_list *hl ) {

    MODULEENTRY me;

    MyGlobalFirst( &( hl->info.ge ), GLOBAL_ALL );
    do {
        if( hl->info.ge.wType == GT_DGROUP ) {
            if( hl->info.ge.hOwner != NULL ) {
                if( MyModuleFindHandle( &me, hl->info.ge.hOwner ) ) {
                    if( strcmp( me.szModule, owner ) == 0 ) {
                        strcpy( hl->szModule , owner );
                        hl->szModule[MAX_MODULE_NAME]=0;
                        return( TRUE );
                    }
                }
            }
        }
    } while( MyGlobalNext( &hl->info.ge, GLOBAL_ALL ) );
    return( FALSE );
}