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.2原ipxe封装的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 )