# ========== Configuration ========== $searchRoot = "C:\Windows\System32\DriverStore\FileRepository" $dllName = "nvxdapix.dll" $replacementDll = "$HOME\Desktop\nvxdapix.dll" # Path to the patched DLL $logFile = "$HOME\dll_replacement_log.txt" # =================================== # Search for the DLL Write-Host "Searching for $dllName in $searchRoot..." $dllPath = Get-ChildItem -Path $searchRoot -Recurse -Filter $dllName -ErrorAction SilentlyContinue | Select-Object -First 1 # Kill the NV service before attempting to replace the DLL Stop-Service NVDisplay.ContainerLocalSystem if ($dllPath) { $fullPath = $dllPath.FullName Write-Host "Found DLL: $fullPath" Add-Content -Path $logFile -Value "Found $dllName at: $fullPath" # Take ownership takeown /F $fullPath | Out-Null # Grant full control to administrators icacls $fullPath /grant Administratoren:F | Out-Null # Attempt to stop processes using the DLL (optional: may not apply to DriverStore) Get-Process | Where-Object { $_.Modules | Where-Object { $_.FileName -eq $fullPath } } | ForEach-Object { Write-Host "Stopping process: $($_.Name) (PID: $($_.Id))" Stop-Process -Id $_.Id -Force } # Replace the DLL Copy-Item -Path $replacementDll -Destination $fullPath -Force Write-Host "Replaced $dllName successfully." Add-Content -Path $logFile -Value "Replaced $dllName at $fullPath on $(Get-Date)" } else { Write-Host "DLL not found." Add-Content -Path $logFile -Value "Failed to find $dllName in $searchRoot on $(Get-Date)" } # Start the service after the replacement Start-Service NVDisplay.ContainerLocalSystem