Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

Please help me

I would like to find the media id of a compact disc
anyone can help???
0
Tonyleung
Asked:
Tonyleung
1 Solution
 
roaknogCommented:
#define VWIN32_DIOC_DOS_IOCTL 1

#include <windows.h>
#include <fstream.h>//for ofstream

//DECLARE SOME VARIABLES
      UINT nDrive = 4; //for cd drive d
      HANDLE hDevice;
      BOOL fResult;
      DWORD cb;
      char hexarray[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
      DWORD hfst, hscd, htrd, hfth, lfst, lscd, ltrd, lfth;

      typedef struct _midSN {
            WORD SNHighPart;
            WORD SNLowPart;
      } midSN;


      typedef struct _MID
      {
            WORD midInfoLevel;
            midSN midSerialNum;
            BYTE midVolLabel[11];
            BYTE midFileSysType[8];
      } MID, *PMID;

      MID mid;
      PMID pmid = &mid;

      typedef struct _DEVICEIOCTL_REGISTETRS
      {
            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;


void main()
      {
      DEVIOCTL_REGISTERS roakreg;
      PDEVIOCTL_REGISTERS preg = &roakreg;
      roakreg.reg_EAX = 0x440D;
      roakreg.reg_EBX = nDrive;
      roakreg.reg_ECX = 0x866;
      roakreg.reg_EDX = (DWORD)pmid;
      roakreg.reg_Flags = 0x8000;


// GET HANDLE
      hDevice = CreateFile("\\\\.\\vwin32",
            0,
            0,
            NULL,
            0,
            FILE_FLAG_DELETE_ON_CLOSE,
            NULL);

      fResult = DeviceIoControl(hDevice,
            VWIN32_DIOC_DOS_IOCTL,
            &roakreg,
            sizeof(roakreg),
            &roakreg,
            sizeof(roakreg),
            &cb,
            0);

//CLOSE HANDLE
      CloseHandle(hDevice);

//convert serial number to hex
      hfst = mid.midSerialNum.SNHighPart/4096;
      hscd = (mid.midSerialNum.SNHighPart-(hfst*4096))/256;
      htrd = (mid.midSerialNum.SNHighPart-(hfst*4096)-(hscd*256))/16;
      hfth = (mid.midSerialNum.SNHighPart-(hfst*4096)-(hscd*256)-(htrd*16));
      lfst = mid.midSerialNum.SNLowPart/4096;
      lscd = (mid.midSerialNum.SNLowPart-(lfst*4096))/256;
      ltrd = (mid.midSerialNum.SNLowPart-(lfst*4096)-(lscd*256))/16;
      lfth = (mid.midSerialNum.SNLowPart-(lfst*4096)-(lscd*256)-(ltrd*16));

//OUTPUT
      ofstream q("c:\\temp\\dioc.doc");
      q << "cb = " << cb << 
            ".\vhDevice = " << hDevice << 
            ".\v(HANDLE)INVALID_HANDLE_VALUE = " << (HANDLE)INVALID_HANDLE_VALUE << 
            ".\vfResult = " << fResult << 
            ".\vVWIN32_DIOC_DOS_IOCTL = " << VWIN32_DIOC_DOS_IOCTL <<
            ".\vnDrive = " << nDrive <<
            ".\vmid.midInfoLevel = " << mid.midInfoLevel <<
            ".\vWORD mid.midSerialNum.SNHighPart = " << mid.midSerialNum.SNHighPart <<
            ".\vWORD mid.midSerialNum.SNLowPart = " << mid.midSerialNum.SNLowPart <<
            ".\v&mid.midSerialNum.SNHighPart = " << &mid.midSerialNum.SNHighPart <<
            ".\v&mid.midSerialNum.SNLowPart = " << &mid.midSerialNum.SNLowPart <<
            ".\vhexadecimal mid.midSerialNum.SNHighPart = " << hexarray[hfst] << hexarray[hscd] << hexarray[htrd] << hexarray[hfth] <<
            ".\vhexadecimal mid.midSerialNum.SNLowPart = " << hexarray[lfst] << hexarray[lscd] << hexarray[ltrd] << hexarray[lfth] <<
            ".\vThe Serial Number is: " << hexarray[lfst] << hexarray[lscd] << hexarray[ltrd] << hexarray[lfth] << "-" << hexarray[hfst] << hexarray[hscd] << hexarray[htrd] << hexarray[hfth] <<
            ".\vmid.midVolLabel = " << mid.midVolLabel <<
            ".\vmid.midFileSysType = " << mid.midFileSysType <<
            ".\vmid->pmidInfoLevel = " << pmid->midInfoLevel <<
            ".\vmid->pmidVolLabel = " << pmid->midVolLabel <<
            ".\vmid->pmidFileSysType = " << pmid->midFileSysType <<
            ".\v(DWORD) pmid = " << (DWORD)pmid <<
            ".\vroakreg.reg_EDX = (DWORD) pmid = " << roakreg.reg_EDX  <<
            ".\vroakreg.reg_EBX = nDrive = " << roakreg.reg_EBX <<
            ".\vroakreg.reg_ECX = 0x866 = " << roakreg.reg_ECX <<
            ".\vroakreg.reg_Flags = 0x8000 = " << roakreg.reg_Flags <<
            ".\vroakreg.reg_EAX = " << roakreg.reg_EAX <<
            ".\v";

      cout << "\n     This program gets the media id of a cd at drive D:\\!\n\n     Function 440Dh of interrupt 21h is used!\n\n     The information is put into file c:\\temp\\dioc.doc!\n\n     This is not to be confused with the media in the FAT!\n\n     To get the media you could use function 1h of interrupt 25\n\n     with a boot structure, or offset 15h of a buffer!\n\n     (C) 1998 Inniea Publishing Company ROAK NOG!\n\n     ";
}
0

Featured Post

Technology Partners: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now