static void do_read (void) { char *handle; int length; MateVFSHandle *from_handle; MateVFSResult result; MateVFSFileSize bytes_read; guint8 *data; handle = get_handle (); length = get_int (); if (length < 0) { fprintf (vfserr, "Can't read %d bytes\n", length); return; } from_handle = lookup_file (handle); if (!from_handle) return; data = g_malloc (length); result = mate_vfs_read (from_handle, data, length, &bytes_read); if (show_if_error (result, "read ", handle)) return; ms_ole_dump (data, bytes_read, 0); }
static void do_dump (void) { char *from; MateVFSHandle *from_handle; MateVFSResult result; guint32 offset; from = get_fname (); result = mate_vfs_open (&from_handle, from, MATE_VFS_OPEN_READ); if (show_if_error (result, "open ", from)) return; for (offset = 0; 1; ) { MateVFSFileSize bytes_read; guint8 data [1024]; result = mate_vfs_read (from_handle, data, 1024, &bytes_read); if (show_if_error (result, "read ", from)) return; if (bytes_read == 0) break; ms_ole_dump (data, bytes_read, offset); offset += bytes_read; } result = mate_vfs_close (from_handle); if (show_if_error (result, "close ", from)) return; }
static void hammer_stream (MsOleStream *stream, gboolean write) { int i, lp; guint8 *mem; #define BLOCK_LEN 1000 #define NUM_BLOCKS 7100 for (lp = 0; lp < NUM_BLOCKS; lp++) { mem = g_malloc (BLOCK_LEN); if (!write) g_assert (stream->read_copy ( stream, mem, BLOCK_LEN)); for (i = 0; i < BLOCK_LEN; i++) { guint8 sig; sig = 0; //(i << 3) ^ (lp); if (write) mem [i] = sig; else { if (i == 0 && lp == 0) { /* Ok, this dump shows how: Old value = 0 '\000' New value = 154 '\232' 0x4001bf17 in write_bb (f=0x804e638) at ms-ole.c:916 916 SET_BBD_LIST (f, lp, blk); (gdb) bt #0 0x4001bf17 in write_bb (f=0x804e638) at ms-ole.c:916 #1 0x4001e55f in ms_ole_cleanup (f=0x804e638) at ms-ole.c:1538 #2 0x4001f349 in ms_ole_destroy (ptr=0xbffff6f4) at ms-ole.c:1873 #3 0x0804b757 in do_regression_tests () at test-ole.c:953 #4 0x0804b9ad in main (argc=2, argv=0xbffff78c) at test-ole.c:985 Corrupt the data in the stream - libole2 does not work with large files. */ ms_ole_dump (mem, 64); } if (i < 32 && lp == 0) continue; if (mem [i] != sig) g_error ("Mismatch 0x%x 0x%x", mem [i], sig); } } if (write) stream->write (stream, mem, BLOCK_LEN); } }
static void do_dump (MsOle *ole) { char *ptr; MsOleStream *stream; guint8 *buffer; gchar *tname; ptr = arg_data [arg_cur++]; if (!ptr) { printf ("Need a stream name\n"); return; } tname = g_strdup (ptr); if (strcmp(tname, "SummaryInformation") == 0) { printf ("Changing name to prepend 005\n"); tname = "\05SummaryInformation"; } if (strcmp(tname, "DocumentSummaryInformation") == 0) { printf ("Changing name to prepend 005\n"); tname = "\05DocumentSummaryInformation"; } if (test_stream_open (&stream, ole, cur_dir, tname, 'r') != MS_OLE_ERR_OK) { printf ("Error opening '%s'\n", ptr); return; } buffer = g_malloc (stream->size); stream->read_copy (stream, buffer, stream->size); printf ("Stream : '%s' length 0x%x\n", ptr, stream->size); if (buffer) ms_ole_dump (buffer, stream->size); else printf ("Failed read\n"); ms_ole_stream_close (&stream); }
static void do_biff_raw (MsOle *ole) { char *ptr; MsOleStream *stream; ptr = arg_data[arg_cur++]; if (!ptr) { printf ("Need a stream name\n"); return; } if (test_stream_open (&stream, ole, cur_dir, ptr, 'r') != MS_OLE_ERR_OK) { printf ("Error opening '%s'\n", ptr); return; } { guint8 data[4], *buffer; buffer = g_new (guint8, 65550); while (stream->read_copy (stream, data, 4)) { guint32 len=MS_OLE_GET_GUINT16(data+2); /* printf ("0x%4x Opcode 0x%3x : %15s, length 0x%x (=%d)\n", stream->position, MS_OLE_GET_GUINT16(data), get_biff_opcode_name (MS_OLE_GET_GUINT16(data)), len, len);*/ printf ("Opcode 0x%3x : %15s, length 0x%x (=%d)\n", MS_OLE_GET_GUINT16(data), get_biff_opcode_name (MS_OLE_GET_GUINT16(data)), len, len); stream->read_copy (stream, buffer, len); ms_ole_dump (buffer, len); buffer[0]=0; buffer[len-1]=0; } ms_ole_stream_close (&stream); } }