From c6ddb95effcc4b6d63ac68b0af1f8cd1ff66cfda Mon Sep 17 00:00:00 2001 From: Howard Wu <40033067+Howard20181@users.noreply.github.com> Date: Sun, 29 Jun 2025 11:33:38 +0800 Subject: [PATCH] Add NVFBC patch scripts and update documentation Added Patch.ps1 PowerShell script and RunPatch.bat batch launcher for automating the NVFBC DLL patch process. Updated win/nvfbcwrp/README.md with instructions for using the new scripts. Minor formatting and link improvements in win/README.md. --- win/README.md | 17 +---- win/nvfbcwrp/Patch.ps1 | 151 ++++++++++++++++++++++++++++++++++++++ win/nvfbcwrp/README.md | 9 ++- win/nvfbcwrp/RunPatch.bat | 12 +++ 4 files changed, 173 insertions(+), 16 deletions(-) create mode 100644 win/nvfbcwrp/Patch.ps1 create mode 100644 win/nvfbcwrp/RunPatch.bat diff --git a/win/README.md b/win/README.md index 15ba2d8..b0de6bf 100644 --- a/win/README.md +++ b/win/README.md @@ -1,5 +1,4 @@ -NVENC and NvFBC patches for Windows Nvidia drivers -================================================== +# NVENC and NvFBC patches for Windows Nvidia drivers ![GitHub last commit](https://img.shields.io/github/last-commit/keylase/nvidia-patch.svg) ![Latest GeForce version](https://img.shields.io/badge/latest%20GeForce%20version-576.80-brightgreen.svg) ![Latest Quadro version](https://img.shields.io/badge/latest%20Quadro%20version-536.25-blue.svg) @@ -26,7 +25,7 @@ If you like this project, best way to contribute is by sending PRs and fixing do - Windows Server 2012 R2 - Windows Server 2016 - Windows Server 2019 -- NVENC-compatible GPU (https://developer.nvidia.com/video-encode-decode-gpu-support-matrix#Encoder) +- NVENC-compatible GPU () - Nvidia driver. Patch available for versions in [table below](#version-table). ## NVENC Patch Step-by-Step Guide @@ -62,7 +61,6 @@ Credits to [TroubleChute channel](https://www.youtube.com/channel/UCkih2oVTbXPEp ### Windows 10, Windows 11 drivers - | Product series | Version | x64 library patch | x86 library patch | Driver link | |----------------|---------|-------------------|-------------------|-------------| | GeForce | 391.35 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win10_x64/391.35/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win10_x64/391.35/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/391.35/391.35-desktop-win10-64bit-international-whql.exe) | @@ -275,7 +273,6 @@ Credits to [TroubleChute channel](https://www.youtube.com/channel/UCkih2oVTbXPEp | GeForce | 576.66 DCH (Notebook Hotfix) | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win10_x64/576.66/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win10_x64/576.66/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/576.66hf/576.66-desktop-notebook-win10-win11-64bit-international-dch.hf.exe) | | GeForce | 576.80 DCH | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win10_x64/576.80/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win10_x64/576.80/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/576.80/576.80-desktop-win10-win11-64bit-international-dch-whql.exe) | - | Product series | Version | x64 library patch | x86 library patch | Driver link | |----------------|---------|-------------------|-------------------|-------------| | Quadro | 416.78 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win10_x64/quadro_416.78/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win10_x64/quadro_416.78/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/Quadro_Certified/416.78/416.78-quadro-desktop-notebook-win10-64bit-international-whql.exe) | @@ -323,10 +320,8 @@ Credits to [TroubleChute channel](https://www.youtube.com/channel/UCkih2oVTbXPEp | Quadro | 526.67 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win10_x64/quadro_526.67/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win10_x64/quadro_526.67/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/Quadro_Certified/526.67/526.67-quadro-rtx-desktop-notebook-win10-win11-64bit-international-dch-whql.exe) | | Quadro | 536.25 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win10_x64/quadro_536.25/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win10_x64/quadro_536.25/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/Quadro_Certified/536.25/536.25-quadro-rtx-desktop-notebook-win10-win11-64bit-international-dch-whql.exe) | - ### Windows 7, Windows 8, Windows 8.1 drivers - | Product series | Version | x64 library patch | x86 library patch | Driver link | |----------------|---------|-------------------|-------------------|-------------| | GeForce | 431.60 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win7_x64/431.60/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win7_x64/431.60/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/431.60/431.60-desktop-win8-win7-64bit-international-whql.exe) | @@ -396,7 +391,6 @@ Credits to [TroubleChute channel](https://www.youtube.com/channel/UCkih2oVTbXPEp | GeForce | 471.96 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win7_x64/471.96/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win7_x64/471.96/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/471.96/471.96-desktop-win8-win7-64bit-international-whql.exe) | | GeForce | 472.12 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win7_x64/472.12/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win7_x64/472.12/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/472.12/472.12-desktop-win8-win7-64bit-international-whql.exe) | - | Product series | Version | x64 library patch | x86 library patch | Driver link | |----------------|---------|-------------------|-------------------|-------------| | Quadro | 431.02 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win7_x64/quadro_431.02/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win7_x64/quadro_431.02/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/Quadro_Certified/431.02/431.02-quadro-desktop-notebook-win8-win7-64bit-international-whql.exe) | @@ -410,10 +404,8 @@ Credits to [TroubleChute channel](https://www.youtube.com/channel/UCkih2oVTbXPEp | Quadro | 441.28 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win7_x64/quadro_441.28/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win7_x64/quadro_441.28/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/Quadro_Certified/441.28/441.28-quadro-desktop-notebook-win8-win7-64bit-international-whql.exe) | | Quadro | 441.66 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win7_x64/quadro_441.66/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/win7_x64/quadro_441.66/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/Quadro_Certified/441.66/441.66-quadro-desktop-notebook-win8-win7-64bit-international-whql.exe) | - ### Windows Server 2008R2, 2012, 2012R2 drivers - | Product series | Version | x64 library patch | x86 library patch | Driver link | |----------------|---------|-------------------|-------------------|-------------| | Quadro | 430.64 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/ws2012_x64/quadro_430.64/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/ws2012_x64/quadro_430.64/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/Quadro_Certified/430.64/430.64-quadro-winserv2008r2-2012-2012r2-64bit-international-whql.exe) | @@ -448,10 +440,8 @@ Credits to [TroubleChute channel](https://www.youtube.com/channel/UCkih2oVTbXPEp | Quadro | 472.12 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/ws2012_x64/quadro_472.12/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/ws2012_x64/quadro_472.12/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/Quadro_Certified/472.12/472.12-quadro-rtx-winserv-2012r2-64bit-international-whql.exe) | | Quadro | 472.84 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/ws2012_x64/quadro_472.84/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/ws2012_x64/quadro_472.84/nvencodeapi.1337) | [Driver link](http://international.download.nvidia.com/Windows/Quadro_Certified/472.84/472.84-quadro-rtx-winserv-2012r2-64bit-international-whql.exe) | - ### Windows Server 2016, 2019 drivers - | Product series | Version | x64 library patch | x86 library patch | Driver link | |----------------|---------|-------------------|-------------------|-------------| | Quadro | 430.86 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/ws2016_x64/quadro_430.86/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/ws2016_x64/quadro_430.86/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/Quadro_Certified/430.86/430.86-quadro-winserv-2016-2019-64bit-international-whql.exe) | @@ -485,7 +475,6 @@ Credits to [TroubleChute channel](https://www.youtube.com/channel/UCkih2oVTbXPEp | Quadro | 472.12 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/ws2016_x64/quadro_472.12/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/ws2016_x64/quadro_472.12/nvencodeapi.1337) | [Driver link](https://international.download.nvidia.com/Windows/Quadro_Certified/472.12/472.12-quadro-rtx-winserv-2016-2019-64bit-international-whql.exe) | | Quadro | 472.84 | [x64 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/ws2016_x64/quadro_472.84/nvencodeapi64.1337) | [x86 library patch](https://raw.githubusercontent.com/keylase/nvidia-patch/master/win/ws2016_x64/quadro_472.84/nvencodeapi.1337) | [Driver link](http://international.download.nvidia.com/Windows/Quadro_Certified/472.84/472.84-quadro-rtx-winserv-2016-2019-64bit-international-whql.exe) | - ## Benchmarks -* [Plex Media Server: nVidia Hardware Transcoding Calculator for Plex Estimates](https://www.elpamsoft.com/?p=Plex-Hardware-Transcoding) - useful benchmark of achieved simultaneous transcodes with various stream quality and hardware with patched drivers. +- [Plex Media Server: nVidia Hardware Transcoding Calculator for Plex Estimates](https://www.elpamsoft.com/?p=Plex-Hardware-Transcoding) - useful benchmark of achieved simultaneous transcodes with various stream quality and hardware with patched drivers. diff --git a/win/nvfbcwrp/Patch.ps1 b/win/nvfbcwrp/Patch.ps1 new file mode 100644 index 0000000..5035700 --- /dev/null +++ b/win/nvfbcwrp/Patch.ps1 @@ -0,0 +1,151 @@ +# NVFBC DLL patch script +# Requires administrator privileges to run +Function Test-Administrator { + [OutputType([bool])] + param() + process { + [Security.Principal.WindowsPrincipal]$user = [Security.Principal.WindowsIdentity]::GetCurrent(); + return $user.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator); + } +} #end function Test-Administrator +Function Test-CommandExist { + Param ($Command) + $OldPreference = $ErrorActionPreference + $ErrorActionPreference = 'stop' + try { if (Get-Command $Command) { RETURN $true } } + Catch { RETURN $false } + Finally { $ErrorActionPreference = $OldPreference } +} #end function Test-CommandExist +If (Test-CommandExist pwsh.exe) { + $pwsh = "pwsh.exe" +} +Else { + $pwsh = "powershell.exe" +} +If (-Not (Test-Administrator)) { + Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force + $Proc = Start-Process -PassThru -Verb RunAs $pwsh -Args "-ExecutionPolicy Bypass -Command Set-Location '$PSScriptRoot'; &'$PSCommandPath' EVAL" + If ($null -Ne $Proc) { + $Proc.WaitForExit() + } + If ($null -Eq $Proc -Or $Proc.ExitCode -Ne 0) { + Write-Warning "Failed to launch start as Administrator`r`nPress any key to exit" + $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown'); + } + exit +} +ElseIf (($args.Count -Eq 1) -And ($args[0] -Eq "EVAL")) { + Start-Process $pwsh -NoNewWindow -Args "-ExecutionPolicy Bypass -Command Set-Location '$PSScriptRoot'; &'$PSCommandPath'" + exit +} +Function Unlock-DLL { + param ( + [string]$filePath + ) + + # Check if the file exists + if (-Not (Test-Path -Path $filePath)) { + Write-Error "The specified file does not exist." + exit + } + + Write-Information "Unlocking file: $filePath" + + # Get the file security object + $fileSecurity = Get-Acl -Path $filePath + + # Set the owner to "Administrators" + $administrators = [System.Security.Principal.NTAccount]"Administrators" + $fileSecurity.SetOwner($administrators) + + # Apply the new owner to the file + Set-Acl -Path $filePath -AclObject $fileSecurity + + # Define a new access rule for "Administrators" with full control + $administratorsRights = [System.Security.AccessControl.FileSystemRights]::FullControl + $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($administrators, $administratorsRights, [System.Security.AccessControl.InheritanceFlags]::None, [System.Security.AccessControl.PropagationFlags]::None, [System.Security.AccessControl.AccessControlType]::Allow) + + # Add the new access rule to the file security object + $fileSecurity.AddAccessRule($accessRule) + + # Apply the updated security settings to the file + Set-Acl -Path $filePath -AclObject $fileSecurity + + Write-Information "Owner changed to 'Administrators' and full control permissions granted to 'Administrators' for file: $filePath" +} #end function Unlock-DLL +Write-Information "Staring NVFBC DLL patch..." + +$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path + +$system32Path = "$env:WINDIR\system32" +$sysWOW64Path = "$env:WINDIR\SysWOW64" + +$originalNvFBC64 = "$system32Path\NvFBC64.dll" +$originalNvFBC32 = "$sysWOW64Path\NvFBC.dll" + +$backupNvFBC64 = "$system32Path\NvFBC64_.dll" +$backupNvFBC32 = "$sysWOW64Path\NvFBC_.dll" + +$wrapperNvFBC64 = "$scriptDir\nvfbcwrp64.dll" +$wrapperNvFBC32 = "$scriptDir\nvfbcwrp32.dll" + +try { + # Step 1: Backup NvFBC64.dll + if (Test-Path $originalNvFBC64) { + Write-Information "Rename $originalNvFBC64 to $backupNvFBC64" + Unlock-DLL $originalNvFBC64 + Move-Item -Path $originalNvFBC64 -Destination $backupNvFBC64 -Force + Write-Information "✓ NvFBC64.dll backup completed" + } + else { + Write-Warning "NvFBC64.dll not found" + } + + # Step 2: Backup NvFBC.dll + if (Test-Path $originalNvFBC32) { + Write-Information "Rename $originalNvFBC32 to $backupNvFBC32" + Unlock-DLL $originalNvFBC32 + Move-Item -Path $originalNvFBC32 -Destination $backupNvFBC32 -Force + Write-Information "✓ NvFBC.dll backup completed" + } + else { + Write-Warning "NvFBC.dll not found" + } + + # Step 3: Copy 64-bit wrapper to system32 + if (Test-Path $wrapperNvFBC64) { + Write-Information "Copy $wrapperNvFBC64 to $originalNvFBC64" + Copy-Item -Path $wrapperNvFBC64 -Destination $originalNvFBC64 -Force + Write-Information "✓ 64-bit warpper copied" + } + else { + throw "nvfbcwrp64.dll not found" + } + + # Step 4: Copy 32-bit wrapper SysWOW64 + if (Test-Path $wrapperNvFBC32) { + Write-Information "Copy $wrapperNvFBC32 to $originalNvFBC32" + Copy-Item -Path $wrapperNvFBC32 -Destination $originalNvFBC32 -Force + Write-Information "✓ 32-bit wrapper copied" + } + else { + throw "nvfbcwrp32.dll not found" + } +} +catch { + Write-Error "$($_.Exception.Message)" -ErrorAction Continue + Write-Error "Patch install failed!" -ErrorAction Continue + Write-Information "Rolling back changes..." + if ((Test-Path $backupNvFBC64) -and (-not (Test-Path $originalNvFBC64))) { + Move-Item -Path $backupNvFBC64 -Destination $originalNvFBC64 -Force -ErrorAction SilentlyContinue + } + if ((Test-Path $backupNvFBC32) -and (-not (Test-Path $originalNvFBC32))) { + Move-Item -Path $backupNvFBC32 -Destination $originalNvFBC32 -Force -ErrorAction SilentlyContinue + } + Read-Host "Press to stop." + exit 1 +} + +Write-Information "Press to stop." +pause +# End of script diff --git a/win/nvfbcwrp/README.md b/win/nvfbcwrp/README.md index 7af98fe..e298a8d 100644 --- a/win/nvfbcwrp/README.md +++ b/win/nvfbcwrp/README.md @@ -1,5 +1,4 @@ -nvfbcwrp -======== +# nvfbcwrp Wrapper for `NvFBC64.dll` library which injects private keys into `NvFBC_CreateEx` calls in order to enable NvFBC on customer-grade hardware (like GeForce cards) for all NvFBC-targeted applications. It should work at least with applications built with Nvidia Capture SDK versions 5.0 to 7.1. @@ -15,6 +14,8 @@ Wrapper for `NvFBC64.dll` library which injects private keys into `NvFBC_CreateE This procedure has to be repeated after any driver reinstall/update, so keep your copies of `nvfbcwrp64.dll` and `nvfbcwrp32.dll` files. +You can use the [PowerShell script](Patch.ps1) and [Patch Launcher](RunPatch.bat) to quickly apply patch. + ## Advanced Usage `nvfbcwrp` allows user to capture and replay `privateData` used by other NvFBC applications (like GeForce Experience, Shadow Play and so on). It may be useful if built-in `privateData` will render invalid for some reason. Wrapper recognizes two environment variables: @@ -31,7 +32,11 @@ Hence, if default magic baked into nvfbcwrp doesn't work for you, you have to: ## 3rd-party software For some software (e.g Steam) it is also needed to add registry value to use NvFBC, which you can do by running: + ```batch reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\nvlddmkm" /v NVFBCEnable /d 1 /t REG_DWORD /f ``` + (reboot / driver restart required to take effect) + +To quickly reset graphics driver press `Windows key` + `Ctrl` + `Shift` + `B` diff --git a/win/nvfbcwrp/RunPatch.bat b/win/nvfbcwrp/RunPatch.bat new file mode 100644 index 0000000..bd31a99 --- /dev/null +++ b/win/nvfbcwrp/RunPatch.bat @@ -0,0 +1,12 @@ +@echo off +%~d0 +cd "%~dp0" +if not exist Patch.ps1 ( + echo "Patch.ps1" is not found. + echo Press any key to exit + pause>nul + exit 1 +) else ( + start powershell.exe -ExecutionPolicy Bypass -File .\Patch.ps1 + exit +)