Solved

Int 21h Function 440Dh

Posted on 1998-01-29
3
243 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Separate into files by filename 12 87
Prevent this page from creating additional dialogs. 3 619
zeroMAx challenge 20 113
canBalance challenge 34 98
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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. …
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/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

838 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