Solved

Int 21h Function 440Dh

Posted on 1998-01-29
3
241 Views
Last Modified: 2013-11-19
if you look up help under Int 21h Function 440Dh Minor Code 46h(FAT32)

and make a working code out of it, that is all I need.

I have a structure

struct MID
{
    WORD midInfoLevel;
    DWORD midSerialNum;  
    char midVolLabel[11];
    char midFileSysType[8];
};

and a puhbutton function
void CMyDlg::OnButtonRUN()
{
      // TODO: Add your control notification handler codehere
      MID* MediaID;
      MediaID->midInfoLevel = 0;
      __asm
      {

mov     bx, 1               ;See below
mov     ch, 48h           ;See below
mov     cl, 46h                 ;Set Media ID
mov     dx, seg MediaID         ;See below
mov     ds, dx
mov     dx, offset MediaID      ;ds:dx points to MID structure
mov     ax, 440Dh               ;IOCTL for block device
int     21h

//jc      error_handler           ;carry set means error

      }
}

asm doesnot like mystructure, so try yourself
0
Comment
Question by:has
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 1315193
In Win32, you can't use int 21h functions in this way. The following part is from the SDK documentation.


Calling DeviceIoControl on Windows 95

A Win32-based application running on Windows 95 can use the DeviceIoControl function to send control codes directly to a virtual device driver (VxD). Any VxD can support any number of control codes, or none at all.

The system VxD, VWIN32.VXD, supports the input and output control (IOCTL) functions originally provided by MS-DOS Interrupt 21h. The following example shows how to call Get Media ID (Interrupt 21h Function 440Dh Minor Code 66h) from a Win32-based application:

 
“\\\\.\\VxDName”
In Windows 95,
 
#define VWIN32_DIOC_DOS_IOCTL 1
 
typedef struct _DEVIOCTL_REGISTERS {
    DWORD reg_EBX;
    DWORD reg_EDX;
    DWORD reg_ECX;
    DWORD reg_EAX;
    DWORD reg_EDI;
    DWORD reg_ESI;
    DWORD reg_Flags;
} DEVIOCTL_REGISTERS, *PDEVIOCTL_REGISTERS;
 
typedef struct _MID {
    WORD  midInfoLevel;
    DWORD midSerialNum;
    BYTE  midVolLabel[11];
    BYTE  midFileSysType[8];
} MID, *PMID;
 
BOOL GetMediaID(PMID pmid, UINT nDrive)
{
    DEVIOCTL_REGISTERS reg;
 
    reg.reg_EAX = 0x440D;       /* IOCTL for block devices */
    reg.reg_EBX = nDrive;       /* zero-based drive ID     */
    reg.reg_ECX = 0x0866;       /* Get Media ID command    */
    reg.reg_EDX = (DWORD) pmid; /* receives media ID info  */
 
    if (!DoIOCTL(&reg))
        return FALSE;
 
    if (reg.reg_Flags & 0x8000) /* error if carry flag set */
        return FALSE;
 
    return TRUE;
}
 
BOOL DoIOCTL(PDEVIOCTL_REGISTERS preg)
{
    HANDLE hDevice;
 
    BOOL fResult;
    DWORD cb;
 
    preg->reg_Flags = 0x8000; /* assume error (carry flag set) */
 
    hDevice = CreateFile("\\\\.\\vwin32",
        GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
        (LPSECURITY_ATTRIBUTES) NULL, OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL);
 
    if (hDevice == (HANDLE) INVALID_HANDLE_VALUE)
        return FALSE;
    else {
        fResult = DeviceIoControl(hDevice, VWIN32_DIOC_DOS_IOCTL,
            preg, sizeof(*preg), preg, sizeof(*preg), &cb, 0);
 
        if (!fResult)
            return FALSE;
    }
 
    CloseHandle(hDevice);
 
    return TRUE;
}

0
 

Author Comment

by:has
ID: 1315194
thank you for your help. I use winNT, and tried the code above
but could not get it working. I used exact same code except

"\\\\.\\vwin32" ( I used "\\\\.\\a:") and on my test button
void CFormatDlg::OnButtonTest()
{
      // TODO: Add your control notification handler code here
      MID mid;
      UINT nDrive = 0;
      if(GetMediaID(&mid, nDrive))
      {
            CString name;
            name = mid.midVolLabel;
            MessageBox(name);
      }
      else MessageBox("error");
}

but line
fResult = DeviceIoControl(hDevice, VWIN32_DIOC_DOS_IOCTL,
preg, sizeof(*preg), preg, sizeof(*preg), &cb, 0);

returns false ? can you tell ? is because of NT not win 95 ?
thanks
0
 
LVL 23

Expert Comment

by:chensu
ID: 1315195
Yes, it is because of Windows NT. First, the Int 21h Function 440Dh Minor Code 46h(FAT32) is one of the Windows 95 features according to the documentation. And FAT32 is supported only by Windows 95 OEM Service Release 2 and later. Second, VWIN32.VXD is used in Windows 95.

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
fizzArray  challenge 1 84
no14 challenge 14 69
noX challenge 17 117
"Black Box" Testing of Control System Software 2 51
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question