Jump to content
Sign in to follow this  
skippynz

Reading the header of CD/DVD media

Recommended Posts

skippynz

Hi everyone,

Its been a while since i've been on here but couldnt think of a better place to get answers to my questions :)

I have to try and read in the header information of a CD or DVD in binary.

Basically i want to catch the first 880 bytes so i can get some info about the CD without having to open it up in a forensic application.  the 880 bytes below will tell me the date that the cd was created, the software used to burn the cd, and the volume name if it has one.

If someone can point in the direction of reading in the header i can work out the rest but i got stumped right out the gate. 

01 43 44 30 30 31 01 00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 57 49 4C 45 59 50 55 42 4C 49 53 48 49 4E 47 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 00 00 00 00 00 00 00 00 A0 D0 01 00 00 01 D0 A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 01 01 00 00 01 00 08 08 00 26 04 00 00 00 00 04 26 58 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 22 00 13 00 00 00 00 00 00 13 00 08 00 00 00 00 08 00 6D 09 19 0C 08 00 F0 02 00 00 01 00 00 01 01 00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4E 45 52 4F 20 42 55 52 4E 49 4E 47 20 52 4F 4D 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 32 30 30 39 30 39 32 35 31 32 30 38 30 30 30 30 F0 32 30 30 39 30 39 32 35 31 32 30 3830 30 30 30 30 00 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30

PS im dont want anyone to write the script for me just a gentle nudge in the right direction would be great.

Cheers

Skip

Share this post


Link to post
Share on other sites
BrewManNH

If you know what that information posted is supposed to say, could you post that so we know what it is we're looking at? Because otherwise, if you don't know what is supposed to be where, I'm sure a google search would tell you what you're looking for.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
skippynz

i guess that'll help aye - attached an image of what that all says

the second image is what im wanting to find from that 880 bytes of data

post-4931-0-87091000-1376453236_thumb.pn

post-4931-0-68271800-1376453358_thumb.pn

Edited by skippynz

Share this post


Link to post
Share on other sites
kylomas

skippynz,

You might try something like this

#include <String.au3>

$str = '01 43 44 30 30 31 01 00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 57 49 4C 45 59 50 55 42 4C 49 53 48 49 4E 47 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 00 00 00 00 00 00 00 00 A0 D0 01 00 00 01 D0 A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 01 01 00 00 01 00 08 08 00 26 04 00 00 00 00 04 26 58 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 22 00 13 00 00 00 00 00 00 13 00 08 00 00 00 00 08 00 6D 09 19 0C 08 00 F0 02 00 00 01 00 00 01 01 00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4E 45 52 4F 20 42 55 52 4E 49 4E 47 20 52 4F 4D 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 32 30 30 39 30 39 32 35 31 32 30 38 30 30 30 30 F0 32 30 30 39 30 39 32 35 31 32 30 38 30 30 30 30 30 00 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30'

local $tstr = stringregexpreplace($str,'00|01|02|03|04|05|06|07|07|09|10|11|12|13|14|15|16|17|18|19|20| ','')

ConsoleWrite(_hextostring($tstr) & @LF)

kylomas

edit: corrected regexp pattern

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
skippynz

Hi and thanks for the reply - i may not have been clear - that information is what i need to get from a CD so stage 2 really

Right now i need to work out how to get that info when I put a CD in the tray, open my app to read in the first 880 bytes and then i can work out the text later.

hopefully that helps?

cheers

Share this post


Link to post
Share on other sites
kylomas

My fault, did'nt read the thead thoroughly..


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
skippynz

nah i think that was my fault :)

Share this post


Link to post
Share on other sites
kylomas

skippynz,

This is a way to read raw data from a DASD device.  I got this somewhere off the forum but do not remember where. 

#RequireAdmin
#AutoIt3Wrapper_UseX64=n
#include <WinAPI.au3>

$sFileName = "\\.\PhysicalDrive0";
$iCreation = 2; OPEN_EXISTING
$iAccess = 2; GENERIC_READ
$iShare = 2+4; FILE_SHARE_READ + FILE_SHARE_WRITE

$hFile = _WinAPI_CreateFile($sFileName, $iCreation, $iAccess, $iShare)
If @error Or $hFile = Ptr(0) Then
$str = "Could not open file "&$sfilename&@CRLF
$str &= "Error: "&@error&@CRLF
$str &= "Handle: "&$hFile
MsgBox(0,"Error: _WinAPI_CreateFile",$str)
Exit
EndIf

MsgBox(0,"Success: _WinAPI_CreateFile ","Handle: "&$hFile)

_WinAPI_SetFilePointer($hFile,0); Beginning of file
If @error Then
MsgBox(0,"Error: _WinAPI_SetFilePointer",StringFormat("Could not move pointer. (Error %d)\n",@error))
EndIf

Global $nBytesReceived
$tBuffer = DllStructCreate("byte[512]")

_WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer,1), 512, $nBytesReceived)
If @error Then
MsgBox(0,"Error: _WinAPI_ReadFile",StringFormat("Could not read file. (Error %d)\n",@error))
EndIf
If $nBytesReceived<512 Then
MsgBox(0,"Error: _WinAPI_ReadFile",StringFormat("Only %d bytes read.\n",$nBytesReceived))
Else
    MsgBox(0,"Results",Hex(DllStructGetData($tBuffer,1)))
EndIf

Hope it helps...

kylomas

edit: and of course, point at the right physical device

edit2:  Hmmm..playing around with this and it appears that a CD drive is not a physical device in this context...

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
skippynz

#RequireAdmin
#AutoIt3Wrapper_UseX64=n
#include <WinAPI.au3>

$sFileName = "\\.\Z:";
$iCreation = 2; OPEN_EXISTING
$iAccess = 2; GENERIC_READ
$iShare = 2+4; FILE_SHARE_READ + FILE_SHARE_WRITE

$hFile = _WinAPI_CreateFile($sFileName, $iCreation, $iAccess, $iShare)
If @error Or $hFile = Ptr(0) Then
$str = "Could not open file "&$sfilename&@CRLF
$str &= "Error: "&@error&@CRLF
$str &= "Handle: "&$hFile
MsgBox(0,"Error: _WinAPI_CreateFile",$str)
Exit
EndIf

MsgBox(0,"Success: _WinAPI_CreateFile ","Handle: "&$hFile)

Global $nBytesReceived
$tBuffer = DllStructCreate("byte[2048]")

_WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer,1), 2048, $nBytesReceived)
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$tBuffer' & @lf & @lf & 'Return:' & @lf & $tBuffer) ;### Debug MSGBOX


If @error Then
MsgBox(0,"Error: _WinAPI_ReadFile",StringFormat("Could not read file. (Error %d)\n",@error))
EndIf
If $nBytesReceived<2048 Then
MsgBox(0,"Error: _WinAPI_ReadFile",StringFormat("Only %d bytes read.\n",$nBytesReceived))
Else
MsgBox(0,"Success: _WinAPI_ReadFile",StringFormat("Read %d bytes.\n",$nBytesReceived))
EndIf

_WinAPI_CloseHandle($hFile)
$sText = BinaryToString(DllStructGetData($tBuffer, 1))

;~ $sText = Hex(DllStructGetData($tBuffer,1,2),2);Just the first byte
MsgBox(0,"Result",$sText) 

Thanks for that - i have it partially working (i think).  says it has read in the 2048 bytes (default for cd and dvd's i think) but now i need to see the content - i will have a play around today and see what else i can do to get this thing working

Edited by skippynz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×