Connecting Tech Pros Worldwide Forums | Help | Site Map

VB - APP - Extract Block From Hex File?

Newbie
 
Join Date: Nov 2008
Posts: 12
#1: Nov 10 '08
Hello,

If possible can anyone show me how to extract a block of data from a hex file
i would like to extract from offset: E000 to simply the end of the file

thanks

Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#2: Nov 10 '08

re: VB - APP - Extract Block From Hex File?


Just like before


Expand|Select|Wrap|Line Numbers
  1. //
  2. //
  3. int Start = 0xE000;
  4. FileStream fs =new FileStream("SomeFile.Com");//you may need to use an overload to support seek
  5. int End = fs.Length;
  6. int lengthtoRead= End - Start;
  7. fs.Seek(Start, SeekOrigin.Begin);
  8. byte[] buff = new byte[lengthtoRead];
  9. int ActualAmountRead = fs.Read(buff,0,buff.Length);
  10. //now if ActualAmountRead is = lengthtoRead, then you have all your bytes in a nice byte[]
  11. //
  12. //
  13.  
Newbie
 
Join Date: Nov 2008
Posts: 12
#3: Nov 10 '08

re: VB - APP - Extract Block From Hex File?


ok but which bits am i to fill in etc...
+ i cant seem to get it to work lots of errors etc...

sorry about this
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#4: Nov 10 '08

re: VB - APP - Extract Block From Hex File?


I suggest you go read up on the FileStream object in MSDN for information about it.
What i posted was all relatively low math and code usage.
Reply