anrieff / libcpuid

a small C library for x86 CPU detection and feature extraction
Other
451 stars 106 forks source link

Kernel driver won't load #133

Closed redeemarr closed 4 years ago

redeemarr commented 4 years ago

Windows 10, x64.

Library and tool builds (Debug, x64) with no problem, but when trying to access MSR features it fails at runtime. Specifically this line from rdmsr.c

if(StartService(drv->scDriver, 0, NULL))

gives result of 577, which means "Windows cannot verify the digital signature for this file. A recent hardware or software change might have installed a file that is signed incorrectly or damaged, or that might be malicious software from an unknown source"

Tried x86 binary of TmpRdr.sys just in case - error 1275, as expected. How could it be fixed? Thanks.

anrieff commented 4 years ago

I believe recent 64-bit Windows versions enforce digitally-signed drivers, and the one shipped with libcpuid was built more than 10 years ago, when such restrictions weren't present.

You may try to work around the issue by rebuilding the driver (its sources are in contrib) and sign it with a recent version of the Microsoft toolchain. I think you'll need the Windows Driver Kit as well. Then the resulting .sys files can be used instead of the stock ones embedded in msrdriver.c. IIRC you can self-sign drivers and they will work on your PC; distributing them on other computers will not. More info here.

For a more general solution to this problem a signing certificate has to be bought.

redeemarr commented 4 years ago

Yep, rebuilt the driver. The process was quite tricky, but that worked. Thanks again. Awesome lib, btw!

anrieff commented 4 years ago

Cool, glad it worked! Cheers!