people/sha0/winvblock.git
11 years ago[bus] Make callers of bus__add_child responsible...
Shao Miller [Thu, 9 Dec 2010 21:58:40 +0000 (16:58 -0500)]
[bus] Make callers of bus__add_child responsible...

...for freeing their device if bus__add_child() fails.
This is better than bus__add_child() freeing it, for the sake
of consistency in the code.  I accidentally re-freed not
once, but twice, while trying some things out.

11 years ago[wv_stdlib] Use appropriate pool tags
Shao Miller [Thu, 9 Dec 2010 21:26:39 +0000 (16:26 -0500)]
[wv_stdlib] Use appropriate pool tags

For AoE:
"WinAoE" with tag 'EoAW'.

For WinVBlock:
"WinVBlock" with tag 'klBV'.

11 years ago[bus,bus/pnp,disk/pnp] Don't use LowerDeviceObject if NULL
Shao Miller [Thu, 9 Dec 2010 20:56:47 +0000 (15:56 -0500)]
[bus,bus/pnp,disk/pnp] Don't use LowerDeviceObject if NULL

A bus might not be an FDO on top of some other PDO, so we should
only call a bus' "LowerDeviceObject" if it exists.

11 years ago[bus] Add do-nothing bus__init_ function
Shao Miller [Thu, 9 Dec 2010 16:58:09 +0000 (11:58 -0500)]
[bus] Add do-nothing bus__init_ function

In order to have a sub-bus as a node on a bus, we need to
implement a device__type::init function, since bus__add_child()
will call it on a child device.

11 years ago[device] Remove device__init_decl macro
Shao Miller [Thu, 9 Dec 2010 16:43:11 +0000 (11:43 -0500)]
[device] Remove device__init_decl macro

Use device__init_func typedef, instead.

11 years ago[driver,bus] Move the "boot bus" into the driver module
Shao Miller [Thu, 9 Dec 2010 06:53:44 +0000 (01:53 -0500)]
[driver,bus] Move the "boot bus" into the driver module

It's now called driver__bus_fdo_ and is accessible via
driver__bus().  This involved some code shuffling.

Additionally, bus__create_pdo_() has been modified to
actually produce a vanilla bus PDO without hard-coding
the "boot bus" logic into it.

We also adjust bus__module_init() to move the "boot bus"
code out.

This effort is towards modules/drivers creating their
own bus.

11 years ago[device] Use typedef for device__create_pdo_func
Shao Miller [Thu, 9 Dec 2010 04:48:23 +0000 (23:48 -0500)]
[device] Use typedef for device__create_pdo_func

Instead of the device__create_pdo_decl() macro and
device__create_pdo_routine function pointer typedef.

11 years ago[driver] Rename driver_dispatch to driver__dispatch_
Shao Miller [Wed, 8 Dec 2010 21:42:06 +0000 (16:42 -0500)]
[driver] Rename driver_dispatch to driver__dispatch_

11 years ago[driver] Rename driver_dispatch_not_supported to driver__dispatch_not_supported_
Shao Miller [Wed, 8 Dec 2010 21:41:06 +0000 (16:41 -0500)]
[driver] Rename driver_dispatch_not_supported to driver__dispatch_not_supported_

11 years ago[driver] Rename os_load_opts to driver__os_load_opts_
Shao Miller [Wed, 8 Dec 2010 21:17:44 +0000 (16:17 -0500)]
[driver] Rename os_load_opts to driver__os_load_opts_

11 years ago[driver] Rename Driver_Globals_Started to driver__started_
Shao Miller [Wed, 8 Dec 2010 21:13:15 +0000 (16:13 -0500)]
[driver] Rename Driver_Globals_Started to driver__started_

11 years ago[driver] Rename Driver_Globals_StateHandle to driver__state_handle_
Shao Miller [Wed, 8 Dec 2010 21:12:16 +0000 (16:12 -0500)]
[driver] Rename Driver_Globals_StateHandle to driver__state_handle_

11 years ago[driver] Rename Driver_Unload to driver__unload_
Shao Miller [Wed, 8 Dec 2010 21:11:01 +0000 (16:11 -0500)]
[driver] Rename Driver_Unload to driver__unload_

11 years ago[device] Correct the return type for device__set
Shao Miller [Wed, 8 Dec 2010 21:06:44 +0000 (16:06 -0500)]
[device] Correct the return type for device__set

11 years ago[driver] Minor style/cosmetic changes
Shao Miller [Wed, 8 Dec 2010 21:04:23 +0000 (16:04 -0500)]
[driver] Minor style/cosmetic changes

Undoing all of the hard work that indent.sh did. *sigh*

11 years ago[bus] Track boot__module_up_ as TRUE a bit earlier
Shao Miller [Wed, 8 Dec 2010 19:44:50 +0000 (14:44 -0500)]
[bus] Track boot__module_up_ as TRUE a bit earlier

We obviously have to track 'bus__module_up_' as 'TRUE'
_before_ the call to bus__create().  Oops.

11 years ago[bus] Require module initialization for bus__create
Shao Miller [Wed, 8 Dec 2010 18:44:26 +0000 (13:44 -0500)]
[bus] Require module initialization for bus__create

Just like the previous commit regarding bus__add_child().

11 years ago[bus] Track if the bus module has been initialized
Shao Miller [Wed, 8 Dec 2010 18:23:06 +0000 (13:23 -0500)]
[bus] Track if the bus module has been initialized

Since bus__add_child() is a library function, we don't really
want a caller using it unless the WinVBlock driver is
actually running.  We now track module initialization status.

11 years ago[bus] Rename bus__finalize to bus__module_shutdown
Shao Miller [Wed, 8 Dec 2010 18:10:12 +0000 (13:10 -0500)]
[bus] Rename bus__finalize to bus__module_shutdown

11 years ago[bus] Rename bus__init to bus__module_init
Shao Miller [Wed, 8 Dec 2010 17:52:43 +0000 (12:52 -0500)]
[bus] Rename bus__init to bus__module_init

Because 'bus__init' seems more like something you'd
do to a particular bus instance.

11 years ago[bus] Rename Bus_GetDeviceCapabilities to bus__get_dev_capabilities
Shao Miller [Wed, 8 Dec 2010 17:43:44 +0000 (12:43 -0500)]
[bus] Rename Bus_GetDeviceCapabilities to bus__get_dev_capabilities

11 years ago[bus] Don't use winvblock__def_struct for bus__type
Shao Miller [Wed, 8 Dec 2010 17:38:46 +0000 (12:38 -0500)]
[bus] Don't use winvblock__def_struct for bus__type

11 years ago[bus] Rename create_pdo to bus__create_pdo_
Shao Miller [Wed, 8 Dec 2010 17:17:59 +0000 (12:17 -0500)]
[bus] Rename create_pdo to bus__create_pdo_

11 years ago[bus] Rename free_bus to bus__free_
Shao Miller [Wed, 8 Dec 2010 17:15:56 +0000 (12:15 -0500)]
[bus] Rename free_bus to bus__free_

11 years ago[bus] Rename bus_list to bus__list_
Shao Miller [Wed, 8 Dec 2010 17:15:07 +0000 (12:15 -0500)]
[bus] Rename bus_list to bus__list_

11 years ago[bus] Rename bus_list_lock to bus__list_lock_
Shao Miller [Wed, 8 Dec 2010 17:14:23 +0000 (12:14 -0500)]
[bus] Rename bus_list_lock to bus__list_lock_

11 years ago[bus] Rename boot_bus_fdo to bus__boot_fdo_
Shao Miller [Wed, 8 Dec 2010 17:13:22 +0000 (12:13 -0500)]
[bus] Rename boot_bus_fdo to bus__boot_fdo_

11 years ago[bus] Minor style/cosmetic changes
Shao Miller [Wed, 8 Dec 2010 16:02:23 +0000 (11:02 -0500)]
[bus] Minor style/cosmetic changes

Undoing all of the hard work that indent.sh did. *sigh*

11 years ago[device] Introduce device__set function
Shao Miller [Wed, 8 Dec 2010 14:52:33 +0000 (09:52 -0500)]
[device] Introduce device__set function

Use this new device__set() to set a 'device' pointer for
a 'DEVICE_OBJECT'.

11 years ago[bus] Rename bus__get_ptr to bus__get
Shao Miller [Wed, 8 Dec 2010 14:29:46 +0000 (09:29 -0500)]
[bus] Rename bus__get_ptr to bus__get

And use a function instead of a macro.

11 years ago[device] Introduce device__get function
Shao Miller [Wed, 8 Dec 2010 07:06:43 +0000 (02:06 -0500)]
[device] Introduce device__get function

