Help - Search - Members - Calendar
Full Version: BartePE for Beginners - Tutorial 2 of 4
The CD Forum > Bart's PE Builder > General
Fred Retread
I hope that at this point you have successfully produced a BartPE CD even if it's just the one that results from the raw pebuilder3110a distribution file, as described in my first tutorial. So now let's talk about plugins. I'm going to assume that you have pebuilder3110a installed on the C: drive of your computer. That was Phase I. Now we're ready for:

Phase II: Creating and Working with Plugins
Let's begin by using Windows Explorer or a similar utility to expand the C:\pebuilder3110a directory one level and look at it. The subdirectories we will refer to frequently are "C:\pebuilder3110a\BartPE" and "C:\pebuilder3110a\plugin." Let's use the notation C:\..\BartPE and C:\..\plugin for those.

C:\..\BartPE and its subfolders are the destination that pebuilder program copies files to during the building process. The copied files come from the XP source directory and from the C:\..\plugin directory. The content of the ISO image file that gets burned to the CD consists of those files and the registry created by pebuilder process.

Each subfolder of C:\..\plugin is, of course, what we refer to as a plugin. A plugin folder contains a [program name].inf file, a [program name].xml file, and program files. The program files may be in the main plugin folder or in subfolders. The .inf file tells pebuilder what folders to create in C:\..\BartPE, what files from the plugin's folders to put in them, and, if necessary, what keys need to be added to the registry. The .xml file sets up the plugin's program in the Bart start menu.

Before we proceed I suggest that you tidy up your pebuilder3110a installation a bit. If you used my first tutorial you'll see that you the C:\..\plugin folder has a lot of subfolders, yet C:\..\BartPE\Programs folder only has a handful of programs in it That's because a lot of the plugins that came in the distribution file are in disabled status, waiting for you to find and download their missing program files. Good luck doing that, since pebuilder3110a is more than five years old. So run pebuilder and press the "Plugins" button to view the status of all the plugins.. You can delete plugins by highlighting them and pressing the "Remove" button. Personally, I removed all the ones that had a "no" in the "enabled" column, except for dcomlaunch which is needed (at least it is with SP2— I don't know about SP1 or SP3) even though its enabled status is "no."

There are many pre-made plugins posted in repositories on the internet. You can find them here at 911cd.net and elsewhere on the internet. If they are really complete you can simply place their files into new folders created under C:\pebuilder3110a\plugin and you have yourself a new plugin. But many of them only contain the .inf and .xml files, and require you to obtain the program files separately. Nevertheless, you can surely find some plugins that you want that way. But the focus of this tutorial is how to build your own.

To build a plugin for a program, first you have to figure out what files the program needs, and what registry keys, if any, are essential. That can be a bit of a guessing game. But as you learn, it becomes an educated guessing game. The good news is that many programs will run without registry keys even though registry keys are created when they are installed. So starting by placing just the files and folders that a normal install process places in a new C:\Program Files subfolder is an approach that may lead to quick success. For cases where that approach doesn't work we'll discuss later how to find out what registry keys are needed and how to enter them. Either way, the second challenge is to figure out how to code the information for pebuilder.

Once you have the files, as describe above, you can often successfully create a plugin by adapting the .inf and .xml files from an existing one. Create your plugin folder and put your working files in it. Then copy in the .inf and .xml files from an existing plugin, rename them appropriately and then edit them using your intuition, common sense and growing knowledge to make them fit your program files.

But let's build a plugin from scratch and discuss the reasoning behind each step. As an example we will make a plugin for Miray Software's very excellent free version of HDClone. I suggest that you actually get yourself a copy and install it on your computer right now, then come back. I think you'll find this to be a very desirable program to have on your Bart disk. I like it so much I actually bought the standard edition. If I haven't convinced you, just read along. But as a high school teacher my experience tells me that you won't learn as much that way.

After the installation of HDClone, if you look in C:\Program Files\HDClone 4 Free Edition you'll see that the only installed files are seven files in the parent folder and one subfolder named "bootimages" containing three more files. Those three files are image files—it happens that HDclone has its own ability to create bootable HDClone disks and USB sticks and needs those image files.

So we create a folder called C:\pebuiler3110a\plugin\hdclone. From the installation's parent folder we copy five of the seven files (we recognize by their names that the other two are uninstall files that we certainly don't need) into our plugin's parent folder. And we copy the "bootimages" subfolder with its files in it to our plugin's parent folder. Now we open Notepad or another simple ASCII text editor to create the .inf file, which we may as well name hdclone.inf

Here we go.

First, all plugins start like this:
CODE
; PE Builder v3 plug-in INF file for HDClone

[Version]
Signature= "$Windows NT$"
Notes:
Reminder: a semicolon ; means that what follows on that line is a comment only
The [Version] section above is always required.

