[How To] Alternate use for INF RegisterDLLs

Discuss & post Update Pack addons here.
Post Reply
User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

[How To] Alternate use for INF RegisterDLLs

Post by ricktendo64 » Sun Aug 26, 2007 1:34 pm

Hey guys I just wanted to document some cool alternate INF RegisterDLLs usage.

Every body knows the basics

Code: Select all

16422,%ProgDir%,Program.dll,1

11,,ShellExt.dll,1
Here are a few other ways you can use RegisterDLLs:

You can use it to register/install a EXE example

Code: Select all

16422,%SIDEBAR%,sidebar.exe,,,"/RegServer" ;<-Self Registering

16422,%SIDEBAR%,sidebar.exe,,,"/UnregServer" ;<-Self UnRegistering

16422,%TRAYSOFT%,PhoneTray.exe,,,"-install" ;<-Custom Switch
You can even call regsvr32.exe to do the registering

Code: Select all

11,,regsvr32.exe,,,"/s %16422%\%ProgDir%\Program.dll"

11,,regsvr32.exe,,,"/s %16422%\%ProgDir%\Program.ocx"
I found you can also launch your custom INF sections

Code: Select all

11,,rundll32.exe,,,"advpack.dll,LaunchINFSection InfFile.inf,InfSectionName"

11,,rundll32.exe,,,"setupapi,InstallHinfSection InfSectionName Flag InfFile.inf"
Use it to delete folders :P

Code: Select all

11,,rundll32.exe,,,"advpack.dll,DelNodeRunDLL32 %16422%\%DirName%,Flag"
==================================================

On a sidenote, I tried installing MSI files but it did NOT work

Code: Select all

11,,msiexec.exe,,,"/i %10%\Installer.msi /qn"
BTW all the above get executed during T-23
For more info on this that might give you a better idea you can read the OSR Guide to INF's where you will find more info on Flags and Timeout and other stuff. You can also find some of these examples if you look in syssetup.inf in your install disc.

User avatar
dumpydooby
Posts: 530
Joined: Sun Jan 15, 2006 6:09 am

Post by dumpydooby » Sun Aug 26, 2007 5:33 pm

Well done.

Mitsuko Aninikkou
Posts: 210
Joined: Tue Dec 13, 2005 12:52 pm
Location: The Netherlands (But running US WinXP, in case it comes up)

Post by Mitsuko Aninikkou » Thu Aug 30, 2007 9:58 pm

Great How To, rick, I'm sure this will come in handy ^_^
Especially since this is the only way I know of to get to advpack.dll simply by right-click-Install-ing the inf file. Very cool.

Edit: by the way can you install .msi files from RunPreSetupCommands/RunPostSetupCommands? If so this should work: (inf file called theInf.inf: it calls itself)

Code: Select all

[Version]
Signature = $Windows NT$

[DefaultInstall] 
RegisterDLLs = GoToRunMSI 

[GoToRunMSI] 
11,,rundll32.exe,,,"advpack.dll,LaunchINFSection %1%\theInf.inf,RunMSI" 

[RunMSI] 
RunPreSetupCommands = RunMSI.run

[RunMSI.run]
"""%10%\Installer.msi""" /qn
Edit2: corrected the inf code (in case anyone wants to use it as a template) and put it into a code box
Last edited by Mitsuko Aninikkou on Thu Aug 30, 2007 11:01 pm, edited 1 time in total.

User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

Post by ricktendo64 » Thu Aug 30, 2007 10:53 pm

Glad you like it :P

As for the MSI installation/repair I already do something similar using RunPre/PostSetupCommands in my Sidebar AddOn

Install code

Code: Select all

[Gad.Installer.Install]
MSIEXEC /i """%16422%\%VISXORG%\GadgetInstallerSetup.msi""" /qn
Repair code

Code: Select all

[Gad.Installer.Repair]
MSIEXEC /f {3F3733A5-8322-454D-A638-3B74E1C83752} /qn

Mitsuko Aninikkou
Posts: 210
Joined: Tue Dec 13, 2005 12:52 pm
Location: The Netherlands (But running US WinXP, in case it comes up)

Post by Mitsuko Aninikkou » Thu Aug 30, 2007 11:06 pm

Thanks for the confirmation, Rick, just did some testing and corrected the code in my previous post. (RegisterDLLs section fails with just 'rundll32', it needs to be 'rundll32.exe' as in your guide)

User avatar
ricktendo64
Posts: 3213
Joined: Mon May 22, 2006 12:27 am
Location: Honduras

Post by ricktendo64 » Thu Aug 30, 2007 11:15 pm

Can I ask you for detailed instructions how you calculate/translate 0x00000008 and other INF flags... What formula can I use to do this :D

EIDT: BTW I know how you can add these types of shortcuts using ProfileItems

Code: Select all