Use this new device__get() to get a 'device' pointer from
a 'PDEVICE_OBJECT' instead of the old casting.  We still
need to change the casting used when _setting_ it, though.

11 years ago[aoe] Rename get_aoe_disk_ptr to aoe__get_
Shao Miller [Wed, 8 Dec 2010 06:15:36 +0000 (01:15 -0500)]
[aoe] Rename get_aoe_disk_ptr to aoe__get_

11 years ago[aoe] Rename aoe_disk_list to aoe__disk_list_
Shao Miller [Wed, 8 Dec 2010 05:46:38 +0000 (00:46 -0500)]
[aoe] Rename aoe_disk_list to aoe__disk_list_

11 years ago[aoe] Rename aoe_disk_list_lock to aoe__disk_list_lock_
Shao Miller [Wed, 8 Dec 2010 05:45:55 +0000 (00:45 -0500)]
[aoe] Rename aoe_disk_list_lock to aoe__disk_list_lock_

11 years ago[aoe] Rename AoE_Globals_Started to aoe__started_
Shao Miller [Wed, 8 Dec 2010 05:44:44 +0000 (00:44 -0500)]
[aoe] Rename AoE_Globals_Started to aoe__started_

11 years ago[aoe] Rename AoE_Globals_ThreadHandle to aoe__thread_handle_
Shao Miller [Wed, 8 Dec 2010 05:43:41 +0000 (00:43 -0500)]
[aoe] Rename AoE_Globals_ThreadHandle to aoe__thread_handle_

11 years ago[aoe] Rename AoE_Globals_OutstandingTags to aoe__outstanding_tags_
Shao Miller [Wed, 8 Dec 2010 05:42:47 +0000 (00:42 -0500)]
[aoe] Rename AoE_Globals_OutstandingTags to aoe__outstanding_tags_

11 years ago[aoe] Rename AoE_Globals_DiskSearchList to aoe__disk_search_list_
Shao Miller [Wed, 8 Dec 2010 05:41:56 +0000 (00:41 -0500)]
[aoe] Rename AoE_Globals_DiskSearchList to aoe__disk_search_list_

11 years ago[aoe] Rename AoE_Globals_ProbeTag to aoe__probe_tag_
Shao Miller [Wed, 8 Dec 2010 05:40:56 +0000 (00:40 -0500)]
[aoe] Rename AoE_Globals_ProbeTag to aoe__probe_tag_

11 years ago[aoe] Rename AoE_Globals_TagList to aoe__tag_list_
Shao Miller [Wed, 8 Dec 2010 05:40:01 +0000 (00:40 -0500)]
[aoe] Rename AoE_Globals_TagList to aoe__tag_list_

11 years ago[aoe] Rename AoE_Globals_TagListLast to aoe__tag_list_last_
Shao Miller [Wed, 8 Dec 2010 05:39:00 +0000 (00:39 -0500)]
[aoe] Rename AoE_Globals_TagListLast to aoe__tag_list_last_

11 years ago[aoe] Rename AoE_Globals_ThreadSignalEvent to aoe__thread_sig_evt_
Shao Miller [Wed, 8 Dec 2010 02:49:08 +0000 (21:49 -0500)]
[aoe] Rename AoE_Globals_ThreadSignalEvent to aoe__thread_sig_evt_

11 years ago[aoe] Rename AoE_Globals_SpinLock to aoe__spinlock_
Shao Miller [Wed, 8 Dec 2010 02:47:31 +0000 (21:47 -0500)]
[aoe] Rename AoE_Globals_SpinLock to aoe__spinlock_

11 years ago[aoe] Rename AoE_Globals_Stop to aoe__stop_
Shao Miller [Wed, 8 Dec 2010 02:46:23 +0000 (21:46 -0500)]
[aoe] Rename AoE_Globals_Stop to aoe__stop_

11 years ago[aoe] Rename AoE_Globals_TargetList to aoe__target_list_
Shao Miller [Wed, 8 Dec 2010 02:45:10 +0000 (21:45 -0500)]
[aoe] Rename AoE_Globals_TargetList to aoe__target_list_

11 years ago[aoe] Rename AoE_Globals_TargetListSpinLock to aoe__target_list_spinlock_
Shao Miller [Wed, 8 Dec 2010 02:43:12 +0000 (21:43 -0500)]
[aoe] Rename AoE_Globals_TargetListSpinLock to aoe__target_list_spinlock_

11 years ago[aoe] Rename target_list to aoe__target_list_
Shao Miller [Wed, 8 Dec 2010 02:38:41 +0000 (21:38 -0500)]
[aoe] Rename target_list to aoe__target_list_

11 years ago[aoe] Rename search_state to aoe__search_state_
Shao Miller [Wed, 8 Dec 2010 02:36:30 +0000 (21:36 -0500)]
[aoe] Rename search_state to aoe__search_state_

11 years ago[aoe] Rename disk_search to aoe__disk_search_
Shao Miller [Wed, 8 Dec 2010 02:28:45 +0000 (21:28 -0500)]
[aoe] Rename disk_search to aoe__disk_search_

11 years ago[aoe] Rename work_tag to aoe__work_tag_
Shao Miller [Wed, 8 Dec 2010 02:26:05 +0000 (21:26 -0500)]
[aoe] Rename work_tag to aoe__work_tag_

11 years ago[aoe] Rename io_req to aoe__io_req_
Shao Miller [Wed, 8 Dec 2010 02:23:05 +0000 (21:23 -0500)]
[aoe] Rename io_req to aoe__io_req_

11 years ago[aoe] Rename packet to aoe__packet_
Shao Miller [Wed, 8 Dec 2010 02:21:12 +0000 (21:21 -0500)]
[aoe] Rename packet to aoe__packet_

11 years ago[aoe] Rename create_aoe_disk to aoe__create_disk_
Shao Miller [Wed, 8 Dec 2010 01:35:39 +0000 (20:35 -0500)]
[aoe] Rename create_aoe_disk to aoe__create_disk_

11 years ago[aoe] Rename free_aoe_disk to aoe__free_disk_
Shao Miller [Wed, 8 Dec 2010 01:31:35 +0000 (20:31 -0500)]
[aoe] Rename free_aoe_disk to aoe__free_disk_

11 years ago[aoe] Rename unload to aoe__unload_
Shao Miller [Wed, 8 Dec 2010 01:29:08 +0000 (20:29 -0500)]
[aoe] Rename unload to aoe__unload_

11 years ago[aoe] Rename process_abft to aoe__process_abft_
Shao Miller [Wed, 8 Dec 2010 01:27:17 +0000 (20:27 -0500)]
[aoe] Rename process_abft to aoe__process_abft_

11 years ago[debug] Undo a build macro toggle that slipped in
Shao Miller [Wed, 8 Dec 2010 01:12:25 +0000 (20:12 -0500)]
[debug] Undo a build macro toggle that slipped in

We were building with debugging enabled.  Oops.

11 years ago[aoe] Rename thread routine to aoe__thread_
Shao Miller [Wed, 8 Dec 2010 01:10:48 +0000 (20:10 -0500)]
[aoe] Rename thread routine to aoe__thread_

11 years ago[aoe] Rename aoe_disk_type to aoe__disk_type_
Shao Miller [Wed, 8 Dec 2010 01:06:52 +0000 (20:06 -0500)]
[aoe] Rename aoe_disk_type to aoe__disk_type_

Trying out a new style: All file-scope items prefixed by
"file__" and non-exported items suffixed with an underscore.

11 years ago[aoe] Don't use winvblock__def_enum for tag type
Shao Miller [Wed, 8 Dec 2010 01:00:25 +0000 (20:00 -0500)]
[aoe] Don't use winvblock__def_enum for tag type

11 years ago[device] Remove device__free_decl macro
Shao Miller [Tue, 7 Dec 2010 22:42:29 +0000 (17:42 -0500)]
[device] Remove device__free_decl macro

Use a typedef, instead.

11 years ago[irp] Remove irp__handler_decl macro
Shao Miller [Tue, 7 Dec 2010 22:00:27 +0000 (17:00 -0500)]
[irp] Remove irp__handler_decl macro

Use a typedef for similar (but lesser) convenience.
Again, for the sake of editors that parse source files.

11 years ago[aoe] Don't use winvblock__def_struct for aoe_disk_type
Shao Miller [Tue, 7 Dec 2010 21:18:00 +0000 (16:18 -0500)]
[aoe] Don't use winvblock__def_struct for aoe_disk_type

It might have been less typing, but some editors with code
completion obviously don't work with it.

11 years ago[aoe] Major cosmetic changes
Shao Miller [Tue, 7 Dec 2010 21:11:42 +0000 (16:11 -0500)]
[aoe] Major cosmetic changes

