⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ioctl.c

📁 Due to an increase in demand for and questions about direct disk access for Micrososft platforms, a
💻 C
字号:
/*
 * win32\ioctl.c    perform DOS IOCTL calls
 *
 * This file is part of the BETA version of DISKLIB
 * Copyright (C) 1998, Gregg Jennings
 *
 * See README.TXT for information about re-distribution.
 * See DISKLIB.TXT for information about usage.
 *
 */

#include <stdio.h>

#include "win32.h"
#include "dosio.h"
#include "debug.h"

/*
 * win_ioctl        perform DOS IOCTL call (INT 21h/440Dh)
 *
 * Notes: Unlike the DOS version of this function this function
 *        only supports only a subset of 440Dh IOCTL functions.
 *
 */

extern int win_ioctl(DOS_MINOR_CODE func, int dev, void *buf)
{
int i;
DIOC_REGISTERS regs DBG_0;

    regs.d.eax = 0x440D;
    regs.d.ebx = dev + 1;
    regs.d.ecx = 0x0800 + func;
    regs.d.edx = (DWORD)buf;

    if ((i = win_device_io(VWIN32_DIOC_DOS_IOCTL,&regs)) != DEVICE_OK)
        return i;

    if (regs.x.flags & 0x0001)
        return regs.x.ax;
    /*
        Note: If carry is set Windows does not set the error code
        that would be returned by GetLastError() (and there appears
        to be no dosexterr() equivalent) so the driver error code is
        returned, which will be greater than 0 which is greater than
        the ..._OK and ..._ERR defines.
    */

    return DEVICE_OK;
}

/*
 * win_ioctl_ext    perform Window 95 IOCTL call (INT 21h/440Dh)
 *
 * Notes: Unlike the DOS version of this function this function
 *        only supports only a subset of 440Dh IOCTL functions.
 *
 */

extern int win_ioctl_ext(DOS_MINOR_CODE func, int dev, void *buf)
{
int i;
DIOC_REGISTERS regs DBG_0;

    regs.d.eax = 0x440D;
    regs.d.ebx = dev + 1;
    regs.d.ecx = 0x4800 + func;
    regs.d.edx = (DWORD)buf;

    if ((i = win_device_io(VWIN32_DIOC_DOS_IOCTL,&regs)) != DEVICE_OK)
        return i;

    if (regs.x.flags & 0x0001)
        return regs.x.ax;

    return DEVICE_OK;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -