Click here to Skip to main content
13,350,708 members (75,093 online)
Click here to Skip to main content
Add your own
alternative version


19 bookmarked
Posted 1 Aug 2006

How to retrieve DVD region information

, 1 Aug 2006
Rate this:
Please Sign up or sign in to vote.
An article showing you how to programmatically retrieve DVD region information

Sample Image - mydvdregion.jpg


I've been playing with DVDs recently and stumbled upon many tools for DVD backup, DVD region-free tools, and such. In this article we are going to demonstrate how to programmatically retrieve the DVD's region information.

What is DVD Region?

In short it is a mechanism encoded both in DVD players and on DVD discs dictating if a DVD player can play a certain DVD disk. The DVD region in the DVD player is stored inside the hardware and cannot be reset if windows is re-installed or the player was moved to another PC. Some ways to circumvent this is to update your player's firmware and remove the DVD region support from it. The DVD region in the DVD movie is stored inside one of its IFO file.

From [1] we have the following regions:

Region CodeRegion Name
0No Region Coding
1United States of America, Canada
2Europe, including France, Greece, Turkey, Egypt, Arabia, Japan and South Africa
3Korea, Thailand, Vietnam, Borneo and Indonesia
4Australia and New Zealand, Mexico, the Caribbean, and South America
5India, Africa, Russia and former USSR countries
6Peoples Republic of China
8Airlines/Cruise Ships
9Expansion (often used as region free)

DVD region has been defined extensively on the net please check this article's references.

Technical prerequisites

In order to read information from the DVD drive we are going to issue SCSI commands to the hardware itself (DVD player). For simplicity, this article's code do not use ASPI instead uses Microsoft's SPTI (SCSI Pass Through Interface) to talk with the hardware. The SCSI commands issued to the hardware are standards and can be found on the net [3].

Using SPTI to issue SCSI commands

Sending SCSI / CDBs (command descriptor blocks) to the device is very simple with the SPTI interface and consists of only setting up the correct block and sending it.

  1. Open the device, say: \\.\C:\
  2. Prepare a SCSI_PASS_THROUGH_DIRECT structure
  3. Prepare the CDB (Command Descriptor Block), a structure used to select which command and pass appropriate parameters ([4] [6])
  4. Prepare the return or data buffer (buffer returned after the command is issued)
  5. Use DeviceIoControl() with IOCTL code value of IOCTL_SCSI_PASS_THROUGH_DIRECT (value 0x4D014) to issue the call
  6. Interpret the results

Reading the DVD region

After reading in [5] we realize that we need to send to the DVD the SCSI operation code SCSIOP_REPORT_KEY (value 0xA4) with some specific parameters.

The REPORT_KEY can be used to do many things, but we only need to read the DVD region information, for that we fill the "CDB_REPORT_KEY" as:

AllocationLength = sizeof(REPORT_KEY_DATA_RPC_STATE)
AGID = 0

After the command is issued, a REPORT_KEY_DATA_RPC_STATE ([5] page 533) will be filled with the region information.

Quoted and paraphrased from [5]:

# of Vendor Resets Available = is a count down counter that indicates the number of times that the vendor may reset the region. The manufacturer of the Drive sets this value to 4 and the value is decremented each time the vendor clears the Drive’s region. When this value is zero, the vendor may no longer clear the Drive's region.

# of User Controlled Changes Available = is a count down counter that indicates the number of times that the user may set the region. This value is initially 5.

The Region Mask returns a value that specifies the Drive Region in which the Drive is located. Once the Drive Region has been set, the Drive shall be located in only one region. Each bit represents one of eight regions. If a bit is cleared in this field, the disc may be played in the corresponding region. If a bit is set in this field, the disc may not be played in the corresponding region. Only one bit can be cleared.

Example: if region mask is 0xFE which is 11111110 in binary means that bit1 is cleared thus region 1 is set.

RPC Scheme specifies the type of Region Playback Controls being used by the Drive.
We currently have two schemes RPC1 which do not enforce region playback control, and RPC2 which enforces the region playback control.

The code

void print_region_info(HANDLE device)
  static char *region_names[] = 
   "United States of America, Canada", // Region 1
   "Europe, including France, Greece, Turkey, Egypt, Arabia, "
"Japan and South Africa", // 2
   "Korea, Thailand, Vietnam, Borneo and Indonesia", // 3
   "Australia and New Zealand, Mexico, the Caribbean, and South America", // 4
   "India, Africa, Russia and former USSR countries", // 5
   "Peoples Republic of China", // 6
   "Unused", // 7
   "Airlines/Cruise Ships" // 8

  static char *region_set[] =
    "No region set", // 0
    "Region set", // 1
    // 2
    "Drive region is set. Additional restrictions required to make changes",
    "Region set permanently, but may be reset by vendor", // 3


  CDB_REPORT_KEY report = {0};

  report.OperationCode = SCSIOP_REPORT_KEY;
  report.AllocationLength = sizeof(REPORT_KEY_DATA_RPC_STATE);
  report.AGID = 0;
  report.KeyFormat = KEY_FORMAT_RPC_STATE;

  if (!carry_cdb(device, &report, sizeof(report), ®ion, sizeof(region)))
    printf("Could not get region info!\n");

  unsigned char region_code = ~region.region_mask;
  int i;

  char *region_name = "No Region Coding";
  for (i=7;i>=0;i--)
    if ( (1 << i) & region_code) 
      region_name = region_names[i];

    "Region Information:\n"
    "Vendor changes: %d\n"
    "User changes: %d\n"
    "Region name: %s\n"
    "Type code: %s\n",

How to programmatically set DVD region?

I did not try it, but apparently one has to issue a SEND_KEY command with appropriate structures. Check [5] page 587.


Hope you learned a little from this article and got pointers about where to look further.
If I find interest and time, perhaps I will extend my knowledge beyond this and write more articles. Meanwhile, happy coding.


  • [1]
  • [2]
  • [3]
  • [4]
  • [5] [3] / SCSI Multi-Media Commands – 5 (MMC-5) / mmc5r03a.pdf
  • [6] DDK / SCSI_PASS_THROUGH documentation


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Elias Bachaalany
Web Developer
United States United States
Elias (aka lallousx86, @0xeb) has always been interested in the making of things and their inner workings.

His computer interests include system programming, reverse engineering, writing libraries, tutorials and articles.

In his free time, and apart from researching, his favorite reading topics include: dreams, metaphysics, philosophy, psychology and any other human/mystical science.

Former employee of Hex-Rays (the creators of IDA Pro), was responsible about many debugger plugins, IDAPython project ownership and what not.

Elias currently works at Microsoft as a software security engineer.

More articles and blog posts can be found here:


You may also be interested in...


Comments and Discussions

QuestionMedia Code Pin
Pascal Damman22-Jul-11 0:46
memberPascal Damman22-Jul-11 0:46 
AnswerRe: Media Code Pin
Elias Bachaalany22-Jul-11 1:29
memberElias Bachaalany22-Jul-11 1:29 
GeneralMessage Closed Pin
26-May-10 14:07
memberJiggawha26-May-10 14:07 
QuestionDVD TYPE Pin
jxy3331619-Sep-08 6:38
memberjxy3331619-Sep-08 6:38 
QuestionPlease tell me how to set the DVD region by C++ coding Pin
jxy3331619-Sep-08 6:36
memberjxy3331619-Sep-08 6:36 
GeneralDVD region Set Pin
argo77717-Dec-07 6:53
memberargo77717-Dec-07 6:53 
i'm trying to set the dvd region through a SEND_KEY CDB. Unfortunately until now i had no luck.
The DeviceIoControl returns correctly and the program seems to "do something" for a couple of seconds but the region does not change.
Did you have more luck?

if necessary i can give more details of my attempt.
GeneralSPTI (SCSI Pass Through Interface) and changer Pin
fredguo29-Jan-07 9:28
memberfredguo29-Jan-07 9:28 
GeneralRe: SPTI (SCSI Pass Through Interface) and changer Pin
lallous31-Jan-07 5:32
memberlallous31-Jan-07 5:32 
GeneralCD/DVD Configuration Pin
rbrunton25-Aug-06 11:05
memberrbrunton25-Aug-06 11:05 
GeneralRe: CD/DVD Configuration Pin
lallous1-Sep-06 0:12
memberlallous1-Sep-06 0:12 
Joke Pin 2:15
suss 2:15 
GeneralManaged wrapper request Pin
lallous3-Aug-06 11:10
memberlallous3-Aug-06 11:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 1 Aug 2006
Article Copyright 2006 by Elias Bachaalany
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid