Solved

Determining disk transfer mode under XP

Posted on 2006-06-30
11
1,373 Views
Last Modified: 2010-05-18
How do I programatically determine the following properties for any fixed disks that are installed in a Windows XP machine:

1) The supportted transfer modes (PIO, UDMA).
2) The current transfer mode being used.

Looking for example source code in C, or at least a pointer in the right direction.

Thanks,
J
0
Comment
Question by:JamieR
  • 4
  • 4
  • 2
11 Comments
 
LVL 18

Assisted Solution

by:JoseParrot
JoseParrot earned 100 total points
Comment Utility
Hi,

This is done at register level. Not a simple API call. Changes will be effective after reboot.

At HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96A-E325-11CE-BFC1-08002BE10318}
in 0000 Make a new DWord named "DMA fix” and give it the value: 1
in 0001 Make a new DWord named: "DmaDetectionLevel” , value = 2
in 0002 Make a new DWord named "DmaDetectionLevel", value = 2

So, the program should set these values in the register, as usual. By changing this, you force xp to DMA, given it no chance to switch to PIO.

For deeper information on DMA settings, take a look at Microsoft's
DMA Mode for ATA/ATAPI Devices in Windows XP:
http://www.microsoft.com/whdc/device/storage/ide-dma.mspx
http://www.microsoft.com/whdc/hwdev/tech/storage/ide-dma.mspx

Hope it helps!

Jose
0
 
LVL 2

Expert Comment

by:kjpus
Comment Utility
It seems Jose's method will tell the OS to check DMA status but will not tell you what mode the controller is using. You need a few more registry keys to do this:

HKLM\System\CCS\Control\Class\{4D36E96A-E325-11CE-BFC1-08002BE10318}

0000 - IDE controller itself - reg_dword "EnableUDMA66", value 1.
0001 - primary channel,
0002 - secondary channel.

Both channels, dwords:
MasterDeviceTimingModeAllowed 0xFFFFFFFF
SlaveDeviceTimingModeAllowed 0xFFFFFFFF
UserMasterDeviceTimingModeAllowed 0xFFFFFFFF
UserSlaveDeviceTimingModeAllowed 0xFFFFFFFF
and
MasterDeviceTimingMode 0xFFFF or 0xFFFFF
SlaveDeviceTimingMode 0xFFFF or 0xFFFFF
or
for Multi-Word DMA Mode 2 and PIO4 (burners, very old HDDs...) - 0x0410
for Ultra ATA33 (CDROMs, DVDs, old HDDs...) - 0x2010
for Ultra ATA66 (just HDDs) - 0x8010
for Ultra ATA100 (modern HDDs) - 0x10010
for Ultra ATA133 (ultramodern HDDs) - 0x12010
0
 
LVL 18

Expert Comment

by:JoseParrot
Comment Utility
That's right! Good comment.
Jose
0
 
LVL 1

Author Comment

