Rename some functions and local identifiers, etc.
/**
- * Copyright (C) 2009, Shao Miller <shao.miller@yrdsb.edu.on.ca>.
+ * Copyright (C) 2009-2010, Shao Miller <shao.miller@yrdsb.edu.on.ca>.
* Copyright 2006-2008, V.
* For WinAoE contact information, see http://winaoe.org/
*
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _probe_h
-# define _probe_h
+#ifndef _WV_M_PROBE_H_
+# define _WV_M_PROBE_H_
/**
* @file
*
- * Boot-time disk probing specifics
- *
+ * Boot-time disk probing specifics.
*/
-winvblock__def_struct ( int_vector )
-{
- winvblock__uint16 Offset;
- winvblock__uint16 Segment;
-};
-
-# ifdef _MSC_VER
-# pragma pack(1)
-# endif
-winvblock__def_struct ( safe_mbr_hook )
-{
- winvblock__uint8 Jump[3];
- winvblock__uint8 Signature[8];
- winvblock__uint8 VendorID[8];
- int_vector PrevHook;
- winvblock__uint32 Flags;
- winvblock__uint32 mBFT; /* MEMDISK only */
-}
-
-__attribute__ ( ( __packed__ ) );
-# ifdef _MSC_VER
-# pragma pack()
-# endif
+typedef struct WV_PROBE_INT_VECTOR {
+ winvblock__uint16 Offset;
+ winvblock__uint16 Segment;
+ } WV_S_PROBE_INT_VECTOR, * WV_SP_PROBE_INT_VECTOR;
-extern safe_mbr_hook_ptr STDCALL get_safe_hook (
- IN winvblock__uint8_ptr PhysicalMemory,
- IN int_vector_ptr InterruptVector
- );
+#ifdef _MSC_VER
+# pragma pack(1)
+#endif
+struct WV_PROBE_SAFE_MBR_HOOK {
+ winvblock__uint8 Jump[3];
+ winvblock__uint8 Signature[8];
+ winvblock__uint8 VendorId[8];
+ WV_S_PROBE_INT_VECTOR PrevHook;
+ winvblock__uint32 Flags;
+ winvblock__uint32 Mbft; /* MEMDISK only. */
+ } __attribute__((__packed__));
+#ifdef _MSC_VER
+# pragma pack()
+#endif
+typedef struct WV_PROBE_SAFE_MBR_HOOK
+ WV_S_PROBE_SAFE_MBR_HOOK, * WV_SP_PROBE_SAFE_MBR_HOOK;
-extern void probe__disks (
- void
- );
+/* Probe functions. */
+extern WV_SP_PROBE_SAFE_MBR_HOOK STDCALL WvProbeGetSafeHook(
+ IN winvblock__uint8_ptr,
+ IN WV_SP_PROBE_INT_VECTOR
+ );
+extern void WvProbeDisks(void);
-#endif /* _probe_h */
+#endif /* _WV_M_PROBE_H_ */
irp->IoStatus.Status
);
}
- probe__disks();
+ WvProbeDisks();
count = 0;
walker = bus->first_child;
while (walker != NULL) {
{
PHYSICAL_ADDRESS PhysicalAddress;
winvblock__uint8_ptr PhysicalMemory;
- int_vector_ptr InterruptVector;
+ WV_SP_PROBE_INT_VECTOR InterruptVector;
winvblock__uint32 Int13Hook;
- safe_mbr_hook_ptr SafeMbrHookPtr;
+ WV_SP_PROBE_SAFE_MBR_HOOK SafeMbrHookPtr;
grub4dos__drive_mapping_ptr Grub4DosDriveMapSlotPtr;
winvblock__uint32 i;
winvblock__bool FoundGrub4DosMapping = FALSE;
return;
}
InterruptVector =
- ( int_vector_ptr ) ( PhysicalMemory + 0x13 * sizeof ( int_vector ) );
- /*
- * Walk the "safe hook" chain of INT 13h hooks as far as possible
- */
- while ( SafeMbrHookPtr = get_safe_hook ( PhysicalMemory, InterruptVector ) )
- {
+ (WV_SP_PROBE_INT_VECTOR) (PhysicalMemory + 0x13 * sizeof *InterruptVector);
+ /* Walk the "safe hook" chain of INT 13h hooks as far as possible. */
+ while (SafeMbrHookPtr = WvProbeGetSafeHook(PhysicalMemory, InterruptVector)) {
/*
* Check signature
*/
- if (!wv_memcmpeq(SafeMbrHookPtr->VendorID, sig, sizeof sig - 1)) {
+ if (!wv_memcmpeq(SafeMbrHookPtr->VendorId, sig, sizeof sig - 1)) {
DBG ( "Non-GRUB4DOS INT 0x13 Safe Hook\n" );
InterruptVector = &SafeMbrHookPtr->PrevHook;
continue;
#include "filedisk.h"
#include "probe.h"
-safe_mbr_hook_ptr STDCALL
-get_safe_hook (
- IN winvblock__uint8_ptr PhysicalMemory,
- IN int_vector_ptr InterruptVector
- )
-{
- winvblock__uint32 Int13Hook;
- safe_mbr_hook_ptr SafeMbrHookPtr;
- winvblock__uint8 Signature[9] = { 0 };
- winvblock__uint8 VendorID[9] = { 0 };
+WV_SP_PROBE_SAFE_MBR_HOOK STDCALL WvProbeGetSafeHook(
+ IN winvblock__uint8_ptr PhysicalMemory,
+ IN WV_SP_PROBE_INT_VECTOR InterruptVector
+ ) {
+ winvblock__uint32 int13_hook;
+ WV_SP_PROBE_SAFE_MBR_HOOK safe_mbr_hook;
+ winvblock__uint8 sig[9] = {0};
+ winvblock__uint8 ven_id[9] = {0};
- Int13Hook =
- ( ( ( winvblock__uint32 ) InterruptVector->Segment ) << 4 ) +
- ( ( winvblock__uint32 ) InterruptVector->Offset );
- SafeMbrHookPtr = ( safe_mbr_hook_ptr ) ( PhysicalMemory + Int13Hook );
- RtlCopyMemory ( Signature, SafeMbrHookPtr->Signature, 8 );
- RtlCopyMemory ( VendorID, SafeMbrHookPtr->VendorID, 8 );
- DBG ( "INT 0x13 Segment: 0x%04x\n", InterruptVector->Segment );
- DBG ( "INT 0x13 Offset: 0x%04x\n", InterruptVector->Offset );
- DBG ( "INT 0x13 Hook: 0x%08x\n", Int13Hook );
- DBG ( "INT 0x13 Safe Hook Signature: %s\n", Signature );
- if (!wv_memcmpeq(Signature, "$INT13SF", sizeof "$INT13SF" - 1)) {
- DBG ( "Invalid INT 0x13 Safe Hook Signature; End of chain\n" );
- return NULL;
- }
- return SafeMbrHookPtr;
-}
+ int13_hook = (((winvblock__uint32) InterruptVector->Segment) << 4) +
+ ((winvblock__uint32) InterruptVector->Offset);
+ safe_mbr_hook = (WV_SP_PROBE_SAFE_MBR_HOOK) (PhysicalMemory + int13_hook);
+ RtlCopyMemory(sig, safe_mbr_hook->Signature, 8);
+ RtlCopyMemory(ven_id, safe_mbr_hook->VendorId, 8);
+ DBG("INT 0x13 Segment: 0x%04x\n", InterruptVector->Segment);
+ DBG("INT 0x13 Offset: 0x%04x\n", InterruptVector->Offset);
+ DBG("INT 0x13 Hook: 0x%08x\n", int13_hook);
+ DBG("INT 0x13 Safe Hook Signature: %s\n", sig);
+ if (!wv_memcmpeq(sig, "$INT13SF", sizeof "$INT13SF" - 1)) {
+ DBG("Invalid INT 0x13 Safe Hook Signature; End of chain\n");
+ return NULL;
+ }
+ return safe_mbr_hook;
+ }
-extern void
-probe__disks (
- void
- )
-{
- static winvblock__bool probed = FALSE;
- if ( probed )
- return;
- memdisk__find ( );
- ramdisk_grub4dos__find ( );
- filedisk_grub4dos__find ( );
- probed = TRUE;
-}
+void WvProbeDisks(void) {
+ static winvblock__bool probed = FALSE;
+
+ if (probed)
+ return;
+ memdisk__find();
+ ramdisk_grub4dos__find();
+ filedisk_grub4dos__find();
+ probed = TRUE;
+ }
{
PHYSICAL_ADDRESS PhysicalAddress;
winvblock__uint8_ptr PhysicalMemory;
- int_vector_ptr InterruptVector;
+ WV_SP_PROBE_INT_VECTOR InterruptVector;
winvblock__uint32 Int13Hook;
- safe_mbr_hook_ptr SafeMbrHookPtr;
+ WV_SP_PROBE_SAFE_MBR_HOOK SafeMbrHookPtr;
grub4dos__drive_mapping_ptr Grub4DosDriveMapSlotPtr;
winvblock__uint32 i = 8;
winvblock__bool FoundGrub4DosMapping = FALSE;
return;
}
InterruptVector =
- ( int_vector_ptr ) ( PhysicalMemory + 0x13 * sizeof ( int_vector ) );
- /*
- * Walk the "safe hook" chain of INT 13h hooks as far as possible
- */
- while ( SafeMbrHookPtr = get_safe_hook ( PhysicalMemory, InterruptVector ) )
- {
+ (WV_SP_PROBE_INT_VECTOR) (PhysicalMemory + 0x13 * sizeof *InterruptVector);
+ /* Walk the "safe hook" chain of INT 13h hooks as far as possible. */
+ while (SafeMbrHookPtr = WvProbeGetSafeHook(PhysicalMemory, InterruptVector)) {
if (!wv_memcmpeq(
- SafeMbrHookPtr->VendorID,
+ SafeMbrHookPtr->VendorId,
"GRUB4DOS",
sizeof "GRUB4DOS" - 1
)) {
mdi__mbft_ptr mBFT = ( mdi__mbft_ptr ) ( PhysicalMemory + Offset );
winvblock__uint32 i;
winvblock__uint8 Checksum = 0;
- safe_mbr_hook_ptr AssociatedHook;
+ WV_SP_PROBE_SAFE_MBR_HOOK AssociatedHook;
ramdisk__type_ptr ramdisk_ptr;
if ( Offset >= 0x100000 )
DBG ( "mBFT safe hook physical pointer too high!\n" );
return FALSE;
}
- AssociatedHook = ( safe_mbr_hook_ptr ) ( PhysicalMemory + mBFT->SafeHook );
+ AssociatedHook =
+ (WV_SP_PROBE_SAFE_MBR_HOOK) (PhysicalMemory + mBFT->SafeHook);
if ( AssociatedHook->Flags )
{
DBG ( "This MEMDISK already processed\n" );
{
PHYSICAL_ADDRESS PhysicalAddress;
winvblock__uint8_ptr PhysicalMemory;
- int_vector_ptr InterruptVector;
- safe_mbr_hook_ptr SafeMbrHookPtr;
+ WV_SP_PROBE_INT_VECTOR InterruptVector;
+ WV_SP_PROBE_SAFE_MBR_HOOK SafeMbrHookPtr;
winvblock__uint32 Offset;
winvblock__bool FoundMemdisk = FALSE;
return;
}
InterruptVector =
- ( int_vector_ptr ) ( PhysicalMemory + 0x13 * sizeof ( int_vector ) );
- /*
- * Walk the "safe hook" chain of INT 13h hooks as far as possible
- */
- while ( SafeMbrHookPtr = get_safe_hook ( PhysicalMemory, InterruptVector ) )
- {
- if (!wv_memcmpeq(SafeMbrHookPtr->VendorID, "MEMDISK ", 8)) {
+ (WV_SP_PROBE_INT_VECTOR) (PhysicalMemory + 0x13 * sizeof *InterruptVector);
+ /* Walk the "safe hook" chain of INT 13h hooks as far as possible. */
+ while (SafeMbrHookPtr = WvProbeGetSafeHook(PhysicalMemory, InterruptVector)) {
+ if (!wv_memcmpeq(SafeMbrHookPtr->VendorId, "MEMDISK ", 8)) {
DBG ( "Non-MEMDISK INT 0x13 Safe Hook\n" );
}
else
{
- FoundMemdisk |= check_mbft ( PhysicalMemory, SafeMbrHookPtr->mBFT );
+ FoundMemdisk |= check_mbft ( PhysicalMemory, SafeMbrHookPtr->Mbft );
}
InterruptVector = &SafeMbrHookPtr->PrevHook;
}