Question about how to overwrite inbox StorAHCI driver with the one I build?

I tried to search on this site and others, but did not find anything, so I decided to post the question here, it should be easy enough for most of experienced guys :slight_smile:

I compiled and built the storahci project under Win 8 64-bit Pro, VS 2013. I could built it successfully without any error (amazing :slight_smile: )
I even made an inf file for it to manually install this driver and replace MS’ inbox storahci driver, I thought I was doing great, but later on, I found my driver was not event kicked in, never load. It is weird that the AHCI controller is still working? in Device Manager, it shows it’s a TEST AHCI Controller, and driver version is 0.0.2.000?. blah blah ? everything looks correct, except I know it’s not driven by my TEST StorAHCI driver, it is still using inbox driver or something.

I am wondering if it’s my inf problem or something else. Here is my teststorahci.inf

; teststorahci.INF
; Installation INF for TEST AHCI Controller for Windows VISTA/2008/7

[Version]
Signature=“$WINDOWS NT$”
Class=hdc
ClassGUID={4D36E96A-E325-11CE-BFC1-08002BE10318}
Provider=%TEST%
DriverVer=07/10/2014,0.0.2.000

[Manufacturer]
%TEST%=TEST_AHCI,NTamd64

[TEST_AHCI.NTamd64]
%PCI\VEN_1000&DEV_8000.DeviceDesc%= TESTstoreahci_Inst, PCI\VEN_1000&DEV_8000

[TESTstorahci_Inst]
CopyFiles = @TESTstorahci.sys
Include=mshdc.inf

[DestinationDirs]
DefaultDestDir = 12

;********************************************************
; Extra Registry Entries

[Strings]
TEST = “TEST, Inc.”
PCI\VEN_1000&DEV_8000.DeviceDesc =“TEST AHCI Controller”

In this storahci project downloaded from Microsoft website, I did not change any anything, not even a line :slight_smile: just change the target system to Win 8 64-bit, project name to teststorachi and hit build button :slight_smile:
And I turned off Win 8 64-bit driver signing, and successfully manually install driver for this VEN_1000&DEV_8000 device?.

When I run Verfiier.exe and I realized TESTStorAHCI.sys is not running at all. And when I check Windows\System32\Drivers , my TESTStorAHCI.sys is not there at all, only found a driver folder that is located in Windows\System32\DriverStore\FileRepository\TESTStorAHCI.inf_amd64XXXXXXX , and in that folder, it has two files, one is my TESTStorAHCI.inf and the other one is PNF file?

Am I doing anything wrong in int ? or did anyone try to build storahci project and overwrite microsoft’s?

Appreciate your help!

Jord

xxxxx@gmail.com wrote:

I even made an inf file for it to manually install this driver and replace MS’ inbox storahci driver,…

How did you do that, exactly? Right-click in Device Manager and do
“Update Driver”?

I thought I was doing great, but later on, I found my driver was not event kicked in, never load. It is weird that the AHCI controller is still working? in Device Manager, it shows it’s a TEST AHCI Controller, and driver version is 0.0.2.000?. blah blah ? everything looks correct, except I know it’s not driven by my TEST StorAHCI driver, it is still using inbox driver or something.

I am wondering if it’s my inf problem or something else. Here is my teststorahci.inf

Yes, your INF is not enough. You are copying the driver into place, but
that’s all you do. You’re not connecting your driver to the device.

In terms of configuration, devices aren’t really driven by drivers, they
are driven by services. In order to have your driver get used by a
device, you have to create a service that points to your driver, and you
have to tell the device to use that service as its driver. You aren’t
doing that.

You need a [TESTstorachi_Inst.Services] section with an AddService line
to add a service for your driver. As long as the second parameter of
that AddService line is “2”, that will make your service the primary
service for the device.

You can check this yourself in the registry, by going to
HKLM\System\CurrentControlSet\Enum\PCI\VEN_1000&DEV_8000, to the first
subkey therein, and check the “Service” value. My guess is it is still
msahci.

–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim,

Thanks.

How did you do that, exactly? Right-click in Device Manager and do “Update Driver”?

YES, I was using that method.

Thank you so much for pointing out addservice, I add that section and 2 in the second param. I was also doing some research online and found some information, however, I am still unable to make the service connected to the driver and device. Below is the new INF I made. Although I still can install it successfully, the “Service” value in registry still shows storahci, not TESTStorAHCI that I put down in INF. The TESETStorAHCI.sys is no in Driver folder nor in DriverStore folder. Any idea?

