ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/pbcdedit/pbcdedit
(Generate patch)

Comparing pbcdedit/pbcdedit (file contents):
Revision 1.9 by root, Wed Aug 14 22:54:28 2019 UTC vs.
Revision 1.27 by root, Wed Aug 14 23:56:22 2019 UTC

75sensitive data. 75sensitive data.
76 76
77=back 77=back
78 78
79The target audience for this program is professionals and tinkerers who 79The target audience for this program is professionals and tinkerers who
80are rewady to invest time into learning how it works. It is not an easy 80are ready to invest time into learning how it works. It is not an easy
81program to use and requires patience and a good understanding of BCD data 81program to use and requires patience and a good understanding of BCD
82stores. 82stores.
83 83
84 84
85=head1 SUBCOMMANDS 85=head1 SUBCOMMANDS
86 86
87PCBEDIT expects a subcommand as first argument that tells it what to 87PBCDEDIT expects a subcommand as first argument that tells it what to
88do. The following subcommands exist: 88do. The following subcommands exist:
89 89
90=over 90=over
91 91
92=item help 92=item C<help>
93 93
94Displays the whole manuale page (this document). 94Displays the whole manual page (this document).
95 95
96=item export F<path> 96=item C<export> F<path>
97 97
98Reads a BCD data store and writes a JSON representation of it to standard 98Reads a BCD data store and writes a JSON representation of it to standard
99output. 99output.
100 100
101The format of the data is explained later in this document. 101The format of the data is explained later in this document.
102 102
103Example: read a BCD store, modify it wiht an extenral program, write it again. 103Example: read a BCD store, modify it with an external program, write it
104again.
104 105
105 pbcdedit export BCD | modify-json-somehow | pbcdedit import BCD 106 pbcdedit export BCD | modify-json-somehow | pbcdedit import BCD
106 107
107=item import F<path> 108=item C<import> F<path>
108 109
109The reverse of C<export>: Reads a JSON representation of a BCD data store 110The reverse of C<export>: Reads a JSON representation of a BCD data store
110from standard input, and creates or replaces the given BCD data store. 111from standard input, and creates or replaces the given BCD data store.
111 112
112=item edit F<path> instructions... 113=item C<edit> F<path> I<instructions...>
113 114
114Load a BCD data store, apply some instructions to it, and save it again. 115Load a BCD data store, apply some instructions to it, and save it again.
115 116
116See the section L<EDITING BCD DATA STORES>, below, for more info. 117See the section L<EDITING BCD STORES>, below, for more info.
117 118
118=item parse F<path> instructions... 119=item C<parse> F<path> I<instructions...>
119 120
120Same as C<edit>, above, except it doesn't save the data store again. Can 121Same as C<edit>, above, except it doesn't save the data store again. Can
121be useful to extract some data from it. 122be useful to extract some data from it.
122 123
123=item lsblk 124=item C<lsblk>
124 125
125On a GNU/Linux system, you can get a list of partition device descriptors 126On a GNU/Linux system, you can get a list of partition device descriptors
126using this command - the external C<lsblk> command is required, as well as 127using this command - the external C<lsblk> command is required, as well as
127a mounted C</sys> file system. 128a mounted C</sys> file system.
128 129
129The output will be a list of all partitions in the system and C<partition> 130The output will be a list of all partitions in the system and C<partition>
130descriptors for GPT and both C<legacypartition> and C<partition> 131descriptors for GPT and both C<legacypartition> and C<partition>
131descritpors for MBR partitions. 132descriptors for MBR partitions.
132 133
133=item objects [--json] 134=item C<objects> [C<--json>]
134 135
135Outputs two tables: a table listing all type aliases with their hex bcd 136Outputs two tables: a table listing all type aliases with their hex BCD
136element ID, and all object name aliases with their GUID and default type 137element ID, and all object name aliases with their GUID and default type
137(if any). 138(if any).
138 139
139With C<--json> it prints similar information as a JSON object, for easier parsing. 140With C<--json> it prints similar information as a JSON object, for easier parsing.
140 141
141=item elements [--json] 142=item C<elements> [C<--json>]
142 143
143Outputs a table of known element aliases with their hex ID and the format 144Outputs a table of known element aliases with their hex ID and the format
144type. 145type.
145 146
146With C<--json> it prints similar information as a JSON object, for easier parsing. 147With C<--json> it prints similar information as a JSON object, for easier parsing.
147 148
148=item export-regf F<path> 149=item C<export-regf> F<path>
149 150
150This has nothing to do with BCD data stores - it takes a registry hive 151This has nothing to do with BCD stores - it takes a registry hive
151file as argument and outputs a JSON representation of it to standard 152file as argument and outputs a JSON representation of it to standard
152output. 153output.
153 154
154Hive versions 1.2 till 1.6 are supported. 155Hive versions 1.2 till 1.6 are supported.
155 156
156=item import-regf F<path> 157=item C<import-regf> F<path>
157 158
158The reverse of C<export-regf>: reads a JSON representation of a registry 159The reverse of C<export-regf>: reads a JSON representation of a registry
159hive from standard input and creates or replaces the registry hive file given as 160hive from standard input and creates or replaces the registry hive file
160argument. 161given as argument.
161 162
162The written hive will always be in a slightly modified version 1.3 163The written hive will always be in a slightly modified version 1.3
163format. It's not the format windows would generate, but it should be 164format. It's not the format windows would generate, but it should be
164understood by any conformant hive reader. 165understood by any conformant hive reader.
165 166
166Note that the representation chosen by PBCDEDIT currently throws away 167Note that the representation chosen by PBCDEDIT currently throws away
167clasname data (often used for feeble attemtps at hiding stuff by 168classname data (often used for feeble attempts at hiding stuff by
168Microsoft) and security descriptors, so if you write anything other than 169Microsoft) and security descriptors, so if you write anything other than
169a BCD hive you will most likely destroy it. 170a BCD hive you will most likely destroy it.
170 171
171=back 172=back
172 173
173 174
174=head1 BCD DATA STORE REPRESENTATION FORMAT 175=head1 BCD STORE REPRESENTATION FORMAT
175 176
176A BCD data store is represented as a JSON object with one special key, 177A BCD data store is represented as a JSON object with one special key,
177C<meta>, and one key per BCD object. That is, each BCD object becomes 178C<meta>, and one key per BCD object. That is, each BCD object becomes
178one key-value pair in the object, and an additional key called C<meta> 179one key-value pair in the object, and an additional key called C<meta>
179contains meta information. 180contains meta information.
242=head2 The C<meta> key 243=head2 The C<meta> key
243 244
244The C<meta> key is not stored in the BCD data store but is used only 245The C<meta> key is not stored in the BCD data store but is used only
245by PBCDEDIT. It is always generated when exporting, and importing will 246by PBCDEDIT. It is always generated when exporting, and importing will
246be refused when it exists and the version stored inside doesn't store 247be refused when it exists and the version stored inside doesn't store
247the JSON schema version of PBCDEDIT. This ensures that differemt and 248the JSON schema version of PBCDEDIT. This ensures that different and
248incompatible versions of PBCDEDIT will not read and misinterΓΌret each 249incompatible versions of PBCDEDIT will not read and misinterpret each
249others data. 250others data.
250 251
251=head2 The object keys 252=head2 The object keys
252 253
253Every other key is a BCD object. There is usually a BCD object for the 254Every other key is a BCD object. There is usually a BCD object for the
254boot manager, one for every boot option and a few others that store common 255boot manager, one for every boot option and a few others that store common
255settings inherited by these. 256settings inherited by these.
256 257
257Each BCD object is represented by a GUID wrapped in curly braces. These 258Each BCD object is represented by a GUID wrapped in curly braces. These
258are usually random GUIDs used only to distinguish bCD objects from each 259are usually random GUIDs used only to distinguish BCD objects from each
259other. When adding a new boot option, you can simply generate a new GUID. 260other. When adding a new boot option, you can simply generate a new GUID.
260 261
261Some of these GUIDs are fixed well known GUIDs which PBCDEDIT will decode 262Some of these GUIDs are fixed well known GUIDs which PBCDEDIT will decode
262into human-readable strings such as C<{globalsettings}>, which is the same 263into human-readable strings such as C<{globalsettings}>, which is the same
263as C<{7ea2e1ac-2e61-4728-aaa3-896d9d0a9f0e}>. 264as C<{7ea2e1ac-2e61-4728-aaa3-896d9d0a9f0e}>.
297get a list of all BCD elements known to PBCDEDIT by running F<pbcdedit 298get a list of all BCD elements known to PBCDEDIT by running F<pbcdedit
298elements>. 299elements>.
299 300
300What was said about duplicate keys mapping to the same object is true for 301What was said about duplicate keys mapping to the same object is true for
301elements as well, so, again, you should always use the canonical name, 302elements as well, so, again, you should always use the canonical name,
302whcih is the human radable alias, if known. 303which is the human readable alias, if known.
303 304
304=head3 BCD element types 305=head3 BCD element types
305 306
306Each BCD element has a type such as I<string> or I<boolean>. This type 307Each BCD element has a type such as I<string> or I<boolean>. This type
307determines how the value is interpreted, and most of them are pretty easy 308determines how the value is interpreted, and most of them are pretty easy
319 "description" : "Windows 10", 320 "description" : "Windows 10",
320 "systemroot" : "\\Windows", 321 "systemroot" : "\\Windows",
321 322
322=item boolean 323=item boolean
323 324
324Almost as simnple are booleans, which represent I<true>/I<false>, 325Almost as simple are booleans, which represent I<true>/I<false>,
325I<on>/I<off> and similar values. In the JSON form, true is represented 326I<on>/I<off> and similar values. In the JSON form, true is represented
326by the number C<1>, and false is represented by the number C<0>. Other 327by the number C<1>, and false is represented by the number C<0>. Other
327values will be accepted, but PBCDEDIT doesn't guarantee how these are 328values will be accepted, but PBCDEDIT doesn't guarantee how these are
328interpreted. 329interpreted.
329 330
335 336
336=item integer 337=item integer
337 338
338Again, very simple, this is a 64 bit integer. IT can be either specified 339Again, very simple, this is a 64 bit integer. IT can be either specified
339as a decimal number, as a hex number (by prefixing it with C<0x>) or as a 340as a decimal number, as a hex number (by prefixing it with C<0x>) or as a
340binatry number (prefix C<0b>). 341binary number (prefix C<0b>).
341 342
342For example, the boot C<timeout> is an integer, specifying the automatic 343For example, the boot C<timeout> is an integer, specifying the automatic
343boot delay in seconds: 344boot delay in seconds:
344 345
345 "timeout" : 30, 346 "timeout" : 30,
346 347
347=item integer list 348=item integer list
348 349
349This is a list of 64 bit integers separated by whitespace. It is not used 350This is a list of 64 bit integers separated by whitespace. It is not used
350much, so here is a somewhat artificial an untested exanmple of using 351much, so here is a somewhat artificial an untested example of using
351C<customactions> to specify a certain custom, eh, action to be executed 352C<customactions> to specify a certain custom, eh, action to be executed
352when pressing C<F10> at boot: 353when pressing C<F10> at boot:
353 354
354 "customactions" : "0x1000044000001 0x54000001", 355 "customactions" : "0x1000044000001 0x54000001",
355 356
356=item guid 357=item guid
357 358
358This represents a single GUID value wrqapped in curly braces. It is used a 359This represents a single GUID value wrapped in curly braces. It is used a
359lot to refer from one BCD object to other one. 360lot to refer from one BCD object to other one.
360 361
361For example, The C<{bootmgr}> object might refer to a resume boot option 362For example, The C<{bootmgr}> object might refer to a resume boot option
362using C<resumeobject>: 363using C<resumeobject>:
363 364
365 366
366Human readable aliases are used and allowed. 367Human readable aliases are used and allowed.
367 368
368=item guid list 369=item guid list
369 370
370Similar to te guid type, this represents a list of such GUIDs, separated 371Similar to the GUID type, this represents a list of such GUIDs, separated
371by whitespace from each other. 372by whitespace from each other.
372 373
373For example, many BCD objects can I<inherit> elements from other BCD 374For example, many BCD objects can I<inherit> elements from other BCD
374objects by specifying the GUIDs of those other objects ina GUID list 375objects by specifying the GUIDs of those other objects in a GUID list
375called surprisingly called C<inherit>: 376called surprisingly called C<inherit>:
376 377
377 "inherit" : "{dbgsettings} {emssettings} {badmemory}", 378 "inherit" : "{dbgsettings} {emssettings} {badmemory}",
378 379
379This example also shows how human readable aliases can be used. 380This example also shows how human readable aliases can be used.
388=back 389=back
389 390
390=head4 The BCD "device" element type 391=head4 The BCD "device" element type
391 392
392Device elements specify, well, devices. They are used for such diverse 393Device elements specify, well, devices. They are used for such diverse
393purposes such as finding a TFTP network boot imagem serial ports or VMBUS 394purposes such as finding a TFTP network boot image, serial ports or VMBUS
394devices, but most commonly they are used to specify the disk (harddisk, 395devices, but most commonly they are used to specify the disk (harddisk,
395cdrom ramdisk, vhd...) to boot from. 396cdrom, ramdisk, vhd...) to boot from.
396 397
397The device element is kind of a mini-language in its own which is much 398The device element is kind of a mini-language in its own which is much
398more versatile then the limited windows interface to it - BCDEDIT - 399more versatile then the limited windows interface to it - BCDEDIT -
399reveals. 400reveals.
400 401
403element, so almost everything known about it had to be researched first 404element, so almost everything known about it had to be researched first
404in the process of writing this script, and consequently, support for BCD 405in the process of writing this script, and consequently, support for BCD
405device elements is partial only. 406device elements is partial only.
406 407
407On the other hand, the expressive power of PBCDEDIT in specifying devices 408On the other hand, the expressive power of PBCDEDIT in specifying devices
408is much bigger than BCDEDIT and therefore more cna be don with it. The 409is much bigger than BCDEDIT and therefore more can be done with it. The
409downside is that BCD device elements are much more complicated than what 410downside is that BCD device elements are much more complicated than what
410you might think from reading the BCDEDIT documentation. 411you might think from reading the BCDEDIT documentation.
411 412
412In other words, simple things are complicated, and complicated things are 413In other words, simple things are complicated, and complicated things are
413possible. 414possible.
414 415
415Anyway, the general syntax of device elements is an optional GUID, 416Anyway, the general syntax of device elements is an optional GUID,
416followed by a device type, optionally followed by hexdecimal flags in 417followed by a device type, optionally followed by hexadecimal flags in
417angle brackets, optionally followed by C<=> and a comma-separated list of 418angle brackets, optionally followed by C<=> and a comma-separated list of
418arguments, some of which can be (and often are) in turn devices again. 419arguments, some of which can be (and often are) in turn devices again.
419 420
420 [{GUID}]type[<flags>][=arg,arg...] 421 [{GUID}]type[<flags>][=arg,arg...]
421 422
447The types understood and used by PBCDEDIT are as follows (keep in mind 448The types understood and used by PBCDEDIT are as follows (keep in mind
448that not of all the following is necessarily supported in PBCDEDIT): 449that not of all the following is necessarily supported in PBCDEDIT):
449 450
450=over 451=over
451 452
452=item binary=hex... 453=item C<binary=>I<hex...>
453 454
454This type isn't actually a real BCD element type, but a fallback for those 455This type isn't actually a real BCD element type, but a fallback for those
455cases where PBCDEDIT can't perfectly decode a device element (except for 456cases where PBCDEDIT can't perfectly decode a device element (except for
456the leading GUID, which it can always decode). In such cases, it will 457the leading GUID, which it can always decode). In such cases, it will
457convert the device into this type with a hexdump of the element data. 458convert the device into this type with a hexdump of the element data.
458 459
459=item null 460=item C<null>
460 461
461This is another special type - sometimes, a device all zero-filled, which 462This is another special type - sometimes, a device all zero-filled, which
462is not valid. This can mark the absence of a device or something PBCDEDIT 463is not valid. This can mark the absence of a device or something PBCDEDIT
463does not understand, so it decodes it into this special "all zero" type 464does not understand, so it decodes it into this special "all zero" type
464called C<null>. 465called C<null>.
465 466
466It's most commonly found in devices that can use an optional parent 467It's most commonly found in devices that can use an optional parent
467device, when no parent device is used. 468device, when no parent device is used.
468 469
469=item boot 470=item C<boot>
470 471
471Another type without parameters, this refers to the device that was booted 472Another type without parameters, this refers to the device that was booted
472from (nowadays typically the EFI system partition). 473from (nowadays typically the EFI system partition).
473 474
474=item vmbus=interfacetype,interfaceinstance 475=item C<vmbus=>I<interfacetype>,I<interfaceinstance>
475 476
476This specifies a VMBUS device with the given interface type and interface 477This specifies a VMBUS device with the given interface type and interface
477instance, both of which are "naked" (no curly braces) GUIDs. 478instance, both of which are "naked" (no curly braces) GUIDs.
478 479
479Made-up example (couldn't find a single example on the web): 480Made-up example (couldn't find a single example on the web):
480 481
481 vmbus=c376c1c3-d276-48d2-90a9-c04748072c60,12345678-a234-b234-c234-d2345678abcd 482 vmbus=c376c1c3-d276-48d2-90a9-c04748072c60,12345678-a234-b234-c234-d2345678abcd
482 483
483=item partition=<parent>,devicetype,partitiontype,diskid,partitionid 484=item C<partition=><I<parent>>,I<devicetype>,I<partitiontype>,I<diskid>,I<partitionid>
484 485
485This designates a specific partition on a block device. C<< <parent> 486This designates a specific partition on a block device. I<parent> is an
486>> is an optional parent device on which to search on, and is often 487optional parent device on which to search on, and is often C<null>. Note
487C<null>. Note that the anfgle brackets are part of the syntax. 488that the angle brackets around I<parent> are part of the syntax.
488 489
489C<devicetypes> is one of C<harddisk>, C<floppy>, C<cdrom>, C<ramdisk>, 490I<devicetypes> is one of C<harddisk>, C<floppy>, C<cdrom>, C<ramdisk>,
490C<file> or C<vhd>, where the first three should be self-explaining, 491C<file> or C<vhd>, where the first three should be self-explaining,
491C<file> is usually used to locate a device by finding a magic file, and 492C<file> is usually used to locate a file to be used as a disk image,
492C<vhd> is used for virtual harddisks - F<.vhd> and F<-vhdx> files. 493and C<vhd> is used to treat files as virtual harddisks, i.e. F<vhd> and
494F<vhdx> files.
493 495
494The C<partitiontype> is either C<mbr>, C<gpt> or C<raw>, the latter being 496The I<partitiontype> is either C<mbr>, C<gpt> or C<raw>, the latter being
495used for devices without partitions, such as cdroms, where the "partition" 497used for devices without partitions, such as cdroms, where the "partition"
496is usually the whole device. 498is usually the whole device.
497 499
498The C<diskid> identifies the disk or device using a unique signature, and 500The I<diskid> identifies the disk or device using a unique signature, and
499the same is true for the C<partitionid>. How these are interpreted depends 501the same is true for the I<partitionid>. How these are interpreted depends
500on the C<partitiontype>: 502on the I<partitiontype>:
501 503
502=over 504=over
503 505
504=item mbr 506=item C<mbr>
505 507
506The C<diskid> is the 32 bit disk signature stored at offset 0x1b8 in the 508The C<diskid> is the 32 bit disk signature stored at offset 0x1b8 in the
507MBR, interpreted as a 32 bit unsigned little endian integer and written as 509MBR, interpreted as a 32 bit unsigned little endian integer and written as
508hex number. That is, the bytes C<01 02 03 04> would become C<04030201>. 510hex number. That is, the bytes C<01 02 03 04> would become C<04030201>.
509 511
510Diskpart (using the C<DETAIL> command) and the C<lsblk> comamnd typically 512Diskpart (using the C<DETAIL> command) and the C<lsblk> command typically
511found on GNU/Linux systems (using e.g. C<lsblk -o NAME,PARTUUID>) can 513found on GNU/Linux systems (using e.g. C<lsblk -o NAME,PARTUUID>) can
512display the disk id. 514display the I<diskid>.
513 515
514The C<partitionid> is the byte offset(!) of the partition counting from 516The I<partitionid> is the byte offset(!) of the partition counting from
515the beginning of the MBR. 517the beginning of the MBR.
516 518
517Example, use the partition on the harddisk with C<diskid> C<47cbc08a> 519Example, use the partition on the harddisk with I<diskid> C<47cbc08a>
518starting at sector C<2048> (= 1048576 / 512). 520starting at sector C<2048> (= 1048576 / 512).
519 521
520 partition=<null>,harddisk,mbr,47cbc08a,1048576 522 partition=<null>,harddisk,mbr,47cbc08a,1048576
521 523
522=item gpt 524=item C<gpt>
523 525
524The C<diskid> is the disk UUID/disk identifier GUID from the partition 526The I<diskid> is the disk GUID/disk identifier GUID from the partition
525table (as displayed e.g. by C<gdisk>), and the C<partitionid> is the 527table (as displayed e.g. by F<gdisk>), and the I<partitionid> is the
526partition unique GUID (displayed using e.g. the C<gdisk> C<i> command). 528partition unique GUID (displayed using e.g. the F<gdisk> F<i> command).
527 529
528Example: use the partition C<76d39e5f-ad1b-407e-9c05-c81eb83b57dd> on GPT 530Example: use the partition C<76d39e5f-ad1b-407e-9c05-c81eb83b57dd> on GPT
529disk C<9742e468-9206-48a0-b4e4-c4e9745a356a>. 531disk C<9742e468-9206-48a0-b4e4-c4e9745a356a>.
530 532
531 partition=<null>,harddisk,gpt,9742e468-9206-48a0-b4e4-c4e9745a356a,76d39e5f-ad1b-407e-9c05-c81eb83b57dd 533 partition=<null>,harddisk,gpt,9742e468-9206-48a0-b4e4-c4e9745a356a,76d39e5f-ad1b-407e-9c05-c81eb83b57dd
532 534
533=item raw 535=item C<raw>
534 536
535Instead of diskid and partitionid, this type only accepts a decimal disk 537Instead of I<diskid> and I<partitionid>, this type only accepts a decimal
536number and signifies the whole disk. BCDEDIT cannot display the resulting 538disk number and signifies the whole disk. BCDEDIT cannot display the
537device, and I am doubtful whether it has a useful effect. 539resulting device, and I am doubtful whether it has a useful effect.
538 540
539=back 541=back
540 542
541=item legacypartition=<parent>,devicetype,partitiontype,diskid,partitionid 543=item C<legacypartition=><I<parent>>,I<devicetype>,I<partitiontype>,I<diskid>,I<partitionid>
542 544
543This is exactly the same as the C<partition> type, except for a tiny 545This is exactly the same as the C<partition> type, except for a tiny
544detail: instead of using the partition start offset, this type uses the 546detail: instead of using the partition start offset, this type uses the
545partition number for MBR disks. Behaviour other partition types should be 547partition number for MBR disks. Behaviour other partition types should be
546the same. 548the same.
547 549
548The partition number starts at C<1> and skips unused partition, so if 550The partition number starts at C<1> and skips unused partition, so if
549there are two primary partitions and another partition inside the extended 551there are two primary partitions and another partition inside the extended
550partition, the primary partitions are number C<1> and C<2> and the 552partition, the primary partitions are number C<1> and C<2> and the
551partition inside the extended partition is number C<3>, rwegardless of any 553partition inside the extended partition is number C<3>, regardless of any
552gaps. 554gaps.
553 555
554=item locate=<parent>,locatetype,locatearg 556=item C<locate=><I<parent>>,I<locatetype>,I<locatearg>
555 557
556This device description will make the bootloader search for a partition 558This device description will make the bootloader search for a partition
557with a given path. 559with a given path.
558 560
559The C<< <parent> >> device is the device to search on (angle brackets are 561The I<parent> device is the device to search on (angle brackets are
560still part of the syntax!) If it is C<< <null> >>, then C<locate> will 562still part of the syntax!) If it is C<null>, then C<locate> will
561search all disks it can find. 563search all disks it can find.
562 564
563C<locatetype> is either C<element> or C<path>, and merely distinguishes 565I<locatetype> is either C<element> or C<path>, and merely distinguishes
564between two different ways to specify the path to search for: C<element> 566between two different ways to specify the path to search for: C<element>
565uses an element ID (either as hex or as name) as C<locatearg> and C<path> 567uses an element ID (either as hex or as name) as I<locatearg> and C<path>
566uses a relative path as C<locatearg>. 568uses a relative path as I<locatearg>.
567 569
568Example: find any partition which has the C<magicfile.xxx> path in the 570Example: find any partition which has the F<magicfile.xxx> path in the
569root. 571root.
570 572
571 locate=<null>,path,\magicfile.xxx 573 locate=<null>,path,\magicfile.xxx
572 574
573Example: find any partition which has the path specified in the 575Example: find any partition which has the path specified in the
574C<systemroot> element (typically C<\Windows>). 576C<systemroot> element (typically F<\Windows>).
575 577
576 locate=<null>,element,systemroot 578 locate=<null>,element,systemroot
577 579
578=item block=devicetype,args... 580=item C<block=>I<devicetype>,I<args...>
579 581
580Last not least, the most complex type, C<block>, which... specifies block 582Last not least, the most complex type, C<block>, which... specifies block
581devices (which could be inside a F<vhdx> file for example). 583devices (which could be inside a F<vhdx> file for example).
582 584
583C<devicetypes> is one of C<harddisk>, C<floppy>, C<cdrom>, C<ramdisk>, 585I<devicetypes> is one of C<harddisk>, C<floppy>, C<cdrom>, C<ramdisk>,
584C<file> or C<vhd> - the same as for C<partiion=>. 586C<file> or C<vhd> - the same as for C<partiion=>.
585 587
586The remaining arguments change depending on the C<devicetype>: 588The remaining arguments change depending on the I<devicetype>:
587 589
588=over 590=over
589 591
590=item block=file,<parent>,path 592=item C<block=file>,<I<parent>>,I<path>
591 593
592Interprets the C<< <parent> >> device (typically a partition) as a 594Interprets the I<parent> device (typically a partition) as a
593filesystem and specifies a file path inside. 595filesystem and specifies a file path inside.
594 596
595=item block=vhd,<parent> 597=item C<block=vhd>,<I<parent>>
596 598
597Pretty much just changes the interpretation of C<< <parent> >>, which is 599Pretty much just changes the interpretation of I<parent>, which is
598usually a disk image (C<block=file,...)>) to be a F<vhd> or F<vhdx> file. 600usually a disk image (C<block=file,...)>) to be a F<vhd> or F<vhdx> file.
599 601
600=item block=ramdisk,<parent>,base,size,offset,path 602=item C<block=ramdisk>,<I<parent>>,I<base>,I<size>,I<offset>,I<path>
601 603
602Interprets the C<< <parent> >> device as RAM disk, using the (decimal) 604Interprets the I<parent> device as RAM disk, using the (decimal)
603base address, byte size and byte offset inside a file specified by 605base address, byte size and byte offset inside a file specified by
604C<path>. The numbers are usually all C<0> because they cna be extracted 606I<path>. The numbers are usually all C<0> because they can be extracted
605from the RAM disk image or other parameters. 607from the RAM disk image or other parameters.
606 608
607This is most commonly used to boot C<wim> images. 609This is most commonly used to boot C<wim> images.
608 610
609=item block=floppy,drivenum 611=item C<block=floppy>,I<drivenum>
610 612
611Refers to a removable drive identified by a number. BCDEDIT cannot display 613Refers to a removable drive identified by a number. BCDEDIT cannot display
612the resultinfg device, and it is not clear what effect it will have. 614the resulting device, and it is not clear what effect it will have.
613 615
614=item block=cdrom,drivenum 616=item C<block=cdrom>,I<drivenum>
615 617
616Pretty much the same as C<floppy> but for CD-ROMs. 618Pretty much the same as C<floppy> but for CD-ROMs.
617 619
618=item anything else 620=item anything else
619 621
623 625
624=back5 Examples 626=back5 Examples
625 627
626This concludes the syntax overview for device elements, but probably 628This concludes the syntax overview for device elements, but probably
627leaves many questions open. I can't help with most of them, as I also ave 629leaves many questions open. I can't help with most of them, as I also ave
628many questions, but I can walk you through some actual examples using mroe 630many questions, but I can walk you through some actual examples using more
629complex aspects. 631complex aspects.
630 632
631=item locate=<block=vhd,<block=file,<locate=<null>,path,\disk.vhdx>,\disk.vhdx>>,element,path 633=item C<< locate=<block=vhd,<block=file,<locate=<null>,path,\disk.vhdx>,\disk.vhdx>>,element,path >>
632 634
633Just like with C declarations, you best treat device descriptors as 635Just like with C declarations, you best treat device descriptors as
634instructions to find your device and work your way from the inside out: 636instructions to find your device and work your way from the inside out:
635 637
636 locate=<null>,path,\disk.vhdx 638 locate=<null>,path,\disk.vhdx
643Next, this takes the device locate has found and finds a file called 645Next, this takes the device locate has found and finds a file called
644F<\disk.vhdx> on it. This is the same file locate was using, but that is 646F<\disk.vhdx> on it. This is the same file locate was using, but that is
645only because we find the device using the same path as finding the disk 647only because we find the device using the same path as finding the disk
646image, so this is purely incidental, although quite common. 648image, so this is purely incidental, although quite common.
647 649
648Bext, this file will be opened as a virtual disk: 650Next, this file will be opened as a virtual disk:
649 651
650 block=vhd,<see above> 652 block=vhd,<see above>
651 653
652And finally, inside this disk, another C<locate> will look for a partition 654And finally, inside this disk, another C<locate> will look for a partition
653with a path as specified in the C<path> element, which most likely will be 655with a path as specified in the C<path> element, which most likely will be
656 locate=<see above>,element,path 658 locate=<see above>,element,path
657 659
658As a result, this will boot the first Windows it finds on the first 660As a result, this will boot the first Windows it finds on the first
659F<disk.vhdx> disk image it can find anywhere. 661F<disk.vhdx> disk image it can find anywhere.
660 662
661=item locate=<block=vhd,<block=file,<partition=<null>,harddisk,mbr,47cbc08a,242643632128>,\win10.vhdx>>,element,path 663=item C<< locate=<block=vhd,<block=file,<partition=<null>,harddisk,mbr,47cbc08a,242643632128>,\win10.vhdx>>,element,path >>
662 664
663Pretty much the same as the previous case, but witzh a bit of variance. First, look for a specific partition on 665Pretty much the same as the previous case, but with a bit of
664an MBR-partitioned disk: 666variance. First, look for a specific partition on an MBR-partitioned disk:
665 667
666 partition=<null>,harddisk,mbr,47cbc08a,242643632128 668 partition=<null>,harddisk,mbr,47cbc08a,242643632128
667 669
668Then open the file F<\win10.vhdx> on that partition: 670Then open the file F<\win10.vhdx> on that partition:
669 671
675 677
676And again the windows loader (or whatever is in C<path>) will be searched: 678And again the windows loader (or whatever is in C<path>) will be searched:
677 679
678 locate=<see above>,element,path 680 locate=<see above>,element,path
679 681
680=item {b097d2b2-bc00-11e9-8a9a-525400123456}block<1>=ramdisk,<partition=<null>,harddisk,mbr,47cbc08a,242643632128>,0,0,0,\boot.wim 682=item C<< {b097d2b2-bc00-11e9-8a9a-525400123456}block<1>=ramdisk,<partition=<null>,harddisk,mbr,47cbc08a,242643632128>,0,0,0,\boot.wim >>
681 683
682This is quite different. First, it starts with a GUID. This GUID belongs 684This is quite different. First, it starts with a GUID. This GUID belongs
683to a BCD object of type C<device>, which has additional parameters: 685to a BCD object of type C<device>, which has additional parameters:
684 686
685 "{b097d2b2-bc00-11e9-8a9a-525400123456}" : { 687 "{b097d2b2-bc00-11e9-8a9a-525400123456}" : {
688 "ramdisksdidevice" : "partition=<null>,harddisk,mbr,47cbc08a,1048576", 690 "ramdisksdidevice" : "partition=<null>,harddisk,mbr,47cbc08a,1048576",
689 "ramdisksdipath" : "\boot.sdi" 691 "ramdisksdipath" : "\boot.sdi"
690 }, 692 },
691 693
692I will not go into many details, but this specifies a (presumably empty) 694I will not go into many details, but this specifies a (presumably empty)
693template ramdisk image (F<\boot.sdi>) that is used to initiaolize the 695template ramdisk image (F<\boot.sdi>) that is used to initialize the
694ramdisk. The F<\boot.wim> file is then extracted into it. As you cna also 696ramdisk. The F<\boot.wim> file is then extracted into it. As you can also
695see, this F<.sdi> file resides on a different C<partition>. 697see, this F<.sdi> file resides on a different C<partition>.
696 698
697Continuitn, as always, form the inside out, first this device descriptor 699Continuing, as always, from the inside out, first this device descriptor
698finds a specific partition: 700finds a specific partition:
699 701
700 partition=<null>,harddisk,mbr,47cbc08a,242643632128 702 partition=<null>,harddisk,mbr,47cbc08a,242643632128
701 703
702And then specifies a C<ramdisk> image on this partition: 704And then specifies a C<ramdisk> image on this partition:
707seems to be always there on this kind of entry. 709seems to be always there on this kind of entry.
708 710
709If you have some good examples to add here, feel free to mail me. 711If you have some good examples to add here, feel free to mail me.
710 712
711 713
712=head1 EDITING BCD DATA STORES 714=head1 EDITING BCD STORES
713 715
714The C<edit> and C<parse> subcommands allow you to read a BCD data store 716The C<edit> and C<parse> subcommands allow you to read a BCD data store
715and modify it or extract data from it. This is done by exyecuting a series 717and modify it or extract data from it. This is done by executing a series
716of "editing instructions" which are explained here. 718of "editing instructions" which are explained here.
717 719
718=over 720=over
719 721
720=item get I<object> I<element> 722=item C<get> I<object> I<element>
721 723
722Reads the BCD element I<element> from the BCD object I<object> and writes 724Reads the BCD element I<element> from the BCD object I<object> and writes
723it to standard output, followed by a newline. The I<object> can be a GUID 725it to standard output, followed by a newline. The I<object> can be a GUID
724or a human-readable alias, or the special string C<{default}>, which will 726or a human-readable alias, or the special string C<{default}>, which will
725refer to the default BCD object. 727refer to the default BCD object.
726 728
727Example: find description of the default BCD object. 729Example: find description of the default BCD object.
728 730
729 pbcdedit parse BCD get "{default}" description 731 pbcdedit parse BCD get "{default}" description
730 732
731=item set I<object> I<element> I<value> 733=item C<set> I<object> I<element> I<value>
732 734
733Similar to C<get>, but sets the element to the given I<value> instead. 735Similar to C<get>, but sets the element to the given I<value> instead.
734 736
735Example: change bootmgr default too 737Example: change the bootmgr default too
736C<{b097d2ad-bc00-11e9-8a9a-525400123456}>: 738C<{b097d2ad-bc00-11e9-8a9a-525400123456}>:
737 739
738 pbcdedit edit BCD set "{bootmgr}" resumeobject "{b097d2ad-bc00-11e9-8a9a-525400123456}" 740 pbcdedit edit BCD set "{bootmgr}" resumeobject "{b097d2ad-bc00-11e9-8a9a-525400123456}"
739 741
740=item eval I<perlcode> 742=item C<eval> I<perlcode>
741 743
742This takes the next argument, interprets it as Perl code and 744This takes the next argument, interprets it as Perl code and
743evaluates it. This allows you to do more complicated modifications or 745evaluates it. This allows you to do more complicated modifications or
744extractions. 746extractions.
745 747
764The example given for C<get>, above, could be expressed like this with 766The example given for C<get>, above, could be expressed like this with
765C<eval>: 767C<eval>:
766 768
767 pbcdedit edit BCD eval 'say $BCD->{$DEFAULT}{description}' 769 pbcdedit edit BCD eval 'say $BCD->{$DEFAULT}{description}'
768 770
769The example given for C<set> could be expresed like this: 771The example given for C<set> could be expressed like this:
770 772
771 pbcdedit edit BCD eval '$BCD->{$DEFAULT}{resumeobject} = "{b097d2ad-bc00-11e9-8a9a-525400123456}"' 773 pbcdedit edit BCD eval '$BCD->{$DEFAULT}{resumeobject} = "{b097d2ad-bc00-11e9-8a9a-525400123456}"'
772 774
773=item do I<path> 775=item C<do> I<path>
774 776
775Similar to C<eval>, above, but instead of using the argument as perl code, 777Similar to C<eval>, above, but instead of using the argument as perl code,
776it loads the perl code from the given file and executes it. This makes it 778it loads the perl code from the given file and executes it. This makes it
777easier to write more complicated or larger programs. 779easier to write more complicated or larger programs.
778 780
779=back 781=back
780 782
783
781=head1 SEE ALSO 784=head1 SEE ALSO
782 785
783For ideas on what you can do, and some introductory material, try 786For ideas on what you can do with BCD stores in
787general, and some introductory material, try
784L<http://www.mistyprojects.co.uk/documents/BCDEdit/index.html>. 788L<http://www.mistyprojects.co.uk/documents/BCDEdit/index.html>.
785 789
786For good reference on BCD objects and elements, see Geoff Chappels pages 790For good reference on which BCD objects and
791elements exist, see Geoff Chappell's pages at
787at L<http://www.geoffchappell.com/notes/windows/boot/bcd/index.htm>. 792L<http://www.geoffchappell.com/notes/windows/boot/bcd/index.htm>.
788 793
789=head1 AUTHOR 794=head1 AUTHOR
790 795
791Written by Marc A. Lehmann <pbcdedit@schmorp.de>. 796Written by Marc A. Lehmann L<pbcdedit@schmorp.de>.
792 797
793=head1 REPORTING BUGS 798=head1 REPORTING BUGS
794 799
795Bugs can be reported dorectly tt he author at L<pcbedit@schmorp.de>. 800Bugs can be reported directly the author at L<pcbedit@schmorp.de>.
796 801
797=head1 BUGS AND SHORTCOMINGS 802=head1 BUGS AND SHORTCOMINGS
798 803
799This should be a module. Of a series of modules, even. 804This should be a module. Of a series of modules, even.
800 805
801Registry code should preserve classname and security descriptor data, and 806Registry code should preserve classname and security descriptor data, and
802whatever else is necessary to read and write any registry hive file. 807whatever else is necessary to read and write any registry hive file.
803 808
804I am also not happy with device descriptors being strings rather than a 809I am also not happy with device descriptors being strings rather than a
805data structure, but strings are probably better for command line usage. In 810data structure, but strings are probably better for command line usage. In
806any case,. device descriptors could be converted by simply "splitting" at 811any case, device descriptors could be converted by simply "splitting" at
807"=" and "," into an array reference, recursively. 812"=" and "," into an array reference, recursively.
808 813
809=head1 HOMEPAGE 814=head1 HOMEPAGE
810 815
811Original versions of this program can be found at 816Original versions of this program can be found at
2269 2274
2270 if ($insn eq "get") { 2275 if ($insn eq "get") {
2271 my $object = shift @insns; 2276 my $object = shift @insns;
2272 my $elem = shift @insns; 2277 my $elem = shift @insns;
2273 2278
2274 $object = $default if $object eq "{default}"; 2279 $object = $object eq "{default}" ? $default : dec_wguid enc_wguid $object;
2275 2280
2276 print $bcd->{$object}{$elem}, "\n"; 2281 print $bcd->{$object}{$elem}, "\n";
2277 2282
2278 } elsif ($insn eq "set") { 2283 } elsif ($insn eq "set") {
2279 my $object = shift @insns; 2284 my $object = shift @insns;
2280 my $elem = shift @insns; 2285 my $elem = shift @insns;
2281 my $value = shift @insns; 2286 my $value = shift @insns;
2282 2287
2283 $object = $default if $object eq "{default}"; 2288 $object = $object eq "{default}" ? $default : dec_wguid enc_wguid $object;
2284 2289
2285 $bcd->{$object}{$elem} = $value; 2290 $bcd->{$object}{$elem} = $value;
2286 2291
2287 } elsif ($insn eq "eval") { 2292 } elsif ($insn eq "eval") {
2288 bcd_edit_eval shift @insns; 2293 bcd_edit_eval shift @insns;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines