Changeset 434

Show
Ignore:
Timestamp:
08/31/08 18:35:28 (4 months ago)
Author:
t-bone
Message:

Distilled down to a yes/no of finding the flash DLL running. How do I determine if video is playing? ...

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • VidSave/VidSave.cpp

    r433 r434  
    11#include "stdafx.h" 
    22 
    3 void PrintModules( DWORD processID ) 
     3bool ScanModules( DWORD processID ) 
    44{ 
    55    HMODULE hMods[1024]; 
    66    HANDLE hProcess; 
    77    DWORD cbNeeded; 
    8     unsigned int i; 
    9  
    10     // Print the process identifier. 
    11  
    12     printf( "\nProcess ID: %u\n", processID ); 
    138 
    149    // Get a list of all the modules in this process. 
     10    hProcess=OpenProcess( 
     11        PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID 
     12    ); 
     13    if (NULL==hProcess) return 0; 
    1514 
    16     hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | 
    17                             PROCESS_VM_READ, 
    18                             FALSE, processID ); 
    19     if (NULL == hProcess) 
    20         return; 
    21  
    22     if( EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) 
    23     { 
    24         for ( i = 0; i < (cbNeeded / sizeof(HMODULE)); i++ ) 
    25         { 
     15    if (EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) { 
     16        for (unsigned int i=0; i<cbNeeded/sizeof(HMODULE); i++) { 
    2617            TCHAR szModName[MAX_PATH]; 
    2718 
    28             // Get the full path to the module's file. 
    29  
    30             if ( GetModuleFileNameEx(hProcess, hMods[i], szModName, 
    31                                      sizeof(szModName)/sizeof(TCHAR))) 
    32             { 
    33                 // Print the module name and handle value. 
    34  
    35                 _tprintf(TEXT("\t%s (0x%08X)\n"), 
    36                          szModName, hMods[i]); 
     19            if (GetModuleBaseName( 
     20                hProcess, hMods[i], szModName, sizeof(szModName)/sizeof(TCHAR) 
     21            )) { 
     22                if (0==_wcsicmp(szModName, _T("npswf32.dll"))) { 
     23                    CloseHandle(hProcess); 
     24                    return 1; 
     25                } 
    3726            } 
    3827        } 
    3928    } 
    4029 
    41     CloseHandle( hProcess ); 
     30    CloseHandle(hProcess); 
     31    return 0; 
    4232} 
    4333 
    44 void _tmain( ) 
    45 { 
     34bool FindFlash() { 
     35    DWORD aProcesses[1024], cbNeeded; 
     36 
    4637    // Get the list of process identifiers. 
    47  
    48     DWORD aProcesses[1024], cbNeeded, cProcesses; 
    49     unsigned int i; 
    50  
    51     if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ) 
    52         return; 
     38    if (!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded)) { 
     39        return 0; 
     40    } 
    5341 
    5442    // Calculate how many process identifiers were returned. 
    55     cProcesses = cbNeeded / sizeof(DWORD); 
     43    DWORD cProcesses=cbNeeded/sizeof(DWORD); 
    5644 
    57     // Print the name of the modules for each process. 
     45    for (unsigned int i=0; i<cProcesses; i++) { 
     46        if (ScanModules(aProcesses[i])) return 1; 
     47    } 
    5848 
    59     for ( i = 0; i < cProcesses; i++ ) { 
    60         PrintModules( aProcesses[i] ); 
    61         _getch(); 
    62     } 
     49    return 0; 
    6350} 
     51 
     52void _tmain() { 
     53    printf("Found flash? %s\n", FindFlash()?"Yes":"No"); 
     54    _getch(); 
     55}