; teststorahci.INF
; Installation INF for TEST AHCI Controller for Windows VISTA/2008/7

[Version]
Signature=“$WINDOWS NT$”
Class=hdc
ClassGUID={4D36E96A-E325-11CE-BFC1-08002BE10318}
Provider=%TEST%
DriverVer=07/31/2014,0.0.2.000

[Manufacturer]
%TEST%=TEST_AHCI,NTamd64

[TEST_AHCI.NTamd64]
%PCI\VEN_1000&DEV_8000.DeviceDesc%= TESTstoreahci_Inst, PCI\VEN_1000&DEV_8000

[ControlFlags]
ExcludeFromSelect =*

; --------------source
[SourceDisksNames]
1=%SOURCE_DISK%

[SourceDisksFiles]
TESTstorahci.sys = 1

; --------------dest
[DestinationDirs]
DefaultDestDir = 12

[TESTstorahci_Inst]
CopyFiles = @TESTstorahci.sys
Include=mshdc.inf

[TESTstorahci_Inst.Services]
AddService = %SERVICE_NAME%, %SPSVCINST_ASSOCSERVICE%, TESTstorahci_Service_Inst, TESTahci_EventLog_Inst

[TESTstorahci_Service_Inst]
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_BOOT_START%
ErrorControl = %SERVICE_ERROR_NORMAL%
ServiceBinary = %12%\TESTstorahci.sys
LoadOrderGroup = “SCSI Miniport”

[TESTahci_EventLog_Inst]
AddReg = TESTahci_EventLog_Inst.AddReg

[TESTahci_EventLog_Inst.AddReg]
HKR,EventMessageFile,%REG_EXPAND_SZ%,“%%SystemRoot%%\System32\IoLogMsg.dll”
HKR,TypesSupported,%REG_DWORD%,7

; ******** Uninstall section ********
[DefaultUninstall]
DelFiles = @TESTstorahci.sys

[DefaultUninstall.Services]
DelService = %SERVICE_NAME%

;********************************************************
; Extra Registry Entries

[Strings]
TEST = “TEST, Inc.”
PCI\VEN_1000&DEV_8000.DeviceDesc =“TEST AHCI Controller”

SERVICE_NAME = “TESTStorAHCI”
SOURCE_DISK = “TEST AHCI Controller”

SPSVCINST_ASSOCSERVICE = 0x00000002
SERVICE_KERNEL_DRIVER = 1
SERVICE_BOOT_START = 0
SERVICE_ERROR_NORMAL = 1
REG_EXPAND_SZ = 0x00020000
REG_DWORD = 0x00010001

Thanks,

Jord

xxxxx@gmail.com wrote:

Thank you so much for pointing out addservice, I add that section and 2 in the second param. I was also doing some research online and found some information, however, I am still unable to make the service connected to the driver and device. Below is the new INF I made. Although I still can install it successfully, the “Service” value in registry still shows storahci, not TESTStorAHCI that I put down in INF. The TESETStorAHCI.sys is no in Driver folder nor in DriverStore folder. Any idea?

Yes, I see it, and you would have seen it too, if you had run “chkinf”
on this.

[TEST_AHCI.NTamd64]
%PCI\VEN_1000&DEV_8000.DeviceDesc%= TESTstoreahci_Inst, PCI\VEN_1000&DEV_8000

Notice the spelling of “store”.

[TESTstorahci_Inst]
CopyFiles = @TESTstorahci.sys
Include=mshdc.inf

Notice the spelling of “stor”.

By the way, the “Include” line is useless here, as is the
“LoadOrderGroup” in your Service section.

–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim,

Thank you so much for pointing out my typo… I feel like I am idiot :frowning: too many xxxxport, stor, ahci and all the names, nothing but confusing. :slight_smile:

So I could finally install the TESTStorAHCI driver now, but more difficulty now.

A. On the event, I could see Driver service added (TESTsorahci) and Device installed (TESTstorahci.inf)

B. But after about few seconds, a window of “Program Compatibility Assistant” popup saying
************
a digitally signed driver is required

MS AHCI Storport Miniport Driver
Windows ? Win 7 DDL provider

Windows blocked the installation of t a digitally unsigned driver. Uninstall the program or device that uses the driver and check the publisher’s website for a digitally signed version of the driver.

************

