Jump to content

CD/DVD (El Torito) Boot image extractor


stormbreaker
 Share

Recommended Posts

;) Hello everyone. 3 days back, I came across "El Torito" Bootable CD-ROM Format Specification. I was able to write this simple script to extract Boot-Image from a CD/DVD/ISO file. Here is it:

#include <WinAPI.au3>

Global $nBytes
ConsoleWrite("Boot-Image X-tract (by MKISH)" & @crlf & @crlf & "USAGE: bootext.exe <PATH> <IMGNAME>")
If $CmdLine[0] = 0 then Exit
If NOT FileExists($CmdLine[1]) then Exit

$PATH = $CmdLine[1]
$RESULT = $CmdLine[2]

$hFile = _WinAPI_CreateFile("." & $PATH, 2,2)
$xBuffer = DllStructCreate("byte["& 4 & "]")
_WinAPI_SetFilePointer($hFile, 0x11*0x800 + 0x47)
_WinAPI_ReadFile($hFile, DllStructGetPtr($xBuffer), 4, $nBytes)
$sText1 = DllStructGetData($xBuffer, 1)

$dBuffer = DllStructCreate("byte["& 4 & "]")
_WinAPI_SetFilePointer($hFile, 0x800 * Int($sText1) + 0x20 + 0x8)
_WinAPI_ReadFile($hFile, DllStructGetPtr($dBuffer), 4, $nBytes)
$sText2 = DllStructGetData($dBuffer, 1)

$fBuffer = DllStructCreate("byte["& 1 & "]")
_WinAPI_SetFilePointer($hFile, 0x800 * Int($sText1) + 0x20 + 1)
_WinAPI_ReadFile($hFile, DllStructGetPtr($fBuffer), 1, $nBytes)
$sTextd = DllStructGetData($fBuffer, 1)

$pBuffer = DllStructCreate("byte["& 2 & "]")
_WinAPI_SetFilePointer($hFile, 0x800 * Int($sText1) + 0x20 + 0x6)
_WinAPI_ReadFile($hFile, DllStructGetPtr($pBuffer), 2, $nBytes)
$sText3 = SecCount()
$zBuffer = DllStructCreate("byte[" & $sText3 * 0x200 & "]")
_WinAPI_SetFilePointer($hFile, 0x800 * Int($sText2))
_WinAPI_ReadFile($hFile, DllStructGetPtr($zBuffer), $sText3 * 0x200, $nBytes)
$sText4 = DllStructGetData($zBuffer, 1)
FileWrite("" & $RESULT, $sText4)
_WinAPI_CloseHandle($hFile)

Func SecCount()
$fBuffer = DllStructCreate("byte["& 1 & "]")
_WinAPI_SetFilePointer($hFile, 0x800 * Int($sText1) + 0x20 + 1)
_WinAPI_ReadFile($hFile, DllStructGetPtr($fBuffer), 1, $nBytes)

Switch DllStructGetData($fBuffer, 1)
Case 0x00
Return Int(DllStructGetData($pBuffer, 1))

Case 0x01
Return Int(0x50 * 0x02 * 0x0F)

Case 0x02
Return Int(0x50 * 0x02 * 0x12)

Case 0x03
Return Int(0x50 * 0x02 * 0x24)
EndSwitch

EndFunc

Just compile this as CUI App. Hope it is of use to somebody. Useful suggestions are welcome.

EDIT:

The link is working now. A bugfix

Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

  • 5 months later...
FIX: Just bored so fixed this minor bug - the script sometimes printed NULL characters for CD images.

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

UPDATE: Now going command-line.... complete. Posted the command-line version (see 1st post)

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
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
 Share

×
×
  • Create New...