コード例 #1
0
ファイル: ClientCommands.cpp プロジェクト: qaisjp/green-candy
void COMMAND_Modules( const char *szCmdLine )
{
    // Get the base address of the requested module
    // Take a snapshot of all modules in the specified process. 
    HANDLE hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, GetCurrentProcessId() );

    if ( hModuleSnap == INVALID_HANDLE_VALUE )
        return;

    // Set the size of the structure before using it. 
    MODULEENTRY32 ModuleEntry; 
    ModuleEntry.dwSize = sizeof(MODULEENTRY32); 

    // Retrieve information about the first module, 
    // and exit if unsuccessful 
    if ( Module32First( hModuleSnap, &ModuleEntry ) ) 
    {
        // Create a file
        CFile *file = modFileRoot->Open( "modules.txt", "w" );

        if ( !file )
            return;

        do
        {
            // Print it
            file->Printf( "** MODULE **\n"
                             "Name: %s\n"
                             "Base: 0x%P\n"
                             "Size: 0x%P\n"
                             "\n",
                             ModuleEntry.szModule,
                             ModuleEntry.modBaseAddr,
                             ModuleEntry.modBaseSize );
        } while ( Module32Next( hModuleSnap, &ModuleEntry ) );

        // Close it
        delete file;
    }

    // Close the snapshot object
    CloseHandle( hModuleSnap ); 
}
コード例 #2
0
ファイル: ClientCommands.cpp プロジェクト: qaisjp/green-candy
void COMMAND_DumpPlayers( const char *szCmdLine )
{
    // Create a file to dump to
    CFile *file = modFileRoot->Open( SString( "dump_%i.txt", GetTickCount32() ), "w" );

    if ( !file )
    {
        g_pCore->GetConsole()->Print( "dumpplayers: Unable to create file" );
        return;
    }

    // Write time now
    file->Printf( "Comments: %s\n", szCmdLine );
    file->Printf( "Time now: %u\n\n", CClientTime::GetTime() );
    file->Printf( "Objectcount: %u\n", g_pClientGame->GetObjectManager()->Count() );
    file->Printf( "Playercount: %u\n", g_pClientGame->GetPlayerManager()->Count() );
    file->Printf( "Vehiclecount: %u\n\n", g_pClientGame->GetVehicleManager()->Count() );

    file->Printf( "Used building pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( BUILDING_POOL ) );
    file->Printf( "Used ped pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( PED_POOL ) );
    file->Printf( "Used object pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( OBJECT_POOL ) );
    file->Printf( "Used dummy pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( DUMMY_POOL ) );
    file->Printf( "Used vehicle pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( VEHICLE_POOL ) );
    file->Printf( "Used col model pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( COL_MODEL_POOL ) );
    file->Printf( "Used task pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( TASK_POOL ) );
    file->Printf( "Used event pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( EVENT_POOL ) );
    file->Printf( "Used task alloc pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( TASK_ALLOCATOR_POOL ) );
    file->Printf( "Used ped intelli pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( PED_INTELLIGENCE_POOL ) );
    file->Printf( "Used ped attractor pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( PED_ATTRACTOR_POOL ) );
    file->Printf( "Used entry info node pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( ENTRY_INFO_NODE_POOL ) );
    file->Printf( "Used node route pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( NODE_ROUTE_POOL ) );
    file->Printf( "Used patrol route pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( PATROL_ROUTE_POOL ) );
    file->Printf( "Used point route pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( POINT_ROUTE_POOL ) );
    file->Printf( "Used point double link pool: %u\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( POINTER_DOUBLE_LINK_POOL ) );
    file->Printf( "Used point single link pool: %u\n\n\n", g_pGame->GetPools()->GetNumberOfUsedSpaces( POINTER_SINGLE_LINK_POOL ) );

    // Loop through all players
    vector <CClientPlayer*> ::const_iterator iter = g_pClientGame->GetPlayerManager()->IterBegin();
    for ( ; iter != g_pClientGame->GetPlayerManager()->IterEnd(); iter++ )
    {
        // Write the player dump
        DumpPlayer( *iter, file );
    }

    // End of the dump. Close it
    delete file;

    g_pCore->GetConsole()->Print( "dumpplayers: Dumping successfull" );
}