Пример #1
0
VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
{
    ULONG*  RealModeIVT = (ULONG*)0x00000000;
    USHORT* BiosLowMemorySize = (USHORT*)0x00000413;

    if (!DriveMapInstalled)
    {
        // Get the old INT 13h handler address from the vector table
        OldInt13HandlerAddress = RealModeIVT[0x13];

        // Decrease the size of low memory
        (*BiosLowMemorySize)--;

        // Get linear address for drive map handler
        DriveMapHandlerAddress = (ULONG)(*BiosLowMemorySize) << 10;

        // Convert to segment:offset style address
        DriveMapHandlerSegOff = (DriveMapHandlerAddress << 12) & 0xffff0000;
    }

    // Copy the drive map structure to the proper place
    RtlCopyMemory(&DriveMapInt13HandlerMapList, DriveMap, sizeof(DRIVE_MAP_LIST));

    // Set the address of the BIOS INT 13h handler
    DriveMapOldInt13HandlerAddress = OldInt13HandlerAddress;

    // Copy the code to our reserved area
    RtlCopyMemory((PVOID)DriveMapHandlerAddress, &DriveMapInt13HandlerStart, ((ULONG)&DriveMapInt13HandlerEnd - (ULONG)&DriveMapInt13HandlerStart));

    // Update the IVT
    RealModeIVT[0x13] = DriveMapHandlerSegOff;

    CacheInvalidateCacheData();
    DriveMapInstalled = TRUE;
}
Пример #2
0
VOID DriveMapRemoveInt13Handler(VOID)
{
    ULONG*  RealModeIVT = (ULONG*)0x00000000;
    USHORT* BiosLowMemorySize = (USHORT*)0x00000413;

    if (DriveMapInstalled)
    {
        // Get the old INT 13h handler address from the vector table
        RealModeIVT[0x13] = OldInt13HandlerAddress;

        // Increase the size of low memory
        (*BiosLowMemorySize)++;

        CacheInvalidateCacheData();
        DriveMapInstalled = FALSE;
    }
}