Repairing Windows DriverStore is not impossible!

Windows 10 disappointed me again today–my Realtek audio drivers suddenly stopped to work simply after a reboot. All I have now is mysterious "Driver is not signed" error. I tried to remove the unsigned driver (which is portcls.sys by the way) and run sfc /scannow to repair the corrupted file. Did not work. A dism repair worked, but that did not help to solve the sfc issues.

I then made a stupid mistake–I deleted the drivers entirely, a.k.a. all relevant files in C:\WINDOWS\INF, C:\WINDOWS\System32\drivers and most importantly, C:\WINDOWS\System32\drivers\DriverStore. After that I run sfc again and it still does not work!

After cursing Microsoft for making such a silly system repair utility, I return to try to manually diagnose the issue. I first manually copied back all files to INF and drivers, but the driver installations still did not go through. I then try putting back the DriverStore folders–then I found out that I completely forgot their proper names!

Normal Windows Event Viewer only shows a 0x2 error code, so I googled tons of pages to find the location of a proper setup log. It was two hours later that I found the location: C:\Windows\Inf\setupapi.dev.log

After that things went smoothly. You just need to search for Error 2 in the log, and the proper path revealed itself.

!!!  flq:                     Source Media: SPFQOPERATION_ABORT (C:\Windows\System32\DriverStore\FileRepository\wdmaudio.inf_amd64_179dade7dec66387\drmk.sys).
!!!  flq:                     Error 2: The system cannot find the file specified.
!!!  flq:                     FileQueueCommit aborting!
!!!  flq:                     Error 2: The system cannot find the file specified.

Now you just need to copy the directory in WinSxS to the DriverStore and rename. After that the audio drivers are finally back working.