Solved

Int 21h Function 440Dh

Posted on 1998-01-29
3
234 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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 this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now