tTJSScriptBlock* tTJSByteCodeLoader::ReadByteCode( tTJS* owner, const tjs_char* name, const tjs_uint8* buf, size_t size ) { ReadBuffer = buf; ReadIndex = 0; ReadSize = size; const tjs_uint8* databuff = ReadBuffer; // TJS2 int tag = read4byte( databuff ); if( tag != FILE_TAG_LE ) return NULL; // 100'\0' int ver = read4byte( &(databuff[4]) ); if( ver != VER_TAG_LE ) return NULL; int filesize = read4byte( &(databuff[8]) ); if( filesize != size ) return NULL; //// DATA tag = read4byte( &(databuff[12]) ); if( tag != DATA_TAG_LE ) return NULL; size = read4byte( &(databuff[16]) ); ReadDataArea( databuff, 20, size ); int offset = 12 + size; // これがデータエリア後の位置 // OBJS tag = read4byte( &(databuff[offset]) ); offset+=4; if( tag != OBJ_TAG_LE ) return NULL; //int objsize = ibuff.get(); int objsize = read4byte( &(databuff[offset]) ); offset+=4; tTJSScriptBlock* block = new tTJSScriptBlock(owner, name, 0 ); ReadObjects( block, databuff, offset, objsize ); return block; }
void PdfParser::ParseFile( const PdfRefCountedInputDevice & rDevice, bool bLoadOnDemand ) { // make sure everything is clean Clear(); m_device = rDevice; m_bLoadOnDemand = bLoadOnDemand; if( !IsPdfFile() ) { PODOFO_RAISE_ERROR( ePdfError_NoPdfFile ); } ReadDocumentStructure(); try { ReadObjects(); } catch( PdfError & e ) { // If this is being called from a constructor then the // destructor will not be called. // Clean up here Clear(); e.AddToCallstack( __FILE__, __LINE__, "Unable to load objects from file." ); throw e; } // Now sort the list of objects m_vecObjects->Sort(); }
main () { const char* name = "perstest.dat"; if (!CL_BinaryFile::Exists (name)) WriteObjects (name); else ReadObjects (name); return(0); }
CIDE::CIDE(CCSV *csv, bool isAllocated) { m_csv = csv; m_isCSVAllocated = isAllocated; while (csv->ReadNextRow()) { if ( csv->GetItemCount() == 0 ) continue; const char *token = csv->GetRowItem(0); if (strcmp(token, "objs") == 0) ReadObjects(); } }
BOOL PluginOILFilter::BuildCapabilityTree(wxString strXmlFilename, CapabilityTree* pCapTree) { // First we need to load the XML into an XML DOM object // Set Parser flags here? // hRes = pDoc->setProperty(CComBSTR(_T("SelectionLanguage")), CComVariant(_T("XPath"))); // hRes = pDoc->put_async(VARIANT_FALSE); // hRes = pDoc->put_preserveWhiteSpace(VARIANT_TRUE); // hRes = pDoc->put_validateOnParse(VARIANT_FALSE); // hRes = pDoc->put_resolveExternals(VARIANT_FALSE); BOOL bOK = TRUE; xmlDocPtr doc; // If string param contains xml (like original Windows version) // wxCharBuffer buf = strXML.mb_str(wxConvUTF8); // doc = xmlParseDoc((const xmlChar*)buf.data()); // buf will be deallocated when it goes out of scope // If string param gives xml filename (like new LX version) wxCharBuffer buf = strXmlFilename.ToAscii(); doc = xmlParseFile(buf.data()); // buf will be deallocated when it goes out of scope #if _DEBUG if (doc==NULL) doc = xmlParseFile("/tmp/XaraLX/capstest.xml"); #endif ERROR1IF(doc==NULL, FALSE, _R(IDE_XPF_BADXML)); // The name of the root element should be XPFilterConfig xmlNodePtr node = xmlDocGetRootElement(doc); wxString strName = CXMLUtils::ConvertToWXString(node->name); if (strName!=_T("XPFilterConfig")) ERROR1(FALSE, _R(IDE_XPF_BADXML)); xmlNodePtr pChild = node->children; INT32 Phase =0; // There are 7 phases to the parsing // We will loop round until we run out of child elements // After parsing a node the phase counter will be set to the phase just parsed // If an element should have already been parsed (using the phase counter) // then an error will be indicated while (pChild && bOK) { wxString strChildName = CXMLUtils::ConvertToWXString(pChild->name); if (strChildName == _T("#text") || xmlNodeIsText(pChild)) { // ignore it } else if (strChildName == _T("Private")) { if (Phase > 0) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE0)); } // Ignore the entire element Phase = 1; } else if (strChildName == _T("Options")) { if (Phase > 1) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE1)); } bOK = ReadOptions(pChild, pCapTree); // Read the options attributes Phase = 2; } else if (strChildName == _T("Rasterise")) { if (Phase > 2) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE2)); } bOK = ReadRasterise(pChild, pCapTree); // Read the dpi and alpha attributes Phase = 3; } else if (strChildName == _T("Spread")) { if (Phase > 3) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE3)); } bOK = ReadSpread(pChild, pCapTree); // Read the as attribute Phase = 4; } else if (strChildName == _T("Objects")) { if (Phase > 4) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE4)); } bOK = ReadObjects(pChild, pCapTree); // Build the tree of XPFCapability derived objects Phase = 5; } else if (strChildName == _T("Attributes")) { if (Phase > 5) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE5)); } bOK = ReadAttributes(pChild, pCapTree); // Build the tree of XPFCapability derived objects Phase = 6; } else if (strChildName == _T("Colour")) { if (Phase > 6) { ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE6)); } bOK = ReadColour(pChild, pCapTree); // Build the tree of XPFColour objects Phase = 7; } else { ERROR1(FALSE, _R(IDE_XPF_BADXML_UNEXPECTED_PHASE)); } pChild = pChild->next; } xmlFreeDoc(doc); return bOK; }
bool GmExe::Load(const std::string& filename, Gmk* gmk, unsigned int ver) { if (!gmk) return false; // Set handles version = ver; gmkHandle = gmk; exeFilename = filename; // Try to load the EXE if (!exeHandle->Load(filename)) return false; // Now we need to check the ver so we know how to treat the EXE switch(version) { case 800: // GM8.0 EXE { std::cout << "Detected GM8.0 game!" << std::endl; Gm80* gm80 = new Gm80(); if (!gm80->FindGameData(exeHandle)) return false; delete gm80; break; } case 810: // GM8.1 EXE { std::cout << "Detected GM8.1 game!" << std::endl; Gm81* gm81 = new Gm81(); if (!gm81->FindGameData(exeHandle)) return false; gm81->Decrypt(exeHandle); delete gm81; break; } default: // Auto-detect version Gm81* gm81 = new Gm81(); Gm80* gm80 = new Gm80(); // Attempt to detect GM8.0 first if (gm80->FindGameData(exeHandle)) { version = 800; std::cout << "Detected GM8.0 game!" << std::endl; break; } // Attempt to detect GM8.1 next if (gm81->FindGameData(exeHandle)) { version = 810; std::cout << "Detected GM8.1 game!" << std::endl; if (!gm81->Decrypt(exeHandle)) { std::cout << "[Error ] Failed to decrypt game data!" << std::endl; return false; } break; } std::cout << "Unknown game version!" << std::endl; delete gm80; delete gm81; return false; } // Read header std::cout << "Reading header..." << std::endl; if (version == 800) exeHandle->SkipDwords(2); // Version, Debug flag else if (version == 810) exeHandle->SkipDwords(3); // Null Magic, Null Version, Debug flag else return false; // Read settings std::cout << "Reading settings..." << std::endl; if (!ReadSettings()) return false; // Read wrapper std::cout << "Reading d3d wrapper..." << std::endl; if (!ReadWrapper()) return false; // Decrypt main game data paragraph std::cout << "Decrypting game data..." << std::endl; if (!DecryptGameData()) return false; // Skip yet another garbage field -- and the pro flag, silly pro flag exeHandle->SkipDwords(exeHandle->ReadDword() + 1); gmkHandle->gameId = exeHandle->ReadDword(); for(int i = 0; i < 4; i++) exeHandle->ReadDword(); // Read extensions std::cout << "Reading extensions..." << std::endl; if (!ReadExtensions()) return false; // Read triggers std::cout << "Reading triggers..." << std::endl; if (!ReadTriggers()) return false; // Read constants std::cout << "Reading constants..." << std::endl; if (!ReadConstants()) return false; // Read sounds std::cout << "Reading sounds..." << std::endl; if (!ReadSounds()) return false; // Read sprites std::cout << "Reading sprites..." << std::endl; if (!ReadSprites()) return false; // Read backgrounds std::cout << "Reading backgrounds..." << std::endl; if (!ReadBackgrounds()) return false; // Read paths std::cout << "Reading paths..." << std::endl; if (!ReadPaths()) return false; // Read scripts std::cout << "Reading scripts..." << std::endl; if (!ReadScripts()) return false; // Read fonts std::cout << "Reading fonts..." << std::endl; if (!ReadFonts()) return false; // Read timelines std::cout << "Reading timelines..." << std::endl; if (!ReadTimelines()) return false; // Read objects std::cout << "Reading objects..." << std::endl; if (!ReadObjects()) return false; // Read rooms std::cout << "Reading rooms..." << std::endl; if (!ReadRooms()) return false; // Read last ID of object/tile placed gmkHandle->lastInstance = exeHandle->ReadDword(); gmkHandle->lastTile = exeHandle->ReadDword(); // Read includes std::cout << "Reading include files..." << std::endl; if (!ReadIncludes()) return false; // Read game information std::cout << "Reading game information..." << std::endl; if (!ReadGameInformation()) return false; // Ignore library initialization code std::cout << "Reading library initialization code..." << std::endl; exeHandle->SkipDwords(1); unsigned int i = exeHandle->ReadDword(); for(; i; i--) exeHandle->iPosition += exeHandle->ReadDword(); // Read room order std::cout << "Reading room order..." << std::endl; exeHandle->SkipDwords(1); i = exeHandle->ReadDword(); for(; i; i--) gmkHandle->roomExecutionOrder.push_back(exeHandle->ReadDword()); // Correct room order ResourceTree* tmpTree = new ResourceTree(); tmpTree->group = RCT_GROUP_ROOMS; tmpTree->name = "Rooms"; tmpTree->index = 0; tmpTree->status = 1; for(size_t a = 0; a < gmkHandle->roomExecutionOrder.size(); a++) { ResourceTree* rcItem = new ResourceTree(); rcItem->name = gmkHandle->rooms[gmkHandle->roomExecutionOrder[a]]->name; rcItem->group = RCT_GROUP_ROOMS; rcItem->index = gmkHandle->roomExecutionOrder[a]; rcItem->status = 3; tmpTree->contents.push_back(rcItem); } delete gmkHandle->resourceTree[RCT_ID_ROOMS]; gmkHandle->resourceTree[RCT_ID_ROOMS] = tmpTree; return true; }