/** Non-parsing constructor. The table is created to be at least one byte long and having a NUL character as the first byte. */ void SgAsmElfStrtab::ctor() { ROSE_ASSERT(get_container()); if (get_container()->get_size()==0) get_container()->set_size(1); p_dont_free = create_storage(0, false); }
static void test_olestream(void) { HRESULT hr; const CLSID non_existent_class = {0xa5f1772f, 0x3772, 0x490f, {0x9e, 0xc6, 0x77, 0x13, 0xe8, 0xb3, 0x4b, 0x5d}}; IOleObject *ole_obj; IPersistStorage *persist; IStorage *stg; IStream *stm; static const WCHAR olestream[] = {1,'O','l','e',0}; ULONG read; ole_stream_header_t header; hr = create_storage(&stg); ok(hr == S_OK, "got %08x\n", hr); hr = IStorage_OpenStream(stg, olestream, NULL, STGM_SHARE_EXCLUSIVE | STGM_READ, 0, &stm); ok(hr == STG_E_FILENOTFOUND, "got %08x\n", hr); hr = OleCreateDefaultHandler(&non_existent_class, 0, &IID_IOleObject, (void**)&ole_obj); ok(hr == S_OK, "got %08x\n", hr); hr = IOleObject_QueryInterface(ole_obj, &IID_IPersistStorage, (void**)&persist); ok(hr == S_OK, "got %08x\n", hr); hr = IPersistStorage_InitNew(persist, stg); ok(hr == S_OK, "got %08x\n", hr); hr = IStorage_OpenStream(stg, olestream, NULL, STGM_SHARE_EXCLUSIVE | STGM_READ, 0, &stm); ok(hr == S_OK, "got %08x\n", hr); hr = IStream_Read(stm, &header, sizeof(header), &read); ok(hr == S_OK, "got %08x\n", hr); ok(read == sizeof(header), "read %d\n", read); ok(header.version == 0x02000001, "got version %08x\n", header.version); ok(header.flags == 0x0, "got flags %08x\n", header.flags); ok(header.link_update_opt == 0x0, "got link update option %08x\n", header.link_update_opt); ok(header.res == 0x0, "got reserved %08x\n", header.res); ok(header.moniker_size == 0x0, "got moniker size %08x\n", header.moniker_size); IStream_Release(stm); IPersistStorage_Release(persist); IOleObject_Release(ole_obj); IStorage_Release(stg); }
/** Parses the string table. All that actually happens at this point is we look to see if the table begins with an empty * string. */ SgAsmElfStrtab * SgAsmElfStrtab::parse() { SgAsmGenericStrtab::parse(); ROSE_ASSERT(get_container()); if (get_container()->get_size()>0) { unsigned char first_byte; get_container()->read_content_local(0, &first_byte, 1); if (first_byte=='\0') { if (p_dont_free) { ROSE_ASSERT(0==p_dont_free->get_offset()); } else { p_dont_free = create_storage(0, false); } } else if (p_dont_free) { p_dont_free = NULL; } } return this; }