コード例 #1
0
bool CSystemObjectWrapper::GetInterfaces(ISystemUnknown *piUnknown)
{
    m_piObject=QI(ISystemObject,piUnknown);
    if(m_piObject){m_piSerializable=QI(ISystemSerializable,piUnknown);}
    if(!m_piObject){ReleaseInterfaces();return false;}
    return true;
}
コード例 #2
0
ファイル: vidplay.cpp プロジェクト: jleclanche/darkdust-ctp2
//
// CFilePlayer destructor
//
CFilePlayer::~CFilePlayer(void)
{
    DbgLog((LOG_TRACE, 3, TEXT("CFilePlayer d-tor entered"))) ;

    ReleaseInterfaces() ;

    DbgLog((LOG_TRACE, 3, TEXT("CFilePlayer d-tor exiting..."))) ;
}
コード例 #3
0
ファイル: vidplay.cpp プロジェクト: jleclanche/darkdust-ctp2
//
// CDVDPlayer destructor
//
CDVDPlayer::~CDVDPlayer()
{
    DbgLog((LOG_TRACE, 3, TEXT("CDVDPlayer d-tor entered"))) ;

    ReleaseInterfaces() ;

    if (m_pDvdGB)
        m_pDvdGB->Release() ;

    DbgLog((LOG_TRACE, 3, TEXT("CDVDPlayer d-tor exiting..."))) ;
}
コード例 #4
0
ファイル: vidplay.cpp プロジェクト: jleclanche/darkdust-ctp2
//
// CFilePlayer::ClearGraph(): Releases the filter graph built by BuildGraph()
// and the interfaces taken for playback.
//
HRESULT CFilePlayer::ClearGraph(void)
{
    DbgLog((LOG_TRACE, 5, TEXT("CFilePlayer::ClearGraph() entered"))) ;

    ReleaseInterfaces() ;  // let go of the other interfaces
    if (m_pGraph)
    {
        m_pGraph->Release() ;  // let the graph go (we'll create a fresh one next time)
        m_pGraph = NULL ;
    }

    return S_OK ;
}
コード例 #5
0
ファイル: vidplay.cpp プロジェクト: jleclanche/darkdust-ctp2
//
// CDVDPlayer::ClearGraph(): Tears down the filter graph created by BuildGraph()
// and also releases the DVD graph builder object.
//
HRESULT CDVDPlayer::ClearGraph()
{
    DbgLog((LOG_TRACE, 5, TEXT("CDVDPlayer::ClearGraph() entered"))) ;

    ReleaseInterfaces() ;  // let go of the other interfaces
    if (m_pDvdGB)
    {
        m_pDvdGB->Release() ;
        m_pDvdGB = NULL ;
    }

    return S_OK ;

}
コード例 #6
0
bool CSystemObjectWrapper::Create(ISystem *piSystem,std::string sClass,std::string sName)
{
    ReleaseInterfaces();
    bool            bOk=false;
    ISystemObject   *piObject=NULL;
    if(!piSystem->GetObject(sName,&piObject))
    {
        if(piSystem->CreateObject(sClass,sName,&piObject))
        {
            //m_bObjectMustBeDestroyed=true;
        }
    }
    if(piObject){bOk=GetInterfaces(piObject);}
    REL(piObject);
    return bOk;
}
コード例 #7
0
bool CSystemObjectWrapper::Create(std::string sSystem,std::string sClass,std::string sName)
{
    ReleaseInterfaces();

    bool            bOk=false;
    ISystemObject   *piObject=NULL;
    ISystem         *piSystem=NULL;
    ISystemManager  *piManager=GetSystemManager();

    if(piManager){piSystem=piManager->GetSystem(sSystem);}
    if(piSystem){bOk=Create(piSystem,sClass,sName);}
    if(piObject){bOk=GetInterfaces(piObject);}
	if(!bOk)
	{
		RTTRACE("CSystemObjectWrapper::Create -> Failed to create System: %s, Class: %s, Object:%s",sSystem.c_str(),sClass.c_str(),sName.c_str());
	}
    REL(piManager);
    REL(piSystem);
    REL(piObject);
    return bOk;
}
コード例 #8
0
ファイル: vidplay.cpp プロジェクト: jleclanche/darkdust-ctp2
//
// CFilePlayer::BuildGraph(): Builds a AVI/MPEG/.. playback graph rendering via
// OverlayMixer which uses app's given DDraw params.
//
HRESULT CFilePlayer::BuildGraph(HWND hWndApp, LPDIRECTDRAW pDDObj, LPDIRECTDRAWSURFACE pDDPrimary)
{
    DbgLog((LOG_TRACE, 5, TEXT("CFilePlayer::BuildGraph() entered"))) ;

    HRESULT       hr ;
    IBaseFilter  *pOvM ;
    WCHAR         achwFileName[MAX_PATH] ;
    LPWSTR        lpszwFileName = NULL ;
    IBaseFilter  *pVR ;

    // First release any existing interface pointer(s)
    ReleaseInterfaces() ;
    SetColorKey(253) ;  // default magenta for 8bpp

    // Check if a file name has been specified; if so, use that
    if (lstrlen(GetFileName()) > 0)  // if something was specified before
    {
#ifdef UNICODE
        lstrcpy(achwFileName, GetFileName()) ;
#else
        MultiByteToWideChar(CP_ACP, 0, GetFileName(), -1, achwFileName, MAX_PATH) ;
#endif

        lpszwFileName = achwFileName ;
    }
    else  // no file specified, but we should have detected it before!!!
        return E_FAIL ;

    //
    // Instantiate Overlay Mixer, add it to the graph and set DDraw params
    //
    hr = AddOvMToGraph(&pOvM, pDDObj, pDDPrimary) ;
    if (FAILED(hr))
    {
        return E_FAIL ;
    }

    //
    // First render the graph for the selected file
    //
    hr = m_pGraph->RenderFile(lpszwFileName, NULL) ;
    if (S_OK != hr)
    {
        DbgLog((LOG_ERROR, 0,
            TEXT("Rendering the given file didn't succeed completely (Error 0x%lx)"), hr)) ;
        m_pGraph->RemoveFilter(pOvM) ;  // remove from graph
        pOvM->Release() ;               // release filter
        return E_FAIL ;
    }

    //
    // Because there are some AVI files which on some machines decide to rather go
    // through the Color Space Converter filter, just making sure that the OverlayMixer
    // is actually being used.  Otherwise we have to do some more (bull)work.
    //
    if (! IsOvMConnected(pOvM) )
    {
        DbgLog((LOG_TRACE, 1, TEXT("OverlayMixer is not used in the graph. Try again..."))) ;

        //
        // Check that the  specified file has a video stream. Otherwise OverlayMixer
        // will never be used and DDraw exclusive mode playback doesn't make any sense.
        //
        if (FAILED(GetVideoRendererInterface(&pVR)))
        {
            DbgLog((LOG_TRACE, 1, TEXT("Specified file doesn't have any video stream. Aborting graph building."))) ;
            m_pGraph->RemoveFilter(pOvM) ;  // remove from graph
            pOvM->Release() ;               // release filter
            return E_FAIL ;
        }

        //
        // Put the video stream to go through the OverlayMixer.
        //
        hr = PutVideoThroughOvM(pOvM, pVR) ;
        if (FAILED(hr))
        {
            DbgLog((LOG_TRACE, 1, TEXT("Couldn't put video through the OverlayMixer."))) ;
            m_pGraph->RemoveFilter(pOvM) ;  // remove OvMixer from graph
            pOvM->Release() ;               // release OvMixer filter
            pVR->Release() ;                // release VR interface (before giving up)
            return E_FAIL ;
        }
        pVR->Release() ;    // done with VR interface
    }

    //
    // We are successful in building the graph. Now the rest...
    //
    GetInterfaces(hWndApp) ;

    // Get IDDrawExclModeVideo interface of the OvMixer and store it
    hr = pOvM->QueryInterface(IID_IDDrawExclModeVideo, (LPVOID *)&m_pDDXM) ;
    ASSERT(SUCCEEDED(hr)) ;

    // Get the color key to be used and store it
    hr = GetColorKeyInternal(pOvM) ;
    ASSERT(SUCCEEDED(hr)) ;

    pOvM->Release() ;  // done with it

    return S_OK ;
}
コード例 #9
0
ファイル: vidplay.cpp プロジェクト: jleclanche/darkdust-ctp2
//
// CBaseVideoPlayer destructor
//
CBaseVideoPlayer::~CBaseVideoPlayer()
{
    ReleaseInterfaces() ;
}
コード例 #10
0
ファイル: vidplay.cpp プロジェクト: jleclanche/darkdust-ctp2
//
// CDVDPlayer::BuildGraph(): Builds a filter graph for playing back the specified
// DVD title/file.  Also gets some interfaces that are required for controlling
// playback.
//
HRESULT CDVDPlayer::BuildGraph(HWND hWndApp, LPDIRECTDRAW pDDObj, LPDIRECTDRAWSURFACE pDDPrimary)
{
    DbgLog((LOG_TRACE, 5, TEXT("CDVDPlayer::BuildGraph() entered"))) ;

    HRESULT     hr ;

    // First release any existing interface pointer(s)
    ReleaseInterfaces() ;
    SetColorKey(253) ;  // default magenta for 8bpp

    // Check if a DVD-Video volume name has been specified; if so, use that
    WCHAR    achwFileName[MAX_PATH] ;
    LPCWSTR  lpszwFileName = NULL ;  // by default
    if (lstrlen(GetFileName()) > 0)  // if something was specified before
    {
#ifdef UNICODE
        lstrcpy(achwFileName, GetFileName()) ;
#else
        MultiByteToWideChar(CP_ACP, 0, GetFileName(), -1, achwFileName, MAX_PATH) ;
#endif // UNICODE

        lpszwFileName = achwFileName ;
    }
    DbgLog((LOG_TRACE, 5, TEXT("DVD file <%s> will be played"), GetFileName())) ;

    // Set DDraw object and surface on DVD graph builder before starting to build graph
    IDDrawExclModeVideo  *pDDXMV ;
    hr = m_pDvdGB->GetDvdInterface(IID_IDDrawExclModeVideo, (LPVOID *)&pDDXMV) ;
    if (FAILED(hr) || NULL == pDDXMV)
    {
        DbgLog((LOG_ERROR, 0,
            TEXT("ERROR: IDvdGB::GetDvdInterface(IDDrawExclModeVideo) failed (Error 0x%lx)"), hr)) ;
        return hr ;
    }
    hr = pDDXMV->SetDDrawObject(pDDObj) ;
    if (FAILED(hr))
    {
        DbgLog((LOG_ERROR, 0, TEXT("ERROR: IDDrawExclModeVideo::SetDDrawObject() failed (Error 0x%lx)"), hr)) ;
        pDDXMV->Release() ;  // release before returning
        return hr ;
    }
    hr = pDDXMV->SetDDrawSurface(pDDPrimary) ;
    if (FAILED(hr))
    {
        DbgLog((LOG_ERROR, 0, TEXT("ERROR: IDDrawExclModeVideo::SetDDrawSurface() failed (Error 0x%lx)"), hr)) ;
        pDDXMV->SetDDrawObject(NULL) ;  // to reset
        pDDXMV->Release() ;  // release before returning
        return hr ;
    }
    pDDXMV->Release() ;  // done with the interface

    // Build the graph
    AM_DVD_RENDERSTATUS   Status ;
    TCHAR                 achBuffer[1000] ;
    hr = m_pDvdGB->RenderDvdVideoVolume(lpszwFileName,
        AM_DVD_HWDEC_PREFER, &Status) ;
    if (FAILED(hr))
    {
        AMGetErrorText(hr, achBuffer, sizeof(achBuffer)) ;
        MessageBox(hWndApp, achBuffer, "Error", MB_OK) ;
        return hr ;
    }
    if (S_FALSE == hr)  // if partial success
    {
        std::basic_string<TCHAR>   l_Text;
        if (GetStatusText(&Status, achBuffer, sizeof(achBuffer)))
	    {
            l_Text.assign(achBuffer);
        }
        else
        {
            l_Text.assign(TEXT("An unknown error has occurred"));
        }
        l_Text.append(TEXT("\n\nDo you still want to continue?"));
        if (IDNO == MessageBox(hWndApp, l_Text.c_str(), TEXT("Warning"), MB_YESNO))
        {
            return E_FAIL;
        }
    }

    GetInterfaces(hWndApp) ;

    hr = GetColorKeyInternal() ;
    ASSERT(SUCCEEDED(hr)) ;

    return S_OK ;
}
コード例 #11
0
ファイル: st.cpp プロジェクト: AndreyBazhan/KD
HRESULT
CALLBACK
st(
    _In_ PDEBUG_CLIENT DebugClient,
    _In_opt_ PCSTR args
    )

/*++

Routine Description:

    Displays system service table.

Return Value:

    HRESULT

Environment:

    Kernel mode.

--*/

{
    HRESULT Status = S_OK;
    ULONG ProcessorType;
    ULONG PlatformId;
    ULONG Major;
    ULONG Minor;
    ULONG ServicePackNumber;
    ULONG64 KeServiceDescriptorTable;
    ULONG64 KiServiceLimit;
    ULONG64 ServiceTableBase;
    ULONG64 Address;
    ULONG64 ServiceAddress;
    ULONG64 PsNtosImageBase;
    ULONG64 NtosImageBase;
    ULONG64 NtosImageEnd;
    ULONG Limit;
    ULONG i;
    LONG Offset;
    ULONG BytesRead;
    CHAR ServiceName[MAX_PATH];
    IMAGE_NT_HEADERS64 ImageNtHeaders;

    UNREFERENCED_PARAMETER(args);

    __try {

        if ((Status = QueryInterfaces(DebugClient)) != S_OK) {

            DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Could not query interfaces.\n");
            __leave;
        }

        if ((Status = IsKernelMode(DebugClient, __FUNCTION__)) != S_OK) {

            __leave;
        }

        if ((Status = DebugControl->GetActualProcessorType(&ProcessorType)) != S_OK) {

            DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Could not get processor type.\n");
            __leave;
        }

        if ((Status = DebugControl->GetSystemVersion(&PlatformId, &Major, &Minor, NULL, NULL, NULL, &ServicePackNumber, NULL, NULL, NULL)) != S_OK) {

            DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Could not get system version.\n");
            __leave;
        }

        if ((Status = DebugSymbols->GetOffsetByName("nt!KeServiceDescriptorTable", &KeServiceDescriptorTable)) != S_OK) {

            DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Could not get address of nt!KeServiceDescriptorTable.\n");
            __leave;
        }

        if ((Status = DebugSymbols->GetOffsetByName("nt!KiServiceLimit", &KiServiceLimit)) != S_OK) {

            DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Could not get address of nt!KiServiceLimit.\n");
            __leave;
        }

        if ((Status = DebugDataSpaces->ReadPointersVirtual(1, KeServiceDescriptorTable, &ServiceTableBase)) != S_OK) {

            DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Could not read service table base.\n");
            __leave;
        }

        if ((Status = DebugDataSpaces->ReadVirtual(KiServiceLimit, &Limit, sizeof(ULONG), &BytesRead)) != S_OK) {

            DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Could not read service table limit.\n");
            __leave;
        }

        if ((Status = DebugSymbols->GetOffsetByName("nt!PsNtosImageBase", &PsNtosImageBase)) != S_OK) {

            DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Could not get address of nt!PsNtosImageBase.\n");
            __leave;
        }

        if ((Status = DebugDataSpaces->ReadPointersVirtual(1, PsNtosImageBase, &NtosImageBase)) != S_OK) {

            DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Could not read nt!PsNtosImageBase.\n");
            __leave;
        }

        if ((Status = DebugDataSpaces->ReadImageNtHeaders(NtosImageBase, &ImageNtHeaders)) != S_OK) {

            DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Could not read kernel image headers.\n");
            __leave;
        }

        NtosImageEnd = NtosImageBase + ImageNtHeaders.OptionalHeader.SizeOfImage;

        Address = ServiceTableBase;

        DebugControl->Output(DEBUG_OUTPUT_NORMAL, "\n");

        if (IMAGE_FILE_MACHINE_I386 == ProcessorType) {

            for (i = 0; i < Limit; i++, Address += sizeof(ULONG)) {

                ServiceName[0] = '\0';

                if ((Status = DebugDataSpaces->ReadPointersVirtual(1, Address, &ServiceAddress)) != S_OK) {

                    DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Could not read memory.\n");
                    __leave;
                }

                DebugSymbols->GetNameByOffset(ServiceAddress, (PSTR)ServiceName, _countof(ServiceName), &BytesRead, NULL);

                DebugControl->ControlledOutput(DEBUG_OUTCTL_DML,
                                               DEBUG_OUTPUT_NORMAL,
                                               (ServiceAddress >= NtosImageBase && ServiceAddress < NtosImageEnd) ? "%03lx:\t%p\t%s\n" : "%03lx:<col fg=\"changed\">\t%p\t%s</col>\n",
                                               i,
                                               ServiceAddress,
                                               ServiceName);
            }
        }
        else if (IMAGE_FILE_MACHINE_AMD64 == ProcessorType) {

            for (i = 0; i < Limit; i++, Address += sizeof(ULONG)) {

                ServiceName[0] = '\0';

                if ((Status = DebugDataSpaces->ReadVirtual(Address, &Offset, sizeof(Offset), &BytesRead)) != S_OK) {

                    DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Could not read memory.\n");
                    __leave;
                }

                if (Minor < 6000) {

                    Offset &= ~0xF;
                }
                else {

                    Offset >>= 4;
                }

                ServiceAddress = ServiceTableBase + Offset;

                DebugSymbols->GetNameByOffset(ServiceAddress, (PSTR)ServiceName, _countof(ServiceName), &BytesRead, NULL);

                DebugControl->ControlledOutput(DEBUG_OUTCTL_DML,
                                               DEBUG_OUTPUT_NORMAL,
                                               (ServiceAddress >= NtosImageBase && ServiceAddress < NtosImageEnd) ? "%03lx:\t%p\t%s\n" : "%03lx:<col fg=\"changed\">\t%p\t%s</col>\n",
                                               i,
                                               ServiceAddress,
                                               ServiceName);
            }
        }

        DebugControl->Output(DEBUG_OUTPUT_NORMAL, "\n");
    }
    __finally {

        ReleaseInterfaces();
    }

    return Status;
}
コード例 #12
0
CSystemObjectWrapper::~CSystemObjectWrapper()
{
    ReleaseInterfaces();
}
コード例 #13
0
void CSystemObjectWrapper::Destroy()
{
    m_bObjectMustBeDestroyed=true;
    ReleaseInterfaces();
}
コード例 #14
0
void CSystemObjectWrapper::Detach(bool bDestroyIfMust)
{
    if(!bDestroyIfMust){m_bObjectMustBeDestroyed=false;}
    ReleaseInterfaces();
	m_bAttached=false;
}