Example #1
0
/*  Display pin */
CDisp::CDisp(IPin *pPin)
{
    PIN_INFO pi;
    TCHAR str[MAX_PIN_NAME];
    CLSID clsid;

    if (pPin) {
       pPin->QueryPinInfo(&pi);
       pi.pFilter->GetClassID(&clsid);
       QueryPinInfoReleaseFilter(pi);
      #ifndef UNICODE
       WideCharToMultiByte(GetACP(), 0, pi.achName, lstrlenW(pi.achName) + 1,
                           str, MAX_PIN_NAME, NULL, NULL);
      #else
       (void)StringCchCopy(str, NUMELMS(str), pi.achName);
      #endif
    } else {
       (void)StringCchCopy(str, NUMELMS(str), TEXT("NULL IPin"));
    }

    size_t len = lstrlen(str)+64;
    m_pString = (PTCHAR) new TCHAR[len];
    if (!m_pString) {
	return;
    }

    #ifdef UNICODE
    LPCTSTR FORMAT_STRING = TEXT("%S(%s)");
    #else
    LPCTSTR FORMAT_STRING = TEXT("%s(%s)");
    #endif 

    (void)StringCchPrintf(m_pString, len, FORMAT_STRING, GuidNames[clsid], str);
}
Example #2
0
// clashes with REFERENCE_TIME
CDisp::CDisp(LONGLONG ll, int Format)
{
    // note: this could be combined with CDisp(LONGLONG) by
    // introducing a default format of CDISP_REFTIME
    LARGE_INTEGER li;
    li.QuadPart = ll;
    switch (Format) {
	case CDISP_DEC:
	{
	    TCHAR  temp[20];
	    int pos=20;
	    temp[--pos] = 0;
	    int digit;
	    // always output at least one digit
	    do {
		// Get the rightmost digit - we only need the low word
	        digit = li.LowPart % 10;
		li.QuadPart /= 10;
		temp[--pos] = (TCHAR) digit+L'0';
	    } while (li.QuadPart);
	    (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%s"), temp+pos);
	    break;
	}
	case CDISP_HEX:
	default:
	    (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("0x%X%8.8X"), li.HighPart, li.LowPart);
    }
};
Example #3
0
//
// warning -- this function is implemented twice for ansi applications
// linking to the unicode library
//
void WINAPI DbgLogInfo(DWORD Type,DWORD Level,__format_string LPCSTR pFormat,...)
{
    /* Check the current level for this type combination */

    BOOL bAccept = DbgCheckModuleLevel(Type,Level);
    if (bAccept == FALSE) {
        return;
    }

    TCHAR szInfo[2000];

    /* Format the variable length parameter list */

    va_list va;
    va_start(va, pFormat);

    (void)StringCchPrintf(szInfo, NUMELMS(szInfo),
             TEXT("%s(tid %x) %8d : "),
             m_ModuleName,
             GetCurrentThreadId(), timeGetTime() - dwTimeOffset);

    CHAR szInfoA[2000];
    WideCharToMultiByte(CP_ACP, 0, szInfo, -1, szInfoA, NUMELMS(szInfoA), 0, 0);

    (void)StringCchVPrintfA(szInfoA + lstrlenA(szInfoA), NUMELMS(szInfoA) - lstrlenA(szInfoA), pFormat, va);
    (void)StringCchCatA(szInfoA, NUMELMS(szInfoA), "\r\n");

    WCHAR wszOutString[2000];
    MultiByteToWideChar(CP_ACP, 0, szInfoA, -1, wszOutString, NUMELMS(wszOutString));
    DbgOutString(wszOutString);

    va_end(va);
}
Example #4
0
// 
// warning -- this function is implemented twice for ansi applications
// linking to the unicode library
// 
void WINAPI DbgLogInfo(DWORD Type,DWORD Level,const TCHAR *pFormat,...)
{
    
    /* Check the current level for this type combination */

    BOOL bAccept = DbgCheckModuleLevel(Type,Level);
    if (bAccept == FALSE) {
        return;
    }

    TCHAR szInfo[2000];

    /* Format the variable length parameter list */

    va_list va;
    va_start(va, pFormat);

    (void)StringCchCopy(szInfo, NUMELMS(szInfo), m_ModuleName);
    size_t len = lstrlen(szInfo);
    (void)StringCchPrintf(szInfo + len, NUMELMS(szInfo) - len,
             TEXT("(tid %x) %8d : "),
             GetCurrentThreadId(), timeGetTime() - dwTimeOffset);
    len = lstrlen(szInfo);

    (void)StringCchVPrintf(szInfo + len, NUMELMS(szInfo) - len, pFormat, va);

    (void)StringCchCat(szInfo, NUMELMS(szInfo), TEXT("\r\n"));
    DbgOutString(szInfo);

    va_end(va);
}
BOOL CreateHiddenWindow( HINSTANCE hInstance, TCHAR *szFile )
{
    TCHAR szTitle[MAX_PATH + sizeof(CUTSCENE_NAME) + 5];

    // Set up and register window class
    WNDCLASS wc      = {0};
    wc.lpfnWndProc   = (WNDPROC) WindowProc;
    wc.hInstance     = hInstance;
    wc.lpszClassName = CUTSCENE_NAME;
    if (!RegisterClass(&wc))
        return FALSE;

    // Prevent buffer overrun by restricting size of title to MAX_PATH
    (void)StringCchPrintf(szTitle, NUMELMS(szTitle), TEXT("%s: \0"), CUTSCENE_NAME);
    StringCchCatN(szTitle, NUMELMS(szTitle), szFile, MAX_PATH);

    // Create a window of zero size that will serve as the sink for
    // keyboard input.  If this media file has a video component, then
    // a second ActiveMovie window will be displayed in which the video
    // will be rendered.  Setting keyboard focus on this application window
    // will allow the user to move the video window around the screen, make
    // it full screen, resize, center, etc. independent of the application
    // window.  If the media file has only an audio component, then this will
    // be the only window created.
    g_hwndMain = CreateWindowEx(
        0, CUTSCENE_NAME, szTitle,
        0,            // not visible
        0, 0, 0, 0,
        NULL, NULL, hInstance, NULL );

    return (g_hwndMain != NULL);
}
void UpdateMainTitle(void)
{
    TCHAR szTitle[MAX_PATH]={0}, szFile[MAX_PATH]={0};
    HRESULT hr;

    // If no file is loaded, just show the application title
    if (g_szFileName[0] == L'\0')
    {
        hr = StringCchCopy(szTitle, NUMELMS(szTitle), APPLICATIONNAME);
    }

    // Otherwise, show useful information
    else
    {
        // Get file name without full path
        GetFilename(g_szFileName, szFile);

        // Update the window title to show filename and play state
        hr = StringCchPrintf(szTitle, NUMELMS(szTitle), TEXT("Watermark - %s %s%s\0\0"),
                szFile,
                (g_lVolume == VOLUME_SILENCE) ? TEXT("(Muted)\0") : TEXT("\0"),
                (g_psCurrent == Paused) ? TEXT("(Paused)\0") : TEXT("\0"));
    }

    SetWindowText(ghApp, szTitle);
}
Example #7
0
void WINAPI DbgDumpObjectRegister()
{
    TCHAR szInfo[iDEBUGINFO];

    /* Grab the list critical section */

    EnterCriticalSection(&m_CSDebug);
    ObjectDesc *pObject = pListHead;

    /* Scan the object list displaying the name and cookie */

    DbgLog((LOG_MEMORY,2,TEXT("")));
    DbgLog((LOG_MEMORY,2,TEXT("   ID             Object Description")));
    DbgLog((LOG_MEMORY,2,TEXT("")));

    while (pObject) {
        if(pObject->m_wszName) {
            (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("%5d (%p) %30ls"),pObject->m_dwCookie, &pObject, pObject->m_wszName);
        } else {
            (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("%5d (%p) %30hs"),pObject->m_dwCookie, &pObject, pObject->m_szName);
        }
        DbgLog((LOG_MEMORY,2,szInfo));
        pObject = pObject->m_pNext;
    }

    (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("Total object count %5d"),m_dwObjectCount);
    DbgLog((LOG_MEMORY,2,TEXT("")));
    DbgLog((LOG_MEMORY,1,szInfo));
    LeaveCriticalSection(&m_CSDebug);
}
/*****************************Private*Routine******************************\
* GetRecentFiles
*
* Reads at most MAX_RECENT_FILES from the app's registry entry. 
* Returns the number of files actually read.  
* Updates the File menu to show the "recent" files.
*
\**************************************************************************/
int
GetRecentFiles(
    int iLastCount,
    int iMenuPosition   // Menu position of start of MRU list
    )
{
    int     i;
    TCHAR   FileName[MAX_PATH];
    TCHAR   szKey[32];
    HMENU   hSubMenu;

    //
    // Delete the files from the menu
    //
    hSubMenu = GetSubMenu(GetMenu(hwndApp), 0);

    // Delete the separator at the requested position and all the other 
    // recent file entries
    if(iLastCount != 0)
    {
        DeleteMenu(hSubMenu, iMenuPosition, MF_BYPOSITION);

        for(i = 1; i <= iLastCount; i++)
        {
            DeleteMenu(hSubMenu, ID_RECENT_FILE_BASE + i, MF_BYCOMMAND);
        }
    }

    for(i = 1; i <= MAX_RECENT_FILES; i++)
    {
        DWORD   len;
        TCHAR   szMenuName[MAX_PATH + 3];

        (void)StringCchPrintf(szKey, NUMELMS(szKey), TEXT("File %d\0"), i);

        len = ProfileStringIn(szKey, TEXT(""), FileName, MAX_PATH * sizeof(TCHAR));
        if(len == 0)
        {
            i = i - 1;
            break;
        }

        StringCchCopy(aRecentFiles[i - 1], NUMELMS(aRecentFiles[i-1]), FileName);
        (void)StringCchPrintf(szMenuName, NUMELMS(szMenuName), TEXT("&%d %s\0"), i, FileName);

        if(i == 1)
        {
            InsertMenu(hSubMenu, iMenuPosition, MF_SEPARATOR | MF_BYPOSITION, (UINT)-1, NULL);
        }

        InsertMenu(hSubMenu, iMenuPosition + i, MF_STRING | MF_BYPOSITION,
            ID_RECENT_FILE_BASE + i, szMenuName);
    }

    //
    // i is the number of recent files in the array.
    //
    return i;
}
Example #9
0
CDisp::CDisp(double d)
{
#ifdef DEBUG
    (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%.16g"), d);
#else
    (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%d.%03d"), (int) d, (int) ((d - (int) d) * 1000));
#endif
}
void CApp::SetAppValues(HINSTANCE hInst, PTSTR szAppName, int iAppTitleResId) 
{
    DbgLog((LOG_TRACE, 5, TEXT("CApp::SetAppValues()"))) ;

        m_hInstance = hInst ;

    StringCchCopy(m_szAppName, NUMELMS(m_szAppName), APPNAME);
    LoadString(m_hInstance, IDS_APP_TITLE, m_szAppTitle, NUMELMS(m_szAppTitle)) ;
}
///////////////////////////////////////////////////////////////
//
// CPerfStatFunctionTimingImpl::DoPulse
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatFunctionTimingImpl::DoPulse ( void )
{
    // Maybe turn off stats gathering if nobody is watching
    if ( m_bIsActive && m_TimeSinceLastViewed.Get () > 15000 )
        SetActive ( false );

    // Do nothing if not active
    if ( !m_bIsActive )
    {
        m_TimingMap.empty ();
        return;
    }

    // Check if time to cycle the stats
    if ( m_TimeSinceUpdate.Get () >= 5000 )
    {
        m_TimeSinceUpdate.Reset ();

        // For each timed function
        for ( std::map < SString, SFunctionTimingInfo >::iterator iter = m_TimingMap.begin () ; iter != m_TimingMap.end () ; )
        {
            SFunctionTimingInfo& item = iter->second;
            // Update history
            item.iPrevIndex = ( item.iPrevIndex + 1 ) % NUMELMS( item.history );
            item.history[ item.iPrevIndex ] = item.now5s;

            // Reset accumulator
            item.now5s.uiNumCalls = 0;
            item.now5s.fTotalMs = 0;
            item.now5s.fPeakMs = 0;

            // Recalculate last 60 second stats
            item.prev60s.uiNumCalls = 0;
            item.prev60s.fTotalMs = 0;
            item.prev60s.fPeakMs = 0;
            for ( uint i = 0 ; i < NUMELMS( item.history ) ; i++ )
            {
                const STiming& slot = item.history[i];
                item.prev60s.uiNumCalls += slot.uiNumCalls;
                item.prev60s.fTotalMs += slot.fTotalMs;
                item.prev60s.fPeakMs = Max ( item.prev60s.fPeakMs, slot.fPeakMs );
            }

            // Remove from map if no calls in the last 60s
            if ( item.prev60s.uiNumCalls == 0 )
                m_TimingMap.erase ( iter++ );
            else
                ++iter;
        }
    }

    //
    // Update PeakUs threshold
    //
    m_PeakUsRequiredHistory.RemoveOlderThan ( 10000 );
    m_PeakUsThresh = m_PeakUsRequiredHistory.GetLowestValue ( DEFAULT_THRESH_MS * 1000 );
}
/*****************************Private*Routine******************************\
* SetRecentFiles
*
* Writes the most recent files to the registry.
* Purges the oldest file if necessary.
*
\**************************************************************************/
int
SetRecentFiles(
    TCHAR *FileName,    // File name to add
    int iCount,         // Current count of files
    int iMenuPosition   // Menu position of start of MRU list
    )
{
    TCHAR   FullPathFileName[MAX_PATH];
    TCHAR   *lpFile=0;
    TCHAR   szKey[32];
    int     iCountNew, i;

    //
    // Check for duplicates - we don't allow them
    //
    for(i = 0; i < iCount; i++)
    {
        if(0 == lstrcmpi(FileName, aRecentFiles[i]))
        {
            return iCount;
        }
    }

    //
    // Throw away the oldest entry
    //
    MoveMemory(&aRecentFiles[1], &aRecentFiles[0],
               sizeof(aRecentFiles) - sizeof(aRecentFiles[1]));

    //
    // Copy in the full path of the new file.
    //
    GetFullPathName(FileName, MAX_PATH, FullPathFileName, &lpFile);
    StringCchCopy(aRecentFiles[0], NUMELMS(aRecentFiles[0]), FullPathFileName);

    //
    // Update the count of files, saturate to MAX_RECENT_FILES.
    //
    iCountNew = min(iCount + 1, MAX_RECENT_FILES);

    //
    // Clear the old stuff and the write out the recent files to disk
    //
    for(i = 1; i <= iCountNew; i++)
    {
        (void)StringCchPrintf(szKey, NUMELMS(szKey),TEXT("File %d\0"), i);
        ProfileStringOut(szKey, aRecentFiles[i - 1]);
    }

    //
    // Update the file menu
    //
    GetRecentFiles(iCount, iMenuPosition);

    return iCountNew;  // the updated count of files.
}
BOOL CALLBACK CTitleDlg::TitleDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    static CTitleDlg * pThis; 

    switch (message)
    {
        case WM_INITDIALOG:
        {
            pThis = reinterpret_cast<CTitleDlg *>(lParam); // get a pointer to the calling object
        
            // set default values
            TCHAR buf[10];
            HRESULT hr = StringCchPrintf(buf, NUMELMS(buf), TEXT("%u\0"), pThis->m_ulTitle); 
            SetDlgItemText(hDlg, IDC_PLAYCHAPTER, buf);
            hr = StringCchPrintf(buf, NUMELMS(buf), TEXT("%u\0"), pThis->m_ulChapter); 
            SetDlgItemText(hDlg, IDC_PLAYCHAPTER, buf);
        
            //set up spin control
            HWND hEBox = GetDlgItem(hDlg, IDC_PLAYCHAPTER);
            CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT,
                10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 999, 1, 1);

            hEBox = GetDlgItem(hDlg, IDC_PLAYTITLE);
            CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT,
                10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 99, 1, 1);

            return TRUE;
        }

        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
                case IDOK:
                {
                    // Set the Title specified by the user
                    TCHAR buf[10];
                    GetDlgItemText(hDlg, IDC_PLAYCHAPTER, buf, sizeof(buf)/sizeof(TCHAR));
                    pThis->m_ulChapter = _ttoi(buf);

                    GetDlgItemText(hDlg, IDC_PLAYTITLE, buf, sizeof(buf)/sizeof(TCHAR));
                    pThis->m_ulTitle = _ttoi(buf);

                    EndDialog(hDlg, TRUE);
                    return TRUE;
                }

                case IDCANCEL:
                    EndDialog(hDlg, FALSE);
                    return TRUE;
            }
            break;
    }

    return FALSE;
}
Example #14
0
CDisp::CDisp(REFCLSID clsid)
{
    WCHAR strClass[CHARS_IN_GUID+1];
    StringFromGUID2(clsid, strClass, sizeof(strClass) / sizeof(strClass[0]));
    ASSERT(sizeof(m_String)/sizeof(m_String[0]) >= CHARS_IN_GUID+1);
    #ifdef UNICODE 
    (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%s"), strClass);
    #else
    (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%S"), strClass);
    #endif  
};
Example #15
0
////////////////////////////////////////////////////////////
//
// CClientSound::SetFxEffect
//
//
//
////////////////////////////////////////////////////////////
bool CClientSound::SetFxEffect ( uint uiFxEffect, bool bEnable )
{
    if ( uiFxEffect >= NUMELMS( m_EnabledEffects ) )
        return false;

    m_EnabledEffects[uiFxEffect] = bEnable;

    if ( m_pAudio )
        m_pAudio->SetFxEffects ( &m_EnabledEffects[0], NUMELMS( m_EnabledEffects ) );

    return true;
}
Example #16
0
LRESULT CALLBACK TextDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static TCHAR szSaveText[DYNAMIC_TEXT_SIZE]={0};

    switch (message)
    {
        case WM_INITDIALOG:
            // Save current dynamic text so that we can temporarily modify
            // the dynamic text during font adjustment
            _tcsncpy(szSaveText, g_szAppText, NUMELMS(szSaveText));
            SendMessage(GetDlgItem(hWnd, IDC_EDIT_TEXT), EM_LIMITTEXT, DYNAMIC_TEXT_SIZE, 0L);
            SetWindowText(GetDlgItem(hWnd, IDC_EDIT_TEXT), g_szAppText);
            return TRUE;

        case WM_COMMAND:
            switch (wParam)
            {
                case IDOK:
                {
                    TCHAR szText[DYNAMIC_TEXT_SIZE];
                    GetWindowText(GetDlgItem(hWnd, IDC_EDIT_TEXT), szText, DYNAMIC_TEXT_SIZE);
                    _tcsncpy(g_szAppText, szText, NUMELMS(g_szAppText));
                    BlendApplicationText(ghApp, g_szAppText);
                    EndDialog(hWnd, TRUE);
                    return TRUE;
                }
                break;

                case IDCANCEL:
                    // Restore the original text in case it was modified
                    // and previewed while adjusting the font
                    _tcsncpy(g_szAppText, szSaveText, NUMELMS(g_szAppText));
                    BlendApplicationText(ghApp, g_szAppText);
                    EndDialog(hWnd, TRUE);
                    break;

                case IDC_SET_FONT:
                {
                    TCHAR szTempText[DYNAMIC_TEXT_SIZE]={0};

                    // Change the current font
                    g_hFont = UserSelectFont();   

                    // Start displaying the text that is currently in the edit box
                    GetWindowText(GetDlgItem(hWnd, IDC_EDIT_TEXT), szTempText, DYNAMIC_TEXT_SIZE);
                    BlendApplicationText(ghApp, szTempText);
                }
                break;
            }
            break;
    }
    return FALSE;
}
Example #17
0
//
// Try to make a path relative to the 'resources/' directory
//
SString SharedUtil::ConformResourcePath ( const char* szRes, bool bConvertToUnixPathSep )
{
    // Remove up to first '/resources/'
    // else
    // remove up to first '/resource-cache/unzipped/'
    // else
    // remove up to first '/http-client-protected-files/'
    // else
    // remove up to first '/deathmatch/'
    // else
    // if starts with '...'
    //  remove up to first '/'

    SString strDelimList[] = { "/resources/", "/resource-cache/unzipped/", "/http-client-files-protected/", "/deathmatch/" };
    SString strText = szRes ? szRes : "";
    char cPathSep;

    // Handle which path sep char
#ifdef WIN32
    if ( !bConvertToUnixPathSep )
    {
        cPathSep = '\\';
        for ( unsigned int i = 0 ; i < NUMELMS ( strDelimList ) ; i++ )
            strDelimList[i] = strDelimList[i].Replace ( "/", "\\" );
        strText = strText.Replace ( "/", "\\" );
    }
    else
#endif
    {
        cPathSep = '/';
        for ( unsigned int i = 0 ; i < NUMELMS ( strDelimList ) ; i++ )
            strDelimList[i] = strDelimList[i].Replace ( "\\", "/" );
        strText = strText.Replace ( "\\", "/" );
    }

    for ( unsigned int i = 0 ; i < NUMELMS ( strDelimList ) ; i++ )
    {
        // Remove up to first occurrence
        int iPos = strText.find ( strDelimList[i] );
        if ( iPos >= 0 )
            return strText.substr ( iPos + strDelimList[i].length () );
    }

    if ( strText.substr ( 0, 3 ) == "..." )
    {
        // Remove up to first '/'
        int iPos = strText.find ( cPathSep );
        if ( iPos >= 0 )
            return strText.substr ( iPos + 1 );
    }

    return strText;
}
Example #18
0
    void DbgMsg( char* szMessage, ... )
    {
        char szFullMessage[MAX_PATH];
        char szFormatMessage[MAX_PATH];

        // format message
        va_list ap;
        va_start(ap, szMessage);
        (void)StringCchVPrintfA( szFormatMessage, NUMELMS(szFormatMessage), szMessage, ap );
        va_end(ap);
        (void)StringCchCatA( szFormatMessage, NUMELMS(szFormatMessage), "\n" );
        (void)StringCchCopyA( szFullMessage, NUMELMS(szFullMessage), "~*~*~*~*~*~ " );
        (void)StringCchCatA( szFullMessage, NUMELMS(szFullMessage), szFormatMessage );
        OutputDebugStringA( szFullMessage );
    }
Example #19
0
STDAPI
AMovieSetupUnregisterServer( CLSID clsServer )
{
  // convert CLSID uuid to string and write
  // out subkey CLSID\{}
  //
  OLECHAR szCLSID[CHARS_IN_GUID];
  HRESULT hr = StringFromGUID2( clsServer
                              , szCLSID
                              , CHARS_IN_GUID );
  ASSERT( SUCCEEDED(hr) );

  TCHAR achBuffer[MAX_KEY_LEN];
  (void)StringCchPrintf( achBuffer, NUMELMS(achBuffer), CLSID_KEY_FORMAT_STRING, szCLSID );

  // delete subkey
  //

  hr = EliminateSubKey( HKEY_CLASSES_ROOT, achBuffer );
  ASSERT( SUCCEEDED(hr) );

  // return
  //
  return NOERROR;
}
Example #20
0
///////////////////////////////////////////////////////////////
//
// CMemStats::UpdateFrameStats
//
// Update values that are measured each frame
//
///////////////////////////////////////////////////////////////
void CMemStats::UpdateFrameStats ( void )
{

    m_MemStatsNow.d3dMemory = g_pDeviceState->MemoryState;

    static CProxyDirect3DDevice9::SResourceMemory* const nowList[] = {    &m_MemStatsNow.d3dMemory.StaticVertexBuffer, &m_MemStatsNow.d3dMemory.DynamicVertexBuffer,
                                                                                &m_MemStatsNow.d3dMemory.StaticIndexBuffer, &m_MemStatsNow.d3dMemory.DynamicIndexBuffer,
                                                                                &m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture,
                                                                                &m_MemStatsNow.d3dMemory.Effect };

    static CProxyDirect3DDevice9::SResourceMemory* const maxList[] = {    &m_MemStatsMax.d3dMemory.StaticVertexBuffer, &m_MemStatsMax.d3dMemory.DynamicVertexBuffer,
                                                                                &m_MemStatsMax.d3dMemory.StaticIndexBuffer, &m_MemStatsMax.d3dMemory.DynamicIndexBuffer,
                                                                                &m_MemStatsMax.d3dMemory.StaticTexture, &m_MemStatsMax.d3dMemory.DynamicTexture,
                                                                                &m_MemStatsMax.d3dMemory.Effect };

    CProxyDirect3DDevice9::SResourceMemory* const prevList[] = {   &m_MemStatsPrev.d3dMemory.StaticVertexBuffer, &m_MemStatsPrev.d3dMemory.DynamicVertexBuffer,
                                                                                &m_MemStatsPrev.d3dMemory.StaticIndexBuffer, &m_MemStatsPrev.d3dMemory.DynamicIndexBuffer,
                                                                                &m_MemStatsPrev.d3dMemory.StaticTexture, &m_MemStatsPrev.d3dMemory.DynamicTexture,
                                                                                &m_MemStatsPrev.d3dMemory.Effect };

    for ( uint i = 0 ; i < NUMELMS( nowList ) ; i++ )
    {
        maxList[i]->iLockedCount = std::max ( maxList[i]->iLockedCount, nowList[i]->iLockedCount - prevList[i]->iLockedCount );
        prevList[i]->iLockedCount = nowList[i]->iLockedCount;
    }
}
Example #21
0
void WINAPI DbgBreakPoint(LPCSTR pCondition,LPCSTR pFileName,INT iLine)
{
    if(g_fUseKASSERT)
    {
        DbgKernelAssert(pCondition, pFileName, iLine);
    }
    else
    {
        TCHAR szInfo[iDEBUGINFO];

        (void)StringCchPrintf(szInfo, NUMELMS(szInfo),TEXT("%hs \nAt line %d of %hs\nContinue? (Cancel to debug)"),
                 pCondition, iLine, pFileName);

        INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("Hard coded break point"),
                                          MB_SYSTEMMODAL |
                                          MB_ICONHAND |
                                          MB_YESNOCANCEL |
                                          MB_SETFOREGROUND);
        switch (MsgId)
        {
          case IDNO:              /* Kill the application */

              FatalAppExit(FALSE, TEXT("Application terminated"));
              break;

          case IDCANCEL:          /* Break into the debugger */

              DebugBreak();
              break;

          case IDYES:             /* Ignore break point continue execution */
              break;
        }
    }
}
Example #22
0
void WINAPI DbgBreakPoint(LPCTSTR pFileName,INT iLine,__format_string LPCTSTR szFormatString,...)
{
    // A debug break point message can have at most 2000 characters if
    // ANSI or UNICODE characters are being used.  A debug break point message
    // can have between 1000 and 2000 double byte characters in it.  If a
    // particular message needs more characters, then the value of this constant
    // should be increased.
    const DWORD MAX_BREAK_POINT_MESSAGE_SIZE = 2000;

    TCHAR szBreakPointMessage[MAX_BREAK_POINT_MESSAGE_SIZE];

    va_list va;
    va_start( va, szFormatString );

    HRESULT hr = StringCchVPrintf( szBreakPointMessage, NUMELMS(szBreakPointMessage), szFormatString, va );

    va_end(va);

    if( FAILED(hr) ) {
        DbgBreak( "ERROR in DbgBreakPoint().  The variable length debug message could not be displayed because StringCchVPrintf() failed." );
        return;
    }

    ::DbgBreakPoint( szBreakPointMessage, pFileName, iLine );
}
//////////////////////////////////////////////////////////
//
// GetPatchRequirementAltModules
//
// Return true if checksum for some dlls will cause problems
//
//////////////////////////////////////////////////////////
bool GetPatchRequirementAltModules( void )
{
    // Only do file check once per launch
    static bool bDone = false;
    static bool bMismatch = false;

    if ( !bDone )
    {
        SString strGTAPath = GetGTAPath();
        if ( !strGTAPath.empty() )
        {
            struct {
                const char* szMd5;
                const char* szFilename;
            } fileList[] = { { "309D860FC8137E5FE9E7056C33B4B8BE", "eax.dll" },
                             { "0602F672BA595716E64EC4040E6DE376", "ogg.dll" },
                             { "2840F08DD9753A5B13C60D6D1C165C9A", "vorbis.dll" },
                             { "2B7B803311D2B228F065C45D13E1AEB2", "vorbisfile.dll" } };

            for ( uint i = 0 ; i < NUMELMS( fileList ) ; i++ )
            {
                SString strPathFilename = PathJoin( strGTAPath, fileList[i].szFilename );
                SString strMd5 = CMD5Hasher::CalculateHexString( strPathFilename );
                if ( strMd5.CompareI( fileList[i].szMd5 ) == false )
                    bMismatch = true;
            }
        }
        bDone = true;

        if ( bMismatch )
            WriteDebugEvent( "PatchRequirementAltModules: Need to use alt modules" );
    }
    return bMismatch;
}
Example #24
0
HRESULT addGraphToRot(IUnknown *pUnkGraph, DWORD *pdwRegister) 
{
	IMoniker * pMoniker;
	IRunningObjectTable *pROT;
	WCHAR wsz[128];
	HRESULT hr;

	if (!pUnkGraph || !pdwRegister)
		return E_POINTER;

	if (FAILED(GetRunningObjectTable(0, &pROT)))
		return E_FAIL;

	hr = StringCchPrintfW(wsz, NUMELMS(wsz), L"FilterGraph %08x pid %08x\0", (DWORD_PTR)pUnkGraph, 
		GetCurrentProcessId());

	hr = CreateItemMoniker(L"!", wsz, &pMoniker);
	if (SUCCEEDED(hr)) 
	{
		// Use the ROTFLAGS_REGISTRATIONKEEPSALIVE to ensure a strong reference
		// to the object.  Using this flag will cause the object to remain
		// registered until it is explicitly revoked with the Revoke() method.
		//
		// Not using this flag means that if GraphEdit remotely connects
		// to this graph and then GraphEdit exits, this object registration 
		// will be deleted, causing future attempts by GraphEdit to fail until
		// this application is restarted or until the graph is registered again.
		hr = pROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, pUnkGraph, 
			pMoniker, pdwRegister);
		pMoniker->Release();
	}

	pROT->Release();
	return hr;
}
Example #25
0
//////////////////////////////////////////////////////////
//
// EndD3DStuff
//
// Clean up
//
//////////////////////////////////////////////////////////
void EndD3DStuff( void )
{
    for( uint i = 0 ; i < NUMELMS( pD3DVertexDeclarations ) ; i++ )
        SAFE_RELEASE( pD3DVertexDeclarations[i] );
    SAFE_RELEASE( pD3DDevice9 );
    SAFE_RELEASE( pD3D9 );
}
Example #26
0
VOID
PerflogReadModuleLevel(
    HINSTANCE hInstance
    )
{
    LONG lReturn;                   // Create key return value
    TCHAR szInfo[iDEBUGINFO];       // Constructs key names
    TCHAR szFullName[iDEBUGINFO];   // Load the full path and module name
    HKEY hModuleKey;                // Module key handle
    LPTSTR pName;                   // Searches from the end for a backslash
    DWORD dwKeySize, dwKeyType, dwKeyValue;

    DWORD dwSize = GetModuleFileName(
        (hInstance ? hInstance : GetModuleHandle( NULL )),
        szFullName,
        iDEBUGINFO );

    if (0 == dwSize || iDEBUGINFO == dwSize) {
        return;
    }

    pName = _tcsrchr(szFullName,'\\');
    if (pName == NULL) {
        pName = szFullName;
    } else {
        pName++;
    }

    /* Construct the base key name */
    (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("SOFTWARE\\Debug\\%s"),pName);

    /* Open the key for this module */
    lReturn =
        RegOpenKeyEx(
            HKEY_LOCAL_MACHINE,   // Handle of an open key
            szInfo,               // Address of subkey name
            (DWORD) 0,            // Reserved value
            KEY_QUERY_VALUE,      // Desired security access
            &hModuleKey );        // Opened handle buffer

    if (lReturn != ERROR_SUCCESS) {
        return;
    }

    dwKeySize = sizeof(DWORD);
    lReturn = RegQueryValueEx(
        hModuleKey,                 // Handle to an open key
        TEXT("PERFLOG"),
        NULL,                       // Reserved field
        &dwKeyType,                 // Returns the field type
        (LPBYTE) &dwKeyValue,       // Returns the field's value
        &dwKeySize );               // Number of bytes transferred

    if ((lReturn == ERROR_SUCCESS) && (dwKeyType == REG_DWORD))
    {
        PerflogModuleLevel = dwKeyValue;
    }

    RegCloseKey(hModuleKey);
}
Example #27
0
SString SharedUtil::GetSystemLongPathName( const SString& strPath )
{
    wchar_t szBuffer[32000];
    szBuffer[0] = 0;
    GetLongPathNameW( FromUTF8( strPath ), szBuffer, NUMELMS( szBuffer ) - 1 );
    return ToUTF8( szBuffer );
}
fsOffsetNumber_t CRawFile::GetSizeNative( void ) const
{
#ifdef _WIN32
    union
    {
        LARGE_INTEGER fileSizeOut;
        DWORD fileSizeOut_split[ sizeof( LARGE_INTEGER ) / sizeof( DWORD ) ];
    };

    BOOL success = GetFileSizeEx( this->m_file, &fileSizeOut );

    if ( success == FALSE )
        return (fsOffsetNumber_t)0;

    // Convert to a FileSystem native number.
    fsOffsetNumber_t bigFileSizeNumber = (fsOffsetNumber_t)0;

    ConvertToWideNumber( bigFileSizeNumber, &fileSizeOut_split[0], NUMELMS(fileSizeOut_split), NUMBER_LITTLE_ENDIAN, NUMBER_LITTLE_ENDIAN );

    return bigFileSizeNumber;
#elif defined(__linux__)
    // todo.
#else
    return (fsOffsetNumber_t)0;
#endif //OS DEPENDANT CODE
}
fsOffsetNumber_t CRawFile::TellNative( void ) const
{
#ifdef _WIN32
    LARGE_INTEGER posToMoveTo;
    posToMoveTo.LowPart = 0;
    posToMoveTo.HighPart = 0;

    union
    {
        LARGE_INTEGER currentPos;
        DWORD currentPos_split[ sizeof( LARGE_INTEGER ) / sizeof( DWORD ) ];
    };

    BOOL success = SetFilePointerEx( this->m_file, posToMoveTo, &currentPos, FILE_CURRENT );

    if ( success == FALSE )
        return (fsOffsetNumber_t)0;

    // Create a FileSystem number.
    fsOffsetNumber_t resultNumber = (fsOffsetNumber_t)0;

    ConvertToWideNumber( resultNumber, &currentPos_split[0], NUMELMS(currentPos_split), NUMBER_LITTLE_ENDIAN, NUMBER_LITTLE_ENDIAN );

    return resultNumber;
#elif defined(__linux__)
    // todo.
#else
    return (fsOffsetNumber_t)0;
#endif //OS DEPENDANT CODE
}
int CRawFile::SeekNative( fsOffsetNumber_t iOffset, int iType )
{
#ifdef _WIN32
    // Split our offset into two DWORDs.
    LONG numberParts[ 2 ];
    unsigned int splitCount = 0;

    SplitIntoNativeNumbers( iOffset, numberParts, NUMELMS(numberParts), splitCount, NUMBER_LITTLE_ENDIAN, NUMBER_LITTLE_ENDIAN );

    // Tell the OS.
    // Using the preferred method.
    DWORD resultVal = INVALID_SET_FILE_POINTER;

    if ( splitCount == 1 )
    {
        resultVal = SetFilePointer( this->m_file, numberParts[0], NULL, iType );
    }
    else if ( splitCount >= 2 )
    {
        resultVal = SetFilePointer( this->m_file, numberParts[0], &numberParts[1], iType );
    }

    if ( resultVal == INVALID_SET_FILE_POINTER )
        return -1;

    return 0;
#elif defined(__linux__)
    // todo.
#else
    return -1;
#endif //OS DEPENDANT CODE
}