Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strip OLE header information (MS Access / SQL Server)

Tags:

c++

ms-access

ole

I have a C++ application that needs to support binary database content (images, etc). When using MS Access or MS SQL Server this data is wrapped inside an OLE object. How do I strip this OLE header information? Note that I can't just look for the beginning of a specific tag as the content can be png, jpg and a whole heap of other formats. Should I use something like COleDataObject?

like image 875
Randy Voet Avatar asked May 09 '26 23:05

Randy Voet


1 Answers

Using MS Access 2007 (I need to test other MS databases) the format seems to be:

84 bytes
file name + \0
full path + \0
5 bytes + [2] bytes (the third byte of those five bytes)
temp path + \0
4 bytes
actual data (if not using a link to the file)

So far I simply parse and strip the part before the actual data, but I'm still wondering if there's no way to use something like COleDataSource to help parse this information more robustly.

Also note that this format only applies for generic content (start tag 0x15 0x1c 0x32). When using bitmaps (start tag 0x15 0x1c 0x2f) there's a fixed offset of 78 bytes and when using PowerPoint (start tag 0x15 0x1c 0x34) there's a fixed offset of 95 bytes.

like image 167
Randy Voet Avatar answered May 12 '26 12:05

Randy Voet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!