If I ignore it, and restart the computer, my Win 8 would not boot at all. Windows will go to preparing automatic repair procedure and I was enforced to go back to the restore point where I was going to install above driver. (Basically just before installing this driver).

It is odd since I did turn off signed driver requirement before I could install the TEST driver and windows did install it too. I did not have a way to use cermgr and signtool since I heard that they do not work for Windows 8 64bit.

Any idea?

Thanks!

Joard

xxxxx@gmail.com wrote:

B. But after about few seconds, a window of “Program Compatibility Assistant” popup saying
************
a digitally signed driver is required

MS AHCI Storport Miniport Driver
Windows ? Win 7 DDL provider

Windows blocked the installation of t a digitally unsigned driver. Uninstall the program or device that uses the driver and check the publisher’s website for a digitally signed version of the driver.

************

If I ignore it, and restart the computer, my Win 8 would not boot at all. Windows will go to preparing automatic repair procedure and I was enforced to go back to the restore point where I was going to install above driver. (Basically just before installing this driver).

It is odd since I did turn off signed driver requirement before I could install the TEST driver and windows did install it too.

How did you turn off the signing requirement? Did you use “bcdedit /set
testsigning on”? That doesn’t turn OFF the requirement. That merely
allows you to use a certificate that you generate yourself. All 64-bit
drivers have to be signed, unless you have the kernel debugger attached.

The Win 8 WDK will generate a certificate for you. If you’re using the
Win 7 WDK, then you have to do it yourself.

I did not have a way to use cermgr and signtool since I heard that they do not work for Windows 8 64bit.

Oh, that’s silly. Those tools work just fine.

–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim. Thanks.

Here is the way I used to turn off driver sign on win 8 64-bit box.
https://learn.sparkfun.com/tutorials/disabling-driver-signature-on-windows-8/disabling-signed-driver-enforcement-on-windows-8

I did let me install the driver without any problem but few seconds later, windows told me I need a signed driver. If I did not turn off the signed driver function, I could not install the driver at all.

So my question is, why did Windows 8 64bit let me install my TESTStorAHCI driver successfully and then quickly told me MS AHCI Storport Miniport Driver require signature …
My guess would be that TESTStorAHCI is a wrapper driver which wrap msahci ?

And why my Win 8 would not boot after driver installation.

I will try again with Win 8 WDK to generate a cert. (I tried both certmgr and singtool, they did not work for me and some one on the forum said they do not work for 64bit…)

Thanks!
Jord

and did anyone build the sample driver, storahci, from DDK, and run it correctly in win 8 64-bit?

Try a 32bit VM or learn how to work with test signed drivers. Test signed
drivers are the best way to go and are really easy to use and VS2013
express is free and automates the process.

Mark Roddy

On Fri, Aug 1, 2014 at 4:00 PM, wrote:

> Tim. Thanks.
>
> Here is the way I used to turn off driver sign on win 8 64-bit box.
>
> https://learn.sparkfun.com/tutorials/disabling-driver-signature-on-windows-8/disabling-signed-driver-enforcement-on-windows-8
>
> I did let me install the driver without any problem but few seconds later,
> windows told me I need a signed driver. If I did not turn off the signed
> driver function, I could not install the driver at all.
>
> So my question is, why did Windows 8 64bit let me install my TESTStorAHCI
> driver successfully and then quickly told me MS AHCI Storport Miniport
> Driver require signature …
> My guess would be that TESTStorAHCI is a wrapper driver which wrap msahci ?
>
> And why my Win 8 would not boot after driver installation.
>
> I will try again with Win 8 WDK to generate a cert. (I tried both certmgr
> and singtool, they did not work for me and some one on the forum said they
> do not work for 64bit…)
>
> Thanks!
> Jord
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Mark and Tim, Thanks. After several attempts of certmgr and signtool, I finally found the problem. It’s probably windows kit 8.0 and 8.1 issues where they have some missing files from each other. Such as inf2cat, and a lot of funny things going on. I managed to make it work under 8.1 anyway and now the TEST driver got signed it locally and privately and I could install and load the driver. Thank you so much! (Thanks for Google too :slight_smile: )

In driver verifier, I did see the test driver got loaded and the AHCI device works O.K. so far, HOWEVER, in the event tab, I only saw my TESTAHCI driver got installed and service added

8/1/2014 Driver service added (TESTStorAHCI)
8/1/2014 Device installed (teststorahci.inf)

I did not see “Device started (TESTStorAHCI)” in the event log nor “Device started (storahci)”?

I do not think it is normal though since if I looked into my Intel SATA controller driver’s event log, by the end of all the driver install and service loaded, it would have a “Device started (storahci)” event anyway.

That being said, I still do not think my TESTStorAHCI driver is in charge of all the required services… any idea?

Thanks!!

Jord

xxxxx@gmail.com wrote:

In driver verifier, I did see the test driver got loaded and the AHCI device works O.K. so far, HOWEVER, in the event tab, I only saw my TESTAHCI driver got installed and service added

8/1/2014 Driver service added (TESTStorAHCI)
8/1/2014 Device installed (teststorahci.inf)

I did not see “Device started (TESTStorAHCI)” in the event log nor “Device started (storahci)”?

I do not think it is normal though since if I looked into my Intel SATA controller driver’s event log, by the end of all the driver install and service loaded, it would have a “Device started (storahci)” event anyway.

Did you check the registry to make sure your service is listed as the
controlling service? I gave you the registry location earlier. Did you
try to reboot?

–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim,

Did you check the registry to make sure your service is listed as the controlling service? I gave you the registry location earlier. Did you try to reboot?

HKLM\System\CurrentControlSet\Enum\PCI\VEN_1000&DEV_8000,

YES, every time when I thought I did successfully install the TESTStorAHCI driver, I did check the first subkey and its service value, looks like it is still storahci.

However there are other register folders under VEN_1000&DEV_8000 , several of them have service value with TESTStorAHCI. Can I delete these folders?

Thanks,

Jord

To make it more specific, I found that if I used W8 inbox AHCI driver, I would see two important entries in Event:

Driver configured (mshdc.inf)
Device started (storachi)

These two do not show up now in my TEST Driver.

and the service value in register still shows storahci. I thought it should be TESTStorAHCI in my inf.

Thanks,

Jord

xxxxx@gmail.com wrote:

To make it more specific, I found that if I used W8 inbox AHCI driver, I would see two important entries in Event:

Driver configured (mshdc.inf)
Device started (storachi)

These two do not show up now in my TEST Driver.

and the service value in register still shows storahci. I thought it should be TESTStorAHCI in my inf.

You need to remember that the Enum tree contains every device the system
has ever seen, not just the devices that are currently live. If you
plug a USB device with no serial number into four different slots,
you’ll have 4 subkeys in the Enum tree, but only one of them actually
represents the device in its current slot. If you change the driver for
an inactive entry, it’s not going to change the live device.

In your case, if you have one device but four subkeys in the Enum tree,
three of those subkeys are vestiges. You need to figure out which one
is current. Usually, that’s fairly easy: active devices will have a
“Control” subkey, and vestigial devices will not.

So, find the one with a “Control” subkey. Check the Service entry, and
check the “ActiveService” value within the “Control” subkey.

–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim, Thanks. Looks like you are right!! only one has control subkey, others only have one subkey which is properties.
The Control subkey belongs to my TESTStorAHCI driver :slight_smile:
So all looks good from register point of view, however, I still believe it’s running W8’s inbox storahci driver since I did add some debug logs in my own TESTStorAHCI driver, but those debug logs never got triggered from debugviewer (dbgview).

Plus, there is no such event in my driver -
Driver configured (mshdc.inf) and Device started (storachi)

Any thought?

Thanks,

Jord

other than dbgview, is there any other way I can read over the debug logs during runtime that I added in the codes?

Thanks,

Jord

xxxxx@gmail.com wrote:

other than dbgview, is there any other way I can read over the debug logs during runtime that I added in the codes?

They also appear in the kernel debugger. Did you “Enable Verbose Kernel
Output” in dbgview?

–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim,
YES, I did enable verbose kernel output but did not see any logs from my TESTStorAHCI driver. That’s why I believe this hardware is still driven by inbox AHCI. What could be wrong? do I have to do anything from source codes? I did build it for debug release and added some logs, that’s all I did…

Thanks,
Jord.

xxxxx@gmail.com wrote:

YES, I did enable verbose kernel output but did not see any logs from my TESTStorAHCI driver. That’s why I believe this hardware is still driven by inbox AHCI. What could be wrong? do I have to do anything from source codes? I did build it for debug release and added some logs, that’s all I did…

Have you hooked up a kernel debugger yet? Add a DbgBreakPoint call in
your DriverEntry and see if you hit the breakpoint. If you do, then the
problem is in the plumbing.

–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.