Next:
CODE
[PEBuilder]
Name="HDClone"
Enable=1
Help="hdclone.pdf"
Notes:
Name= The actual name is arbitrary here. It is not used anywhere. You could put "Barak Obama" or "Sarah Palin" there if you wanted to. And spaces are permitted in the name.
Enabled= 1 means the plugin is active, 0 would mean it is not. The enabled status is switchable later from within pebuilder.
Help= the name of the program's help file goes here

Next:
CODE
[WinntDirectories]
a="Programs\hdclone",2
b="Programs\hdclone\bootimages",2
Notes:
The [WinntDirectories] section tells pebuilder what subfolders to create under C:\..\BarttPE
The syntax is: directoryID=dirname[, number] where the number will be 0, 1, 2, or 3.
We will normally use 2 in our plugins. Maybe 3, but never 0 or 1. The reason for this is that in this section the numbers have the following meanings:
a="Programs\hdclone",0 – would mean create subfolder Programs\hdclone in C:\..\BartPE\i386 and associate it with the variable, a, which really just says a=C:\BartPE\i386\Programs\hdclone. But that's not where we want our files to go.
a="Programs\hdclone",2 – means create subfolder Programs\hdclone in C:\..\BartPE and associate it with the variable, a, or a=C:\BartPE\Programs\hdclone. This is the right choice for us.
adding 1 to either of those numbers adds the instruction to create the subfolder even if it is empty, so
a="Programs\hdclone",1 – would mean create subfolder Programs\hdclone in C:\..\BartPE\i386 even if it's empty
a="Programs\hdclone",3 – would mean create subfolder Programs\hdclone in C:\..\BartPE even if it's empty
b="Programs\hdclone\bootimages",2 – would mean create subfolder Programs\hdclone\bootimages in C:\..\BartPE and associate it with b
The a and the b. can (and will) now be used in the [SourceDisksFiles] secton as variables that represent those folders

Next:
CODE
[SourceDisksFiles]
files\hdclone.exe=a,,1
files\readme.txt=a,,1
files\*.ico=a,,1
files\hdclone.pdf=a,,1
files\bootimages\hdclone.iso=b,,1
files\bootimages\*.img=b,,1
Notes:
The [SourceDisksFiles] section tells pebuilder which folder under C:\..\BartPE to put each of our program's files in.
The syntax is: filename=directoryID[, filenameRenamed][, number] where the number will be 1,2,3,4,5,6,7 or 8
files\hdclone.exe=a,,1 tells pebuilder to copy the file named files\hdclone.exe to the folder associated with a by the statement in the [WinntDirectories] section. The mysterious looking double commas simply indicate that we are not asking for the file to be renamed. The number 1 tells pebuilder to make sure the file exists in the plugin folder when you close the plugins view in the pebuilder dialog, and to give an error message if does not (see more below).
files\*.ico=a,,1 tells pebuilder to copy all files with an .ico extension to the folder designated by a
files\bootimages\hdclone.iso=b,,1 tells pebuilder to copy the file named files\bootimages\hdclone.iso to the folder designated by b
The numbers here have a different meaning than they do in [WinntDirectories]
We will normally use the number 1 In this section, the numbers have the following meaning:
1 - This is used in pebuilder. When you open the plugins view and then close it, you will get an error message if a file that you assigned a 1 to here is missing. You will also get that message if you toggle the particular plugin with the missing files(s) between enabled and not enabled in the pebuilder dialog.
2 - do not decompress the file.
4 - Copy the file if it exists, but don't give an error message in the pebuilder dialog if it is missing.
8 - rename the filename to uppercase. When building an ISO image PE Builder renames the windows filenames to uppercase (required for booting from CD)
Notice that 3,5,6 and 7 are missing from the series. I believe that is because the coding in pebuilder would interpret 3 as meaning that 1 and 2 apply; 5 would mean that 1 and 4 apply; 6 that 2 and 4 apply; and 7 that 1,2 and 4 apply.
Anyway, we will normally use the number 1

Optional background information: If you look in pebuilder.inf, located in the pebuilder3110a folder, you will see that it does not use a [WinntDirectories] section. It uses numbers in the [SourceDisksFiles] instead of letters, like 2,,1. The first number indicates a particular directory path, as follows
30000 – C:\..\BartPE (yes, there could be a 30000,,1 )
1 - C:\..\BartPE\i386
2 - C:\..\BartPE\i386\System32
3 - C:\..\BartPE\i386\Config
4 – C:\..\BartPE\i386\Drivers
And so forth. For a complete listing, see Bart's pluginformat.htm page. But we don't need them.

Finally, we have
CODE
[Append]
nu2menu.xml, hdclone_nu2menu.xml
Always required. This appends the.xml file of our plugin (discussed below) to the main .xml file. Make sure that the plugin's .xml filename and the second name above are exactly the same.

So here is our entire hdclone.inf file:
CODE
; PE Builder v3 plug-in INF file for HDClone

[Version]
Signature= "$Windows NT$:;

[PEBuilder]
Name="HDClone"
Enable=1
Help="hdclone.pdf"

[WinntDirectories]
a="Programs\hdclone",2
b="Programs\hdclone\bootimages",2

[SourceDisksFiles]
files\hdclone.exe=a,,1
files\hdclone.ico=a,,1
files\readme.txt=a,,1
files\hdclone.pdf=a,,1
files\*.ico=a,,1
files\bootimages\hdclone.iso=b,,1
files\bootimages\*.img=b,,1

[Append]
nu2menu.xml, hdclone_nu2menu.xml
Save this file to the plugin folder as hdclone.inf.
Study it for a moment. Can you translate each line into an English sentence? (That's the teacher in me talking.)

Now we need to make an .xml file with the same name as in the [Append] section of the .inf file. The easiest way to get this right and avoid typos is to copy the .xml file in an existing plugin and then edit it to make it fit the current plugin.
CODE
<NU2MENU>
    <MENU ID="Programs">      
    <MITEM TYPE="ITEM" DISABLED="@Not(@FileExists(@GetProgramDrive()\Programs\hdclone\hdclone.exe))"  CMD="RUN"
FUNC="@GetProgramDrive()\Programs\hdclone\hdclone.exe">HDClone</MITEM>
    </MENU>
</NU2MENU>
Save this to the plugin folder as hdclone_nu2menu.xml

Start pebuilder and open the plugins view, then close it. If you get no error messages (remember the 1 in "a,,1?"), then select either "Burn to CD/DVD" or "Create ISO image" and press the Build button. As I mentioned in the first tutorial, I highly recommend downloading Virtual PC 2007 from Microsoft.com and installing it, and then always choosing "Create ISO image." When you run Virtual PC you simply tell it to grab BarePE.iso (or whatever you named it). You get a window on your screen that behaves in all respects like monitor display for your virtual pc. That's the best way to test new plugins, in my opinion.

Adding Registry Keys
If a program won't run properly without registry keys, then, well…you need to add those registry keys.

To identify needed registry keys you need a program like.
InstallRite – a free GUI utility that will list for you the registry keys that were added or changed by installing a program. I have found it very handy for isolating the keys needed verify licensing of the registered versions of programs that I put on my disk. I simply have it check for changes before and after entering registration data.
InstallRite will export the list of keys in Reg file format.

To convert the Reg file output to .inf format you need
ConvRegToInf – This does just what the name says. Its output will be divided into sections, such as.

[Software.AddReg]
Which contains keys from the HKey_LOCAL_MACHINE section of the registry

[Default.AddReg]
Which contains keys from the HKey_Current_User section of the registry

You can copy and paste those section headers and keys to your .inf file. But before you do, you might want to try to identify the ones you really need, especially if there are a lot of keys. This is a skill that will improve with experience. Here are a few hints;
1. I have found that keys that deal will various "MRU"s haven't been necessary
2. I tend to keep keys with "%SystemDrive%" or "SystemRoot%" in them, usually at the beginning of a pathname, for example "%SystemDrive%\HDClone\HDClone.exe". For pebuilder, "%SystermDrive%" is C:\..\BartPE, and "%SystemRoot%" is C:\..\BartPE\i386
My personal experience with registry keys is limited and that's all I've got at this time. But if people reply with additional hints that would be great.

As an example of including registry keys, here's my .inf file for MBRWizard. As I said above, I needed the keys only because I have a licensed version and I wanted to have that recognized on my disk (the keys won't work for anyone else, I made the keys much shorter by omitting data. Software piracy is not what we're about here).
CODE
; PE Builder v3 plug-in INF file for HDClone

[Version]
Signature= "$Windows NT$"

[PEBuilder]
Name="MBRWizard"
Enable=1
Help="MBRWiz3.html"

[WinntDirectories]
a="Programs\MBRWizard",2

[SourceDisksFiles]
files\*.exe=a,,1
files\*.ico=a,,1
files\fsNetter.ini=a,,1
files\MBRBoot.cfg=a,,1
files\mbrwizc.cmd=a,,1

[Append]
nu2menu.xml, MBRWizard_nu2menu.xml

[Software.AddReg]
0x2,"Sherpya\XPEinit\Programs","Diagnosis and Recovery\MBRWizard","%SystemDrive%\Programs\MBRWizard\MBRWizard.exe"

[Software.AddReg]
0x3, "Classes\CLSID\{9416F2B9-92CA-448C-B526-FFC68243D3F1}\Info","Data",\
13,64,61,76,65,65,6e,31,40,63,68,61,72,74,65,72,2e,6e,65,74,00,00,00,00,00,\
48,ef,12,00,c4,20,42,77,a8,a0,17,00,7e,88,d4,77,a8,a0,17,00,00,00,00,00,80,\
0x3, "Classes\CLSID\{9416F2B9-92CA-448C-B526-FFC68243D3F1}\Info","Data",\
13,64,61,76,65,65,6e,31,40,63,68,61,72,74,65,72,2e,6e,65,74,00,00,00,00,00,\
48,ef,12,00,c4,20,42,77,a8,a0,17,00,7e,88,d4,77,a8,a0,17,00,00,00,00,00,80,\
9a,fa,ff,07,08,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
0x3, "Microsoft\Cryptography\RNG","Seed",\
7b,9d,af,80,9e,2a,23,22,2b,b6,07,32,e0,30,d6,ec,ce,bc,42,2a,3d,44,ab,59,91,\
61,1d,b8,df,2c,7b,79,e4,8a,f6,0c,5a,b6,72,f1,45,71,0d,48,07,71,d5,39,3c,34,\
49,52,83,f6,3b,6a,8a,c4,ea,b2,2f,e3,5b,c8,03,5e,45,c4,7c,ce,d7,cf,83,5a,ee,\
72,5f,98,42,31
0x4, "Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\759E42325D2D\Usage","Status", 0x3dd57002
The Sherpya\XPEinit... key is used when you add the XPE shell to your Bart disk. That will be the subject of my 4th tutorial.

PluginBuilder3.51 – Papa TomTom's great tool for automating all of the steps above to create plugins. There is definitely a learning curve to using it. Much is posted about that in this forum so you can pursue that further. But I will say that you will have more success learning and using Pluginbuilder if you first learn the anatomy of plugins by trying the steps in this tutorial.

Recommended Apps.
If you are interested, I will mention four utilities that I would not be without. Miray Software's HDClone, which we just worked with, Roger Layton's (Firesage) MBRWizard, and MiniTool's Partition Wizard, all of which are very powerful and very current as of July 2011, and all of which offer permanent (not trial) free GUI versions. I also would not be without a GUI hex editor that allows me to view and control every byte on every drive. A good free one is HxD Hex Editor. But I bought a license for X-Ways WinHex, which is even more feature-rich and powerful. If disaster hits I can completely wipe my C: drive then restore my XP Pro installation with all 105 of my installed applications in ten minutes as if nothing happened! celebrate14.gif (I limit my c: partition to 15GB and it contains only the Windows, Program Files, and Documents and Settings directories. And I frequently run a simple xcopy based .bat file to backup files I want to keep current).

Miray Software HDClone is a simply fabulous disk/partition cloning/imaging utility. It has a very intuitive interface some innovative technology and some nice options. It comes in a bunch of flavors besides the free edition, with increasing features and increasing speed as you move up the scale. It will create bootable media versions of itself, both CD and USB

Firesage MBRWizard is what I consider to be "best in class" of the utilities that address a common and deadly data disaster recovery issue—corrupted master boot record and/or corrupted volume boot record. It's the "Operating System not found…," the "NTLR not found," etc. MBRWizard will not only likely be able to reconstruct the MBR and/or VBR, but it makes it extremely easy to save those sections as little files and to absolutely be able to restore them when needed. Firesage gives the free version away, just to be of service to the world. And what does Roger ask for a licensed version of perhaps the most vital single utility there is? $7.00. Are you kidding me? That's not much more than an egg McMuffin and a cup of coffee.

MiniTool's Partition Wizard and Easeus's Partition Manager are replacements for Symantec's very excellent but no-longer-supported Partition Magic. They're both very good at the fundamental tasks that are hard to find outside of a Windows install disk and they do much more. The have a very similar look and feel, and do the same things. The Easeus product is the number one downloaded utility at CNET downloads, but I actually like the MiniTool product better for a BartPE disk. There are only about 20 files and directories that need to be copied to the plugin. The Easeus product installs about 350 files and directories to perform the same functions. The MiniTool product also has a superior support site, which even includes videos.

Personally, I bought licensed versions of MBRWizard, HDClone and Partition Wizard because I like them so much. I hope you will consider that move too (but I am no way affiliated with any of the authors or publishers).

Next up: How to make a bootable BartPE USB device
jaclaz
Just for the record, 1st part is here:
BartPE For Beginners - Tutorial 1 of 4, Build and burn your first BartPE CD
thumbup.gif

jaclaz
dog
I think this bit got broken by the board or edit:
Signature= "$Windows NT{:content:}quot;
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.