Jump to content



Photo

CD/DVD (El Torito) Boot image extractor


  • Please log in to reply
3 replies to this topic

#1 MKISH

MKISH

    EXAM Time...

  • Active Members
  • PipPipPipPipPipPip
  • 534 posts

Posted 20 April 2012 - 05:07 AM

;) 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:

AutoIt         
#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, 22 October 2012 - 05:04 PM.

  • JScript likes this

Get DROPBOX - simplify your life...

:::::Dear LOL and Hmmmm... thank you for always being there, when I have nothing else to say... - great words by the author of this post:::::






#2 MKISH

MKISH

    EXAM Time...

  • Active Members
  • PipPipPipPipPipPip
  • 534 posts

Posted 19 October 2012 - 04:35 AM

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

Get DROPBOX - simplify your life...

:::::Dear LOL and Hmmmm... thank you for always being there, when I have nothing else to say... - great words by the author of this post:::::


#3 JScript

JScript

    Goodbye everybody, I got tired of this system adopted here!

  • Active Members
  • PipPipPipPipPipPip
  • 1,062 posts

Posted 19 October 2012 - 05:10 AM

It will be very useful, thanks 4 sharing! :)

JS
http://notebook.forumais.com (Forum Maintenance Notebooks and Desktop)http://autoitbrasil.com/ (AutoIt v3 Brazil!!!)
Spoiler

Posted Image Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!       


#4 MKISH

MKISH

    EXAM Time...

  • Active Members
  • PipPipPipPipPipPip
  • 534 posts

Posted 19 October 2012 - 09:34 AM

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

Get DROPBOX - simplify your life...

:::::Dear LOL and Hmmmm... thank you for always being there, when I have nothing else to say... - great words by the author of this post:::::





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users