bool hasObjectKey(intptr_t aIntObjectKey) { return (objectKey()==aIntObjectKey); };
Object *Object::parseObject( ResourceManager *resMgr, Module *module, SSIZE_T &off ) { Object *obj; ObjectLocation loc; BYTE buf[BIOP_MAX_HEADER]; SSIZE_T offset = 0; SIZE_T len = module->read( off, buf, BIOP_MAX_HEADER ); if (len < BIOP_MAX_HEADER) { printf( "[dsmcc::Object] Warning: Not enough buffer: len=%ld, offset=%ld\n", len, offset ); return NULL; } DWORD magic = RDW(buf,offset); if (magic != BIOP_MAGIC) { printf( "[dsmcc::Object] Warning: Bad magic number: magic=%x, found=%lx\n", BIOP_MAGIC, magic ); return NULL; } WORD biopVersion = RW(buf,offset); if (biopVersion != BIOP_VER) { printf( "[dsmcc::Object] Warning: Invalid version\n" ); return NULL; } BYTE byteOrder = RB(buf,offset); if (byteOrder) { printf( "[dsmcc::Object] Warning: Invalid byte order\n" ); return NULL; } BYTE msgType = RB(buf,offset); if (msgType) { printf( "[dsmcc::Object] Warning: Invalid type\n" ); return NULL; } // Check BIOP message size DWORD msgSize = RDW(buf,offset); if (module->size()-off-offset < msgSize) { printf( "[dsmcc::Object] Warning: Not enough bytes for BIOP message: msgSize=%ld, rest%ld\n", msgSize, module->size()-off-offset ); return NULL; } // 12 bytes parsed = BIOP_MIN_HEADER offset += objectKey( buf+offset, len-offset, loc.keyID ); DWORD objectKindLen = RDW(buf,offset); if (objectKindLen != 4) { printf( "[dsmcc::Object] Warning: Invalid object kind\n" ); return NULL; } // Chapter 11: The downloadID field of the DownloadDataBlock messages shall have the same value // as the carouselID field of the U-U Object Carousel loc.carouselID = module->downloadID(); loc.moduleID = module->id(); DWORD objectKind = RDW(buf,offset); switch (objectKind) { case BIOP_OBJECT_FILE: obj = new File( loc ); break; case BIOP_OBJECT_DIR: case BIOP_OBJECT_GW: obj = new Directory( loc ); break; // case BIOP_OBJECT_STR: // break; case BIOP_OBJECT_STE: obj = new StreamEvent( loc ); break; default: obj = NULL; printf( "[dsmcc::Object] Warning: BIOP object kind %lx not processed\n", objectKind ); } WORD objectInfoLen = RW(buf,offset); // Update offset (27 bytes parsed = BIOP_MAX_HEADER) off += offset; if (obj && !obj->parse( resMgr, module, off, objectInfoLen )) { delete obj; obj = NULL; } return obj; }
/// checks bool hasObjectKey(char &aMemAddrObjectKey) { return (objectKey()==(intptr_t)&aMemAddrObjectKey); };