修改ipxe源码,实现隐藏本地磁盘和读写转移功能(二)

4.代码实现流程图:


4.1隐藏本地磁盘

通过设置寄存器ah值,达到返回错误,隐藏本地磁盘目的;

注意,这里需要设置对应标志寄存器,目的是让函数退出后,不再调用bios-int13

/**
 * hide local disk by int 13.
 *
 * @author sun (9/17/2015)
 *
 * @param int13     Emulated drive
 * @param ix86      A full register dump
 *
 * @return int      Status code
 */
static int int13_hide_local_disk ( struct int13_drive *int13,
             struct i386_all_regs *ix86 ) {
    unsigned int local_drive = ix86->regs.dl;

    if ( local_drive != int13->drive &&
         local_drive < int13->natural_drive ) {
        ix86->regs.ah = 1;
        ix86->flags |= OF;
    }
    return 0;
}

4.2ipxe封装的int13接口,这里只改变函数名,不做其他改变。

该函数是int13各个子功能中转站,封装了ipxe自己的读写接口规范。

/**
 * INT 13 handler
 *
 * @author sun (9/28/2015)
 *
 * @param ix86      all registers
 *
 * @return int      status
 */
static int int13_service_disk_process ( struct i386_all_regs *ix86 ) {
    int command = ix86->regs.ah;
    unsigned int bios_drive = ix86->regs.dl;
    struct int13_drive *int13;
    int status;

    /* Check BIOS hasn't killed off our drive */
    int13_check_num_drives();

    list_for_each_entry ( int13, &int13s, list )
    {
        if ( bios_drive != int13->drive )
        {
            /* Remap any accesses to this drive's natural number */
            if ( bios_drive == int13->natural_drive )
            {
                DBGC2 ( int13, "INT13,%02x (%02x) remapped to "
                    "(%02x)\n", ix86->regs.ah,
                    bios_drive, int13->drive );
                ix86->regs.dl = int13->drive;
                return INT13_STATUS_SUCCESS;
            }
            else if ( ( ( bios_drive & 0x7f ) 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值