The driver.c file is quite large, so this effort isn't
even complete yet.

11 years ago[aoe] Minor cosmetic changes
Shao Miller [Tue, 7 Dec 2010 16:55:50 +0000 (11:55 -0500)]
[aoe] Minor cosmetic changes

11 years ago[disk] Move away from mini IRP handling table registration
Shao Miller [Fri, 3 Dec 2010 21:23:54 +0000 (16:23 -0500)]
[disk] Move away from mini IRP handling table registration

There was no current usage for hooking a disk's mini IRP
handling table chain, so we simply walk the one table from
a disk_dispatch() function.

11 years ago[bus] Start moving away from mini IRP handling registration
Shao Miller [Fri, 3 Dec 2010 21:08:37 +0000 (16:08 -0500)]
[bus] Start moving away from mini IRP handling registration

We begin to move away from a chain of registered mini IRP handling
tables, since right now AoE is the only module to make use of it,
registering with the boot bus.  For now, we leave a portion intact.

11 years ago[driver,device,irp] Don't use mini IRP handling registration
Shao Miller [Fri, 3 Dec 2010 06:36:14 +0000 (01:36 -0500)]
[driver,device,irp] Don't use mini IRP handling registration

We're moving away from registering/deregistering mini IRP
handling tables for devices, and towards each device class
implementing its own dispatch routine.

11 years ago[irp] Move code into irp__process_with_table
Shao Miller [Fri, 3 Dec 2010 05:40:59 +0000 (00:40 -0500)]
[irp] Move code into irp__process_with_table

We only have 4 mini IRP handling tables, so the
register/unregister functionality hardly seems worth it.  One
of the original reasons why it was added was so that AoE could
register with the bus device to receive IOCTLs.  We could do
it differently:

1. AoE could implement its own bus device as a sub-bus of the
   WinVBlock bus.

2. AoE could hook the WinVBlock bus' mini IRP handling table.
   This might be dangerous if AoE didn't unload properly.

3. AoE could still register with the WinVBlock bus to receive
   IRPs, but as a bus registration function versus an abstract
   IRP registration.

This commit paves the way for 'driver', 'bus', 'disk', 'aoe' to
each have their own IRP handling strategy, but to provide the
convenience of still using the mini IRP handling table strategy.
It removes emphasis from the mini IRP handling table
registration functions.

11 years ago[driver,device] Use place-holder driver__default_dispatch
Shao Miller [Thu, 2 Dec 2010 20:16:50 +0000 (15:16 -0500)]
[driver,device] Use place-holder driver__default_dispatch

Working towards the same prototype for IRP handling routines,
we need this place-holder while the mini IRP handling
infrastructure is unchanged.  This is simply to ensure build
and functionality during development, and to keep commit size
reasonable.

11 years ago[driver] Establish driver__dispatch_func type
Shao Miller [Thu, 2 Dec 2010 18:14:20 +0000 (13:14 -0500)]
[driver] Establish driver__dispatch_func type

This type is the prototype for the DriverDispatch function.
Interestingly, this site[1] details a DRIVER_DISPATCH type
for the same reason, but maybe we'll do that later.

11 years ago[irp] Introduce IRP thread routine
Shao Miller [Thu, 2 Dec 2010 16:46:17 +0000 (11:46 -0500)]
[irp] Introduce IRP thread routine

A thread routine which processes IRPs.

11 years ago[device] Make room for threaded devices
Shao Miller [Thu, 2 Dec 2010 15:06:07 +0000 (10:06 -0500)]
[device] Make room for threaded devices

After thinking about a "handler" scheme for devices which
implement various "interfaces," it looked like it'd be
better to implement threading for devices first and to find
out if that would do.

We make space for queuing IRPs and for a thread wakeup signal.

We also replace a lonely ExFreePool() that was missed in a
previous commit with wv_free().

11 years ago[project] Replace RtlZeroMemory with wv_?allocz where reasonable
Shao Miller [Mon, 22 Nov 2010 15:25:13 +0000 (10:25 -0500)]
[project] Replace RtlZeroMemory with wv_?allocz where reasonable

We now have wv_mallocz() and wv_pallocz(), which zero-fill an
allocated memory region.  We lose both speed (boo) and size (yay).

11 years ago[project] Change RtlCompareMemory to wv_memcmpeq
Shao Miller [Sun, 21 Nov 2010 10:25:29 +0000 (05:25 -0500)]
[project] Change RtlCompareMemory to wv_memcmpeq

