cole is used to access Microsoft OLE's Structured Storage and Compound Files. Specifically, cole extracts the structures named streams from a Structured Storage file. Each stream is written to a new file. A dynamic tree in memory is created to store the name of the streams and the name of the files where they are written, besides other information.
cole doesn't know the structure of each stream, it only extract them to new files. If you want to know the structure of a particular stream, you can read the Microsoft's documentation, or seach in Wotsit. Using that documentation, you can read the extracted streams searching for the actual information.
cole has two major functions: OLEdecode and OLEcode. The first takes an Structured Storage file and divide it into streams. The last takes streams and generate an Structured Storage file (the stream_list structure and the streams itself must be valid, but cole doesn't provide functions to validate them by now).
#include <cole/cole.h> |
int OLEdecode
(char *OLEfilename, pps_entry **stream_list, U32 *root, U16 max_level);This function extracts the streams of the file wich name is OLEfilename and generate a array of pps_entry's named stream_list. The array make a tree (ie. each pps_entry have fields such as next for brothers and dir for children pps_entry's) with root pps_entry root, and this tree stores the stream's names, the names of the temporal files where the streams were written and other information. Only streams with level minor than or equal to max_level are extracted, but all streams are extracted if max_level is zero.
OLEdecode returns one of the following numbers:
0. Sucess. |
4. Couldn't open OLEfilename file (can use perror(3)). |
8. OLEfilename file seems to be a plain text file, not a Structured Storage file. |
9. OLEfilename is a binary file, but it's not a Structured Storage file. |
5. Error reading from file, means OLEfilename file has a faulty Structured Storage format. |
6. Error removing temporal files. |
7. Error creating temporal files. |
10. Error allocating memory, there's no more memory. |
#include <stdio.h> #include <cole/cole.h> struct pps_block { char name[0x20]; /* name of the stream */ U8 type; /* type of this pps: 5 == root of stream_list, 1 == dir, 2 == stream */ char filename[L_tmpnam]; /* temporal file name where the stream were written, valid only if type == 2 */ U32 size; /* the size of the temporal file, valid only if type == 2 */ U32 next; /* next pps_entry in this directory, brother pps */ U32 dir; /* pps_entry children, valid only if type != 2 */ U16 level; /* level of the pps in the tree */ U32 seconds1; /* time creation */ U32 seconds2; /* time creation */ U32 days1; /* date creation */ U32 days2; /* date creation */ /* ... */ }; typedef struct pps_block pps_entry; |
pps_entry structure describes one extrated stream.
#include <cole/cole.h> |
int OLEcode
(const char *OLEfilename, int trunc, pps_entry *stream_list, U32 root);This function takes the stream_list tree (which have a root pps_entry root and describes some existing valid streams) and generate a Structured Storage file named OLEfilename. If trunc is zero and OLEfilename exists, returns 2 (see below), in any other case OLEfilename will be created or recreated as needed.
OLEcode returns one of the following numbers:
0. All goes OK. |
1. Error writting in OLEfilename (can use perror(3)). |
2. trunc is zero and OLEfilename exist. |
3. Can't create OLEfilename (can use perror(3)). |
10. Error allocating memory, there's no more memory. |
11. Error reading stream's temporal files. |
12. Error reading stream_list, it's broken. |
#include <cole/cole.h> |
int freeOLEtree
(pps_entry *stream_list);You must call this function at the end of processing the streams, to free memory and remove the stream files.
#include <cole/cole.h> |
void verbosePPSTree
(pps_entry *stream_list, U32 root, int level);You can use this function to display the tree of a Structured Storage file.