[inst.shortct]
setup.ini,progman.groups,,stamenu=%16407%\%disp_name%
setup.ini,stamenu,,"%disp_name% Readme,""""""%16422%\%disp_name%\readme.txt"""""""
setup.ini,stamenu,,"Uninstall %disp_name%,""%launchinf%%prog_infs%.inf,DefaultUninstall"",%11%\setupapi.dll,-54"
The instructions (look at the CMD shortcut example. Just change the shell32 icon to match the txt and/or uninstall icons of your choice)

yumeyao
Moderator
Posts: 1718
Joined: Sun Aug 27, 2006 9:24 pm
Location: Taiyuan, Shanxi, PR China

Post by yumeyao » Fri Aug 31, 2007 12:43 am

this is cool!!!
Image
My work list(Hosted by dumpydooby)

Mitsuko Aninikkou
Posts: 210
Joined: Tue Dec 13, 2005 12:52 pm
Location: The Netherlands (But running US WinXP, in case it comes up)

Post by Mitsuko Aninikkou » Fri Aug 31, 2007 11:39 am

ricktendo64 wrote:BTW I know how you can add these types of shortcuts using ProfileItems
Yeah I know, I only use UpdateInis there because it saves me a few lines :) I've saved all of that guide to a file though, as it's pretty useful.
ricktendo65 wrote:Can I ask you for detailed instructions how you calculate/translate 0x00000008 and other INF flags... What formula can I use to do this?
Sure, it's actually really simple. To translate any 0x[hexadecimal number] flag, just use windows calculator in scientific mode. Set it to Hex, enter the number (without the 0x), set it to Dec, and voila :)

As for how to combine flags, do you know how flags work? They're actually binary numbers that have certain bits set (0x00000008 is actually 0b00000000000000000000000000001000, for instance), and which bits are set determines which action will be taken. For example, to check if the third bit from the right is set a programmer would use "if(flag & (1 << 2)){do stuff;}". (in c++ anyways) So to combine flags all you have to do is figure out which bits are set, then combine them and convert back to decimal or hexadecimal. Windows calculator is, again, useful for this. Of course not all combinations are meaningful, and a program might check for more specific combinations.

User avatar
code65536
Posts: 735
Joined: Wed Mar 14, 2007 2:58 pm
Location: .us
Contact:

Post by code65536 » Fri Aug 31, 2007 12:09 pm

Perhaps what ricktendo64 wanted was this:

Code: Select all

// Flags for AddReg section lines in INF.  The corresponding value
// is <ValueType> in the AddReg line format given below:
//
// <RegRootString>,<SubKey>,<ValueName>,<ValueType>,<Value>...
//
// The low word contains basic flags concerning the general data type
// and AddReg action. The high word contains values that more specifically
// identify the data type of the registry value.  The high word is ignored
// by the 16-bit Windows 95 SETUPX APIs.
//
// If <ValueType> has FLG_ADDREG_DELREG_BIT set, it will be ignored by AddReg
// (not supported by SetupX).
//

#if _SETUPAPI_VER >= 0x0501

#define FLG_ADDREG_DELREG_BIT       ( 0x00008000 ) // if set, interpret as DELREG, see below

#endif // _SETUPAPI_VER >= 0x0501

#define FLG_ADDREG_BINVALUETYPE     ( 0x00000001 )
#define FLG_ADDREG_NOCLOBBER        ( 0x00000002 )
#define FLG_ADDREG_DELVAL           ( 0x00000004 )
#define FLG_ADDREG_APPEND           ( 0x00000008 ) // Currently supported only
                                                   // for REG_MULTI_SZ values.
#define FLG_ADDREG_KEYONLY          ( 0x00000010 ) // Just create the key, ignore value
#define FLG_ADDREG_OVERWRITEONLY    ( 0x00000020 ) // Set only if value already exists

#if _SETUPAPI_VER >= 0x0501

#define FLG_ADDREG_64BITKEY         ( 0x00001000 ) // make this change in the 64 bit registry.
#define FLG_ADDREG_KEYONLY_COMMON   ( 0x00002000 ) // same as FLG_ADDREG_KEYONLY but also works for DELREG
#define FLG_ADDREG_32BITKEY         ( 0x00004000 ) // make this change in the 32 bit registry.

#endif // _SETUPAPI_VER >= 0x0501

//
// The INF may supply any arbitrary data type ordinal in the highword except
// for the following: REG_NONE, REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ.  If this
// technique is used, then the data is given in binary format, one byte per
// field.
//
#define FLG_ADDREG_TYPE_MASK        ( 0xFFFF0000 | FLG_ADDREG_BINVALUETYPE )
#define FLG_ADDREG_TYPE_SZ          ( 0x00000000                           )
#define FLG_ADDREG_TYPE_MULTI_SZ    ( 0x00010000                           )
#define FLG_ADDREG_TYPE_EXPAND_SZ   ( 0x00020000                           )
#define FLG_ADDREG_TYPE_BINARY      ( 0x00000000 | FLG_ADDREG_BINVALUETYPE )
#define FLG_ADDREG_TYPE_DWORD       ( 0x00010000 | FLG_ADDREG_BINVALUETYPE )
#define FLG_ADDREG_TYPE_NONE        ( 0x00020000 | FLG_ADDREG_BINVALUETYPE )
(Copied from setupapi.h from the XPSP2 Platform SDK)

The DELREG keys are similar, so I'll omit them. But basically, when you have a flag like 0x3, you will look at the list of flags to see which ones add up to that (well, technically, bitwise-or for creation of flags and bitwise-and for testing of flags, but for the sake of human calculation, we'll say addition, which is not technically correct, but works in the case of flags). In this case, the flags that add up to 0x3 are FLG_ADDREG_BINVALUETYPE and FLG_ADDREG_NOCLOBBER.

Note that some flags are marked as XP-only (_SETUPAPI_VER >= 0x0501)

For example, if you wanted to add a string value only if an existing value does not exist (don't clobber), you'll use 0x2 instead of the usual 0x0, and if you want to do that with a DWORD, you'll use 0x10003 instead of the usual 0x10001.
My addons: CmdOpen - HashCheck - Notepad2 - MS Runtimes - DirectX

Into the breach, meatbags!

Post Reply