PDA

View Full Version : [DEV-UTIL][19.03.2009]DriverWiz - Make signed CABs from driver DLLs that work


Chainfire
19th March 2009, 05:32 PM
Intro
Lately I've seen a lot of posts by people who are trying to replace WM internal or driver DLLs, either for hacking/testing or to release. Aside from the possibility they are just doing something that won't work in the first place, I've seen failure a lot of times because files aren't properly signed, or if they are, the certificate in question not being in the right certificate stores for it to have any effect. On some ROMs it will still work due to patched NK.EXE, on others it won't, its just not very reliable.

So, I present you with the correct way of doing this by means of a small tool that will do this for you: DriverWiz. It will take care of most of the stuff, and leave you room for additions. You will however still need some basic knowledge of the command line, if you don't have that, you have no business doing anything like this anyways.

Background
I use this technique myself all the time. When just hacking away, replacing system DLLs to trace calls, etc. It's also the same method used for the HTC-CA drivers and the ICS installer. This method works on most stock ROMs as well, though not on all of them (in rare cases some security policies are set that will prevent CAB installation)

Usage
It's fairly simple to use. Just extract the attached zip file somewhere, open the command promt, and change directory to where the zip was extracted. That's the installation part.

Now when you actually want to build a CAB file from a DLL, you use the DriverWiz.bat file.


DriverWiz v1.0 by Chainfire

Usage:
DriverWiz.bat "Description" "CAB-name" "DLL-name-1" ["DLL-name-2" ...]

Examples:
DriverWiz.bat "New DDI" "ddi.cab" "ddi.dll"
DriverWiz.bat "Two DDIs" "ddi.cab" "ddi.dll" "ddiaux.dll"


DriverWiz will take care of signing the DLLs, inserting the certificate, etc, and you will end up with a proper CAB file for this kind of thing. Just copy it to your device and run it to install.

#1. You need to put the DLL files in the same folder as DriverWiz. Do NOT include paths in your DLL names
#2. Include the quotes in the command like in the examples!
#3. The first time you install a CAB made by DriverWiz, your phone may still give you a certificate warning. This is normal, don't worry about it.

Caveats
While this method has never failed me yet, it is possible that some files cannot be replaced this way. Just a disclaimer :)

Modifying
DriverWiz bases the inf file it will create to build a CAB from on DriverWiz.tpl. If you need to add registry entries to your CAB file, modify DriverWiz.tpl before you run the batch file. You can make other modifications too, add files, etc. Just take care that you don't break it :)

You can use your own certificates as well, instead of the supplied "Dummy" certificate that comes with DriverWiz. The files you will want to modify/replace are DriverWiz.pfx (used for signing) and DriverWiz.xml (used for injecting the certificate). I'll see about finding a reference for how to do that online and posting the URL here (someday). Creating a new certificate from scratch can be a frustrating effort - make sure you got openssl handy :)

Changelog
19.03.2009 - 1.1 - Added some file exists checks and attribute changes

Download

Chainfire
19th March 2009, 05:32 PM
Temporary PlaceHolder for more Info.

bram_smulders
19th March 2009, 05:35 PM
Whoo this is hot from the plate, looks very promising!
Driver testing withoud cooking! joohie

Chainfire
19th March 2009, 05:56 PM
Well if you replace the wrong files you're still going to need to hard-reset to boot. I advise KITL before you do :)

P1Tater
19th March 2009, 06:10 PM
Works flawless. You tha man.:D

ruskiyab
19th March 2009, 06:42 PM
Didn't work for me trying to cab up No2Chems Fast Charge battery divers.

Chainfire
19th March 2009, 06:46 PM
Didn't work for me trying to cab up No2Chems Fast Charge battery divers.

What exactly happened? Attach the files and such :)

ruskiyab
19th March 2009, 07:01 PM
It made the cab and all, but when I went to install it, the unsigned error message popped up just like when I tried it with WinCE cab manager.

Chainfire
19th March 2009, 07:20 PM
That is perfectly normal behavior. The first time you install a CAB with this certificate it will not know the certificate. However, once you install it, the certificate will be injected in the right place, and the files signed with the certificate (the driver files in the CAB) will be allowed to be run.

It won't happen the second time you try it :)

ruskiyab
19th March 2009, 07:41 PM
So if I try to install it again, it'll work fine? is there aa soft reset required in between? I can replace these drivers manually by renaming the old ones and copying them over, the whole reason I want a cab in the first place is to facilitate the UC process when I flash a different rom

