|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionI'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:
DVD region has been defined extensively on the net please check this article's references. Technical prerequisitesIn 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 commandsSending 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.
Reading the DVD regionAfter reading in [5] we realize that we need to send to the DVD the SCSI operation code OperationCode = SCSIOP_REPORT_KEY
AllocationLength = sizeof(REPORT_KEY_DATA_RPC_STATE)
AGID = 0
KeyFormat = KEY_FORMAT_RPC_STATE
After the command is issued, a 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. The codevoid 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 }; REPORT_KEY_DATA_RPC_STATE region = {0}; 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"); return; } 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]; break; } } printf( "Region Information:\n" "-------------------\n" "Vendor changes: %d\n" "User changes: %d\n" "Region name: %s\n" "Type code: %s\n", region.nb_vendor_resets, region.nb_user_changes, region_name, region_set[region.type_code] ); } How to programmatically set DVD region?I did not try it, but apparently one has to issue aSEND_KEY command with appropriate structures. Check [5] page 587.
ConclusionsHope 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. References
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||