We previously had patterns like:

  if (!(RtlCompareMemory(foo, bar, sizeof foo) == sizeof foo))

but now we have:

  if (!wv_memcmpeq(foo, bar, sizeof foo))

We've introduced a few new headers, which have the spirit of
mimicry of the C Standard Library....

'memcmpeq()' is completely bogus, however.

The MS compiler doesn't have '_Bool', so we use unsigned short
for the 'bool' type.  I hope that's good enough.

11 years ago[winvblock/disk/pnp.c] Fix ULONG_PTR warnings
Shao Miller [Sun, 21 Nov 2010 07:51:57 +0000 (02:51 -0500)]
[winvblock/disk/pnp.c] Fix ULONG_PTR warnings

The 'Information' member of an IO_STATUS_BLOCK has type
'ULONG_PTR', so if we are assigning a pointer, we should
cast to keep the MS compiler happy.

11 years ago[project] Replace ExFreePool with wv_free
Shao Miller [Sun, 21 Nov 2010 07:45:53 +0000 (02:45 -0500)]
[project] Replace ExFreePool with wv_free

All instances of ExFreePool() have been replaced with wv_free()

11 years ago[project] Change ExAllocatePool to wv_?alloc
Shao Miller [Sun, 21 Nov 2010 06:10:18 +0000 (01:10 -0500)]
[project] Change ExAllocatePool to wv_?alloc

Every instance of ExAllocatePool() has been replaced with one
of wv_malloc() or wv_palloc(), for non-paged memory pool
allocation and paged memory pool allocation, respectively.

Some coding style changes on changed lines, too, as I've
changed my mind yet again.

12 years ago[filedisk] Support hot-swapping to another file
Shao Miller [Sat, 12 Jun 2010 23:39:51 +0000 (19:39 -0400)]
[filedisk] Support hot-swapping to another file

We can currently boot from a GRUB4DOS sector-mapped disk.
GRUB4DOS has the requirement that the sector range be
contiguous (a contiguous file will do).  In a filesystem,
things like defragmentation or other physical movement of
the image file is possible, which would likely spell
disaster if we continued to simply use the range of
sectors on the backing disk.

It is therefore a good idea to use the image file as soon
as possible, rather than the disk.  This commit introduces
the ability to hot-swap to the file pretty early on.  A
file lock is then had, and the backing filesystem and the
image file are protected from being pulled out from
underneath us.

Since GRUB4DOS doesn't pass the filename used (there might
not even be one; it could honestly just be a sector range),
we improvise a means by which filenames can be associated:

  #!GRUB4DOS MENU.LST
  title Boot disk image file
    # Establish a buffer for passing filenames
    map --rd-size=2048
    map --mem (rd)+4 (0x55)
    # Establish the sector-mapped disk
    root (hd0,0)
    map /WinXP.HDD (hd0)
    # Seal the INT 0x13 hook
    map --hook
    # Pass info via the buffer
    write (0x55) #!GRUB4DOS\x00v=1\x00WinXP.HDD\x00\x80\x00
    # Mount the FS in the disk image file and boot NTLDR
    root (hd0,0)
    chainloader /ntldr

In the above, (rd) is a built-in "disk" with a base and a
size.  By default, the base is at memory address 0.  We
adjust the size to be 2048 bytes.  We then use map --mem
to establish a RAM disk (which we are simply abusing as
a buffer) by copying 4 sectors, 512 bytes each, from (rd).
map --mem RAM disks are marked-up in the INT 0x15, AX=0xE820
memory map, so should be protected against accidental
corruption.  After establishing the sector-mapped disk,
we use the write command to put our parameters in the
buffer.  We put

a signature:

  #!GRUB4DOS\x00

a version:

  v=1\x00

a filename:

  WinXP.HDD\x00

the associated drive number (hd0 == 0x80, etc.):

  \x80

the next filename is an ASCII NUL, meaning no more files:

  \x00

The signature was chosen while keeping a particular future
possibility in mind: Passing menu.lst itself as the phony
RAM disk.  All of the path and disk information is in this
file, which makes it fairly convenient.  It would mean
needing to be able to distinguish the menu choice as well
as a extensive parsing system, but it's not impossible.

12 years ago[util] Change the usage
Shao Miller [Mon, 7 Jun 2010 06:50:57 +0000 (02:50 -0400)]
[util] Change the usage

See winvblk.exe -? for new usage.  We process arguments into
options now.

12 years ago[util] Tons of cosmetic changes
Shao Miller [Fri, 4 Jun 2010 04:27:25 +0000 (00:27 -0400)]
[util] Tons of cosmetic changes

Nothing really effectively different.
Error codes changed a bit.

12 years ago[filedisk] Support .ISO-on-HDD scenario
Shao Miller [Thu, 3 Jun 2010 23:41:56 +0000 (19:41 -0400)]
[filedisk] Support .ISO-on-HDD scenario

Had to add a bit to the threaded filedisk in order to
allow a run-once read/write hook which attempts to find
the correct file-backed disk.  This hook used to hook
the enqueuer, but is now queued by it.

So now one can boot an .ISO file that's found on an HDD,
as long as there is a 2048-byte (OD sector) footer whose
last 512 bytes are the Microsoft .VHD footer details.

We should probably provide the convenience for adding
.VHD footers to HDD images and .ISOs in the user-land
utility.

12 years ago[filedisk] Fix GRUB4DOS logic up a bit
Shao Miller [Thu, 3 Jun 2010 21:17:22 +0000 (17:17 -0400)]
[filedisk] Fix GRUB4DOS logic up a bit

Had a check backwards.
Had a dumb boolean where status is fine.

12 years ago[filedisk] Require Microsoft VHD footers for booted disk images
Shao Miller [Thu, 3 Jun 2010 20:52:44 +0000 (16:52 -0400)]
[filedisk] Require Microsoft VHD footers for booted disk images

The previous check for the short MBR magic was really cheap and
could fairly easily result in false positives.  We now require
a Microsoft .VHD "footer" to be within the last 512 bytes of
the disk image.  This works nicely for HDD images right now.

[Un]Fortunately, testing the .ISO case revealed that the code
which iterates through disks in an attempt to find the right
backing disk is running at an IRQL which is incompatible with
IoGetDeviceInterfaces(), which wishes to allocate to pageable
memory.  It would seem best to enqueue this activity, but
neither threaded filedisks nor the GRUB4DOS threaded filedisk
actually implement a new "class" of device, so there's not a
place to throw the previous disk__io routine while we hook a
read/write operation in order to allow for delayed backing
disk discovery.

12 years ago[disk] Use unsigned 64-bit integer for sector counting
Shao Miller [Thu, 3 Jun 2010 05:40:05 +0000 (01:40 -0400)]
[disk] Use unsigned 64-bit integer for sector counting

12 years ago[headers] Add byte order swapping support
Shao Miller [Thu, 3 Jun 2010 01:51:01 +0000 (21:51 -0400)]
[headers] Add byte order swapping support

Simply for convenience, we now have a function
byte__order_swap() and a macro
byte__rev_array_union() and a type
byte__array_union which are all just conveniences
for changing byte order.

12 years ago[version] Up version to 0.0.1.8
Shao Miller [Tue, 1 Jun 2010 07:19:42 +0000 (03:19 -0400)]
[version] Up version to 0.0.1.8

This release introduces initial support for GRUB4DOS
sector-mapped disks.  Currently, only HDD images with MBRs
are supported.

Please note that this is an early stage in supporting this
scenario, so you might find quirks.  Also be aware of the
limitations:
- If your booted-from disk image file gets _moved_ while you
  are booted from it, expect terrible things to happen.  Try
  to avoid such things as defragmenting the filesystem with
  the disk image on it!
- There isn't really a good way to know which Windows disk a
  GRUB4DOS backing disk corresponds to!  Not enough information
  is available to make the right decision.  BIOS drive numbers
  have no relevance in Windows, so we cannot exactly identify
  which backing disk is correct for a disk image
- WinVBlock is not capable of magic; your booted disk image
  _must_ have drivers and device ID associations so that the
  _real_ disks are found at boot time!

12 years ago[filedisk] Add MBR check for GRUB4DOS disks
Shao Miller [Tue, 1 Jun 2010 07:09:12 +0000 (03:09 -0400)]
[filedisk] Add MBR check for GRUB4DOS disks

We lack any good means of finding the correct backing disk for
a boot-time file-backed disk.  Here is a really cheap check
which will test for an MBR where we would expect on on the
backing disk.  This doesn't support CD/DVD, obviously.

