?
Solved

Int 21h Function 440Dh

Posted on 1998-01-29
3
Medium Priority
?
252 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

765 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