Skip to content
⌘ NSIS Forum Archive

Help with system plugin

7 posts

ahmett#

Help with system plugin

I want to get the list of decoder GUIDs supported by the graphics hardware but I'm really bad with the system plugin.So can someone help me to get it by using the following function with the system plugin?




  UINT deviceCount;
GUID* decoderDevices = nullptr;
hr = decoderService->GetDecoderDeviceGuids(&deviceCount, &decoderDevices);
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("IDirectXVideoDecoderServer::GetDecoderDeviceGuids failed with error %X", hr);
return hr;
}

bool found = false;
for (UINT i = 0; i < deviceCount; i++) {
if (decoderDevices[i] == DXVA2_ModeH264_E ||
decoderDevices[i] == DXVA2_Intel_ModeH264_E) {
mDecoderGUID = decoderDevices[i];
found = true;
break;
}
}
CoTaskMemFree(decoderDevices);

if (!found) {
aFailureReason.AssignLiteral("Failed to find an appropriate decoder GUID");
return E_FAIL;
}
JasonFriday13#
You could write this into a plugin instead, it looks too long and messy to write this in script system plugin syntax. All it has to return is either 'error', or 'ok' then the number of guids and then just 'pop' each guid off the stack.

Anders might be able to do some magic with the system plugin though.
Anders#
If all you need is this exact code then you can do it with the System plug-in. I'll whip up some code later.
Anders#
Your code is actually incomplete, you failed to show how you create the device.

This should be close enough
!include LogicLib.nsh
!include Win\COM.nsh
!define /IfNDef D3D_SDK_VERSION 32
!define /IfNDef D3DADAPTER_DEFAULT 0
!define /IfNDef D3DDEVTYPE_HAL 1
!define /IfNDef D3DCREATE_HARDWARE_VERTEXPROCESSING 64
!define /IfNDef D3DFMT_UNKNOWN 0
#D3DFMT_R8G8B8                20
#D3DFMT_A8R8G8B8              21
!define /IfNDef D3DMULTISAMPLE_NONE 0
!define /IfNDef D3DSWAPEFFECT_DISCARD 1
!define /IfNDef D3DPRESENT_INTERVAL_DEFAULT 0
!define /IfNDef IID_IDirectXVideoDecoderService {fc51a551-d5e7-11d9-af55-00054e43ff02}
!define /IfNDef DXVA2_ModeH264_E       {1b81be68-a0c7-11d3-b984-00c04f2e73c5}
!define /IfNDef DXVA2_Intel_ModeH264_E {604F8E68-4951-4c54-88FE-ABD25C15B3D6}
Section
System::Call 'D3d9::Direct3DCreate9(i${D3D_SDK_VERSION})p.r1'
${If} $1 Z= 0
    Abort "Direct3DCreate9 failed"
${EndIf}
System::Call '*(i0,i0,i${D3DFMT_UNKNOWN},i0,i${D3DMULTISAMPLE_NONE},i0,i${D3DSWAPEFFECT_DISCARD},p$hWndParent,i1,i0,i${D3DFMT_UNKNOWN},i0,i0,i${D3DPRESENT_INTERVAL_DEFAULT})p.r3'
DetailPrint "Calling $1 ($3)"
System::Call `$1->16(i${D3DADAPTER_DEFAULT},i${D3DDEVTYPE_HAL},p0,i${D3DCREATE_HARDWARE_VERTEXPROCESSING},pr3,*p0r2)i.r0`
System::Free $3
${IUnknown::Release} $1 ""
DetailPrint hr=$0,IDirect3DDevice9=$2
${If} $0 < 0
    Abort "CreateDevice failed"
${EndIf}
System::Call 'Dxva2::DXVA2CreateVideoService(pr2,&g16 "${IID_IDirectXVideoDecoderService}",*p0r1)i.r0'
${IUnknown::Release} $2 ""
DetailPrint hr=$0,IDirectXVideoDecoderService=$1
${If} $0 < 0
    Abort "DXVA2CreateVideoService failed"
${EndIf}
StrCpy $9 "" ; GUID
System::Call '$1->4(*i0r2, *p0r3)i.r0'
${If} $0 >= 0
    DetailPrint Count=$2
    StrCpy $4 0 ; Offset
    StrCpy $5 0 ; Index
    loop:
        ${IfThen} $5 >= $2 ${|} Goto end ${|}
        System::Call '*$3(&i$4,&g16.r6)'
        DetailPrint GUID#$5=$6
        ${If} $6 == ${DXVA2_ModeH264_E}
        ${OrIf} $6 == ${DXVA2_Intel_ModeH264_E}
            StrCpy $9 $6
            StrCpy $5 $2 ; Stop search early if we find a match
        ${EndIf}
        IntOp $5 $5 + 1
        IntOp $4 $4 + 16
        Goto loop
    end:
    System::Call 'OLE32::CoTaskMemFree(pr3)'
${EndIf}
${IUnknown::Release} $1 ""
${If} $9 != ""
    DetailPrint "Found $9 DXVA2 decoder"
${Else}
    Abort "Failed to find an appropriate decoder GUID"
${EndIf}
SectionEnd 
Anders#
Originally Posted by ahmett View Post
Thank you, you're excellent!
You should probably modify my code a bit to suit your needs. I'm asking for hardware here but depending on what you need, you might be able to use the WARP software renderer.

Also, it might fail for silent installers because it asks for windowed mode so you should disable silent installer or create a fake window or ask for full-screen.