by:JamieR
Comment Utility
Thanks for your comments. However, it seems that this method forces XP to use DMA. I really need some way to determine the current mode without changing it - this functionality for a diagnosis application. :(
0
 
LVL 2

Expert Comment

by:kjpus
Comment Utility
Well, you just need to read the value in MasterDeviceTimingMode or SlaveDeviceTimingMode and determine whether it's PIO or DMA, and what which mode it is. It's easier than changing the mode programmatically.

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 1

Author Comment

by:JamieR
Comment Utility
Yes, this looks good. Is there a definitive list of the values for MasterDeviceTimingMode / SlaveDeviceTimingMode somewhere?

It appears that different bits represent different modes, but all the examples I have seen have two bits set. For instance,

MasterDeviceTimingMode = 0x10010 (10000000000010000). This implies UDMA Mode 5 (ATA100). It seems bit 16 represents UDMA mode 5, but why is bit 4 also set? Microsoft don't seem to publish this information.

Thanks.
0
 
LVL 2

Expert Comment

by:kjpus
Comment Utility
0
 
LVL 1

Author Comment

by:JamieR
Comment Utility
Thanks for your help. I've sucessfully been able to decode the bitmask and determine the transfer mode for each entry.

However, I have one last problem. I'm having trouble correlating this information with the actual drives installed in the machine. For example, one machine I have tested has the following informaton under HKLM\DEVICEMAP\Scsi\...

Port 0, Bus 0, TID 0, LID 0
                Type: DiskPeripheral
      Identifier: WDC WD200EB-00CPF0
      Driver: atapi
      DMAEnabled: 1

Port 1, Bus 0, TID 1, LID 0
                Type: CdRomPeripheral
      Identifier: HL-DT-ST CD-ROM GCR-8520B
      Driver: atapi
      DMAEnabled: 0

This implies the machine only has one HD and one CD-ROM.

Now, on the same machine, here's the information under HKLM\System\CCS\Control\Class\{4D36E96A-E325-11CE-BFC1-08002BE10318}

[0000]      DriverDesc: VIA Bus Master IDE Controller
      Driver Version: 5.1.3597.0
      Driver Date: 7-1-2001
      Driver Provider: Microsoft

[0001]      DriverDesc: Secondary IDE Channel
      Driver Version: 5.1.2600.1106
      Driver Date: 7-1-2001
      Driver Provider: Microsoft
      Master Transfer Mode: (unknown) (0x0)
      Slave Transfer Mode: PIO Mode 4 (0x10)

[0002]      DriverDesc: Primary IDE Channel
      Driver Version: 5.1.2600.1106
      Driver Date: 7-1-2001
      Driver Provider: Microsoft
      Master Transfer Mode: UDMA Mode 5 (ATA100) (0x10010)
      Slave Transfer Mode: (unknown) (0x0)

[0003]      DriverDesc: VIA Bus Master IDE Controller
      Driver Version: 5.1.2600.2180
      Driver Date: 7-1-2001
      Driver Provider: Microsoft

[0004]      DriverDesc: Primary IDE Channel
      Driver Version: 5.1.2600.2180
      Driver Date: 7-1-2001
      Driver Provider: Microsoft
      Master Transfer Mode: UDMA Mode 4 (ATA66) (0x8010)
      Slave Transfer Mode: (unknown) (0x0)

[0005]      DriverDesc: Secondary IDE Channel
      Driver Version: 5.1.2600.2180
      Driver Date: 7-1-2001
      Driver Provider: Microsoft
      Master Transfer Mode: (unknown) (0x0)
      Slave Transfer Mode: PIO Mode 4 (0x10)

Unfortunately this PC is remotely located, so I can't determine the actual hardware configuration.

1) Why are there more entries for transfer modes than there are hardware devices?
2) How do I work out which devices are installed on which port (primary / secondary and master / slave)?
3) How do I increase the points awarded for this question so I can reward you for all your hard work?! :)

Thanks.

J
0
 
LVL 2

Accepted Solution

by:
kjpus earned 400 total points
Comment Utility
I don't know why you have two sets of controllers with different transfer mode. Might be some other devices or vitual drive?

There must be an easier way to get the disk drive / IDE channel mapping. But I only know how to get that using WMI. First, query WIN32_CDROMDRIVE AND WIN32_DISKDRIVE to get all drives on the system. You may need to filter out things like USB disk. Then query WIN32_IDEControllerDevice and look into the dependant field. That will give you wheather the disk is on primary or secondary IDE channel. Slave/Master can be determined by SCSILogicalUnit of the first query.

I'm glad I can help.

0
 
LVL 1

Author Comment

by:JamieR
Comment Utility
I ended up using a combination of things - the registry, WMI (SELECT * FROM CIM_MediaAccessDevice) and various DeviceIoControl calls (IOCTL_SCSI_GET_ADDRESS, SMART_SEND_DRIVE_COMMAND and DFP_GET_VERSION).

Thanks to everyone for their assistance.

Jamie
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This is about my first experience with programming Arduino.
If you don't know how to downgrade, my instructions below should be helpful.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

763 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

7 Experts available now in Live!

Get 1:1 Help Now