12 years ago[disk] Move MBR structure def. and CHS macros into header
Shao Miller [Tue, 1 Jun 2010 06:28:04 +0000 (02:28 -0400)]
[disk] Move MBR structure def. and CHS macros into header

12 years ago[filedisk] Increase timeout for threaded disk processing
Shao Miller [Tue, 1 Jun 2010 04:43:43 +0000 (00:43 -0400)]
[filedisk] Increase timeout for threaded disk processing

If there's nothing to do but a possible device__free(),
just sleep for up to a whole second before checking.

12 years ago[filedisk] Initial support for booting a filedisk from GRUB4DOS
Shao Miller [Tue, 1 Jun 2010 04:04:06 +0000 (00:04 -0400)]
[filedisk] Initial support for booting a filedisk from GRUB4DOS

Whee.  We scan memory for GRUB4DOS sector-mapped disks, create
filedisks for them, then hook them so that the first time they
are used, we try to find the appropriate backing disk for each.

The limitations of the current implementation are:
- We assume the first disk is the right backing disk (very naive)
- We don't check to make sure we don't open our own disk
- It's pretty slow for some reason that needs investigation
- There is not really a good way to associate GRUB4DOS mappings
  to Windows disks; not enough information is passed!
- If the image file for a filedisk gets moved while we are using
  it, expect terrible things to happen!

12 years ago[filedisk] Move filedisk__get_ptr macro into header
Shao Miller [Tue, 1 Jun 2010 02:36:38 +0000 (22:36 -0400)]
[filedisk] Move filedisk__get_ptr macro into header

Same as other such *__get_ptr() macros used by multiple
C source files.

12 years ago[filedisk] Implement threaded filedisk creation function
Shao Miller [Tue, 1 Jun 2010 01:41:18 +0000 (21:41 -0400)]
[filedisk] Implement threaded filedisk creation function

filedisk__create_threaded() should return a pointer to a
threaded, file-backed disk.

12 years ago[filedisk] Add support for threaded filedisks
Shao Miller [Tue, 1 Jun 2010 01:21:16 +0000 (21:21 -0400)]
[filedisk] Add support for threaded filedisks

We now have a disk__io routine which enqueues a request for
later processing.  We implement a device__free routine to
support such asynchronous filedisks.  We have a thread
function per threaded filedisk which processes the queue
of requests.

12 years ago[filedisk] Allow for a file offset
Shao Miller [Mon, 31 May 2010 19:29:26 +0000 (15:29 -0400)]
[filedisk] Allow for a file offset

It's useful to have a base offset into a file from which
the virtual disk's sectors will be considered to start.

12 years ago[filedisk] Add GRUB4DOS module
Shao Miller [Sun, 30 May 2010 06:16:19 +0000 (02:16 -0400)]
[filedisk] Add GRUB4DOS module

Distinguish between the case of GRUB4DOS RAM disks and
GRUB4DOS sector-mapped (file-backed) disks.  A new probe
routine is added (which currently does nothing).

12 years ago[filedisk] Put in own subdir and change to library
Shao Miller [Sun, 30 May 2010 06:01:01 +0000 (02:01 -0400)]
[filedisk] Put in own subdir and change to library

There is a plan to support GRUB4DOS sector-mapped disks,
so we will need another probe routine, suggesting that
there should be a GRUB4DOS source file in a filedisk/
directory, as there is a GRUB4DOS source file in the
ramdisk/ directory.

12 years ago[disk] Allow for asynchronous IRP completion
Shao Miller [Sun, 30 May 2010 05:27:48 +0000 (01:27 -0400)]
[disk] Allow for asynchronous IRP completion

After much debugging, it was revealed that in order to use
ZwReadFile() for a file-backed disk during boot, one needs
to return STATUS_PENDING to the caller and start a worker
thread who will use ZwReadFile() and then complete the IRP.

12 years ago[irp,bus] Send and handle IRP completion properly for detach
Shao Miller [Sun, 23 May 2010 17:36:53 +0000 (13:36 -0400)]
[irp,bus] Send and handle IRP completion properly for detach

The disk detach handler was not completing the IRP and the
IRP processor was not checking for completion in an outer
while() loop.  Both fixed.

12 years ago[aoe] Fix get_ptr macro and uses
Shao Miller [Sun, 23 May 2010 16:47:02 +0000 (12:47 -0400)]
[aoe] Fix get_ptr macro and uses

How I missed this, I really have no idea...