Chainfire
19th March 2009, 07:48 PM
So if I try to install it again, it'll work fine? is there aa soft reset required in between? I can replace these drivers manually by renaming the old ones and copying them over, the whole reason I want a cab in the first place is to facilitate the UC process when I flash a different rom

Actually it should just work the first time. Just click OK when the certificate error appears.

JonInAtl
19th March 2009, 08:55 PM
Nice nice nice work!

Captain_Throwback
21st March 2009, 02:43 AM
I got error messages when creating a cab from a rilphone.dll. Does it mean anything, or are these errors okay? I guess I'm specifically wondering about the SignTool error. If its okay, then my cab should be good.

EDIT: I think I found the problem. I didn't have UAC disabled in Windows 7. I tried it again, after disabling it, and it works fine now. Thanks for the easy to use tool!

Captain_Throwback
4th April 2009, 12:59 AM
I was experimenting with creating a cab for the Rogers folks who need a specific rilphone for their Caller ID to work. There are some registry entries associated with this feature, so I was wondering what the correct syntax is for putting the registry entries into the .tpl file. I've tried a few different ways, and I've either a gotten a 'Registry section is empty' message, or a 'Registry has an unsupported registry root key' error. I'm sure its something really simple I'm missing, so any help you can offer is appreciated.

It just seems that since we now have this easy method to sign these dlls, so that they can be used in any ROM, that the Rogers people shouldn't have to jump through so many hoops to get it to work.

EDIT: Nevermind. I'm an idiot that didn't do a little bit of research. All is well now.

stepw
4th April 2009, 02:37 AM
Excellent stuff, Microsoft may rant about this way of distributing signtool and cabwiz though.


You can use your own certificates as well, instead of the supplied "Dummy" certificate that comes with DriverWiz. The files you will want to modify/replace are DriverWiz.pfx (used for signing) and DriverWiz.xml (used for injecting the certificate). I'll see about finding a reference for how to do that online and posting the URL here (someday). Creating a new certificate from scratch can be a frustrating effort - make sure you got openssl handy :)


Here's an intro to cert stores for WM:
http://msdn.microsoft.com/en-us/library/aa458010.aspx

pfx generation is a 2-liner with openssl:
# Generate a CA certificate
openssl req -new -nodes -x509 -days 9999 -newkey rsa:1024 -md5 -keyout cert.key -out cert.cer -subj "/CN=DriverWiz"
# Convert to pkcs12/PFX format
openssl pkcs12 -export -in cert.cer -out cert.pfx -inkey cert.key

tornado81
5th April 2009, 04:54 PM
got error messages under vista sp2, any ideas?:confused:

vangrieg
20th April 2009, 11:34 AM
I also get an error saying that the latest version of CAPICOM.dll is missing. The ones I can find for download from the internet are version 2.0.0, and the tool requires 2.1.0.1 or later.

Does anyone have the needed version of the dll?

EDIT: Found it, 2.1.0.2 version of the dll is in the attachment.

hilaireg
24th April 2009, 08:14 PM
Many thanks; DriverWiz /w the CAPICOM.DLL saved me about an hour of troubleshooting.

Cheers,

Noonski
16th July 2009, 07:37 PM
Thanks for the capicom.dll Even after disabling UAC in W7Rc1 it wouldn't go, so great to have it posted to.


Chainfire, which format should the Reg's be added?

I tried the default .reg formating just under:

[Registry]
[HKEY_CURRENT_USER\ControlPanel\Profiles]
@=""
"ActiveProfile"="Normal"
?

Scrap that i found the .inf format

[AddRegistry]
HKCU,"New Key","",0x00010001,1

Many thanks for this, i'll try to Point Driver replacing Sinners from now on to here.

Chainfire
17th July 2009, 11:52 PM
Well INF files are a regular female dog.

If you rather use WinCE CAB Manager, the trick is easily done as well. I do not have it handy right here (I'm not at dev box), but it goes like this.


Put the DLL's and EXE's that need to go in the CAB into the same folder as DriverWiz
Execute the following command from the command prompt in the DriverWiz folder: signtool sign /f DriverWiz.pfx *.exe *.dll
Open your WCM/CAB with CM
Somewhere is an option for "Pre XML" (main screen IIRC).. click to add/edit, and load the DriverWiz.xml file
Save
signtool sign /f DriverWiz.pfx *.cab


Et voila. I should really make an update to DriverWiz to include CAPICOM and write a proper guide on how to do all this manually (including making your own certificates and such). It's easy if you know how :)

If you could insert another empty post for me at the top, that'd be great.

Noonski
18th July 2009, 03:04 AM
Consider it Done.

Thanks for the Extra Info i didn't know that.

cnzqy1
27th August 2009, 06:02 AM
Hello, I tried to use this tool to change my rilphone.dll, but I will get stuck at the first screen as I soft reset and I have to hard reset. Any solutions? Thanks!

pyrorob
27th August 2009, 06:37 AM
hey maybe you can help me. im trying to sign a phcanoverbmp.dll and no matter what signer i use it wont take. nothing will add the signature information to the dll, your program or any other. when i check it in pe explorer there is never any authanticode signature ever added. im a little stumped as to why this is happening since ive signed dll's in the past..
any ideas?

Captain_Throwback
27th August 2009, 06:14 PM
Hello, I tried to use this tool to change my rilphone.dll, but I will get stuck at the first screen as I soft reset and I have to hard reset. Any solutions? Thanks!
Perhaps the problem is not this tool (which it really shouldn't be, if you were able to install the cab successfully) - did you try to install an incompatible rilphone on your device (like perhaps, and Xperia rilphone on a Diamond/Touch Pro)?
hey maybe you can help me. im trying to sign a phcanoverbmp.dll and no matter what signer i use it wont take. nothing will add the signature information to the dll, your program or any other. when i check it in pe explorer there is never any authanticode signature ever added. im a little stumped as to why this is happening since ive signed dll's in the past..
any ideas?
Did you remember to unsign it prior to making the modifications to it? That happened to me before when I forgot to unsign it, then modded and saved it. I couldn't sign it with anything. I had to start over. But hopefully there's another way.

At0mAng
24th September 2009, 09:45 PM
Hi,
I am trying to make a cab with rilphone.dll from new Rhodium 6.5 ROM. I believe everything is working fine but I get no radio after I install cab file. Rilphone.dll works fine when cooked in so I do not think that is the issue. I installed SDKCerts.cab before I install new cab but still no luck :(

I attached original dll file too if anyone can help.

Thanks!

Here is output of driverwiz

C:\DriverWiz>DriverWiz.bat "new DDI" "rilphone21841.cab" "rilphone.dll"
DriverWiz v1.1 by Chainfire

--- Deleting old files... ignore file not found errors
Could Not Find C:\DriverWiz\rilphone21841.cab
Could Not Find C:\DriverWiz\DriverWiz.inf
Could Not Find C:\DriverWiz\DriverWiz_MakeCAB.bat
--- Creating inf file from DriverWiz.tpl
--- Changing attributes
--- Signing DLL files
Done Adding Additional Store
Successfully signed: rilphone.dll
--- Creating CAB
Windows CE CAB Wizard
Warning: Section [Registry] has no data
Warning: Section [DefaultInstall] key "AddReg" - there are no section entries to
process
--- Signing CAB
Done Adding Additional Store
Successfully signed: DriverWiz.CAB
--- Renaming to "rilphone21841.cab"
--- Deleting old files... ignore file not found errors
--- Done

abusalza
25th September 2009, 04:33 AM
Hi,
I am trying to make a cab with rilphone.dll from new Rhodium 6.5 ROM. I believe everything is working fine but I get no radio after I install cab file. Rilphone.dll works fine when cooked in so I do not think that is the issue. I installed SDKCerts.cab before I install new cab but still no luck :(

I attached original dll file too if anyone can help.

Thanks!

Here is output of driverwiz

C:\DriverWiz>DriverWiz.bat "new DDI" "rilphone21841.cab" "rilphone.dll"
DriverWiz v1.1 by Chainfire

--- Deleting old files... ignore file not found errors
Could Not Find C:\DriverWiz\rilphone21841.cab
Could Not Find C:\DriverWiz\DriverWiz.inf
Could Not Find C:\DriverWiz\DriverWiz_MakeCAB.bat
--- Creating inf file from DriverWiz.tpl
--- Changing attributes
--- Signing DLL files
Done Adding Additional Store
Successfully signed: rilphone.dll
--- Creating CAB
Windows CE CAB Wizard
Warning: Section [Registry] has no data
Warning: Section [DefaultInstall] key "AddReg" - there are no section entries to
process
--- Signing CAB
Done Adding Additional Store
Successfully signed: DriverWiz.CAB
--- Renaming to "rilphone21841.cab"
--- Deleting old files... ignore file not found errors
--- Done

i have switch-able rilphone.dll on my kaiser and both are working as well.
what i did just put the rilphone.dll into wince cab manager and patched nk.exe with nocert-patched by cmonex...

mccune
28th September 2009, 10:11 PM
Hi,
I am trying to make a cab with rilphone.dll from new Rhodium 6.5 ROM. I believe everything is working fine but I get no radio after I install cab file. Rilphone.dll works fine when cooked in so I do not think that is the issue. I installed SDKCerts.cab before I install new cab but still no luck...................

Same result on a stock ROM from T-Mobile (Vario V).

Chainfire
28th September 2009, 10:56 PM
No idea what the issue might be with that... This method has never failed me before.

I thought about maybe the files are not compatible, but that does not seem to be the case as it does work when cooked in. Very strange. Perhaps something did go wrong? Your 'log' looks good though.

mccune
28th September 2009, 11:55 PM
I was also thinking the rilphone.dll was not compatible. But as At0mAng describes it works when cooked with the ROM. I can't verify that, but for now I would say that it's because of the dll file...

Captain_Throwback
28th September 2009, 11:58 PM
I've actually created a few rilphone cabs with this awesome tool that didn't work for everyone. It doesn't seem to be consistent whether it works or does not for a particular user. It sounds like At0mAng is a user for which it isn't working :rolleyes:. Did you try creating a cab using a different rilphone, and see if it works? That can help you determine whether the tool is at fault, or the driver (or a conflict).

Noonski
29th September 2009, 12:20 AM
I was also thinking the rilphone.dll was not compatible. But as At0mAng describes it works when cooked with the ROM. I can't verify that, but for now I would say that it's because of the dll file...

Off Topic:
How's it Going McCune!

mccune
29th September 2009, 12:36 AM
Off Topic:
How's it Going McCune!
I'm doin' well. How about yourself?
Haven't been as active as I did on the O.R.D.E. project for the Diamond.
Should get active and flash the Rhodium. But all in time!
For now I do a lot of reading, but I'm still here. Will see ya around!

At0mAng
9th October 2009, 07:04 AM
I've actually created a few rilphone cabs with this awesome tool that didn't work for everyone. It doesn't seem to be consistent whether it works or does not for a particular user. It sounds like At0mAng is a user for which it isn't working :rolleyes:. Did you try creating a cab using a different rilphone, and see if it works? That can help you determine whether the tool is at fault, or the driver (or a conflict).

I have tried everything I could think of. I even started fresh with new ROM folder for Visual Kitchen to make sure all permissions were done correctly.

I used Xipporterex & ROM tools to appy cert patch to nk.exe, I manually did the same with a hex editor and I have the option enabled in VK too.

I also tried with fresh ROM folder and let VK handle everything but still no work.

I tried remove singnature from file and then use the signing tool to sign it and install via cab too but it did not work. I also tried the trick to turn off radio, copy rilphone.dll over to windows folder, reboot and yet I still can not enable radio.

Can the signatures be different in Touch Pro2 or something? I can make the rilphone.dll all day and night with no problems on Touch Pro but can't get it to work for the life of me with TP2.

JVH3
10th July 2010, 10:56 PM
Well INF files are a regular female dog.

If you rather use WinCE CAB Manager, the trick is easily done as well. I do not have it handy right here (I'm not at dev box), but it goes like this.


Put the DLL's and EXE's that need to go in the CAB into the same folder as DriverWiz
Execute the following command from the command prompt in the DriverWiz folder: signtool sign /f DriverWiz.pfx *.exe *.dll
Open your WCM/CAB with CM
Somewhere is an option for "Pre XML" (main screen IIRC).. click to add/edit, and load the DriverWiz.xml file
Save
signtool sign /f DriverWiz.pfx *.cab

Et voila. I should really make an update to DriverWiz to include CAPICOM and write a proper guide on how to do all this manually (including making your own certificates and such). It's easy if you know how :)

If you could insert another empty post for me at the top, that'd be great.

This worked great using Visual Studio 2008 as well.

First sign the files of type exe and dll - just like in your instructions.
Put them into the cab
Build the cab.
Sign the cab. - just like in your instructions.

trusa1
13th July 2010, 06:38 AM
Thank you, finally my modified SIPBitmaps.dll working fine.