diff options
author | Filippos Karapetis | 2010-05-30 23:31:33 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-05-30 23:31:33 +0000 |
commit | 50cd1d1da4a934cfcdcf7cb0b05bed6f7d9735c2 (patch) | |
tree | 1db296cc9949220a807398ae340c90189e832c11 | |
parent | 4e25867a671a8847b167decba1ed1e95cf699e66 (diff) | |
download | scummvm-rg350-50cd1d1da4a934cfcdcf7cb0b05bed6f7d9735c2.tar.gz scummvm-rg350-50cd1d1da4a934cfcdcf7cb0b05bed6f7d9735c2.tar.bz2 scummvm-rg350-50cd1d1da4a934cfcdcf7cb0b05bed6f7d9735c2.zip |
Limited access to the script export table and synonyms block
svn-id: r49338
-rw-r--r-- | engines/sci/console.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/kscripts.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/segment.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/segment.h | 29 |
4 files changed, 28 insertions, 23 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 6965ca0ece..98046cfa32 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -1246,12 +1246,12 @@ bool Console::segmentInfo(int nr) { case SEG_TYPE_SCRIPT: { Script *scr = (Script *)mobj; DebugPrintf("script.%03d locked by %d, bufsize=%d (%x)\n", scr->_nr, scr->getLockers(), (uint)scr->getBufSize(), (uint)scr->getBufSize()); - if (scr->_exportTable) - DebugPrintf(" Exports: %4d at %d\n", scr->_numExports, (int)(((const byte *)scr->_exportTable) - ((const byte *)scr->_buf))); + if (scr->getExportTable()) + DebugPrintf(" Exports: %4d at %d\n", scr->getExportsNr(), (int)(((const byte *)scr->getExportTable()) - ((const byte *)scr->_buf))); else DebugPrintf(" Exports: none\n"); - DebugPrintf(" Synonyms: %4d\n", scr->_numSynonyms); + DebugPrintf(" Synonyms: %4d\n", scr->getSynonymsNr()); if (scr->_localsBlock) DebugPrintf(" Locals : %4d in segment 0x%x\n", scr->_localsBlock->_locals.size(), scr->_localsSegment); diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index b829887433..2f260bc03a 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -181,7 +181,7 @@ reg_t kDisposeClone(EngineState *s, int argc, reg_t *argv) { // Returns script dispatch address index in the supplied script reg_t kScriptID(EngineState *s, int argc, reg_t *argv) { int script = argv[0].toUint16(); - int index = (argc > 1) ? argv[1].toUint16() : 0; + uint16 index = (argc > 1) ? argv[1].toUint16() : 0; if (argv[0].segment) return argv[0]; @@ -193,7 +193,7 @@ reg_t kScriptID(EngineState *s, int argc, reg_t *argv) { Script *scr = s->_segMan->getScript(scriptSeg); - if (!scr->_numExports) { + if (!scr->getExportsNr()) { // This is normal. Some scripts don't have a dispatch (exports) table, // and this call is probably used to load them in memory, ignoring // the return value. If only one argument is passed, this call is done @@ -205,8 +205,8 @@ reg_t kScriptID(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } - if (index > scr->_numExports) { - error("Dispatch index too big: %d > %d", index, scr->_numExports); + if (index > scr->getExportsNr()) { + error("Dispatch index too big: %d > %d", index, scr->getExportsNr()); return NULL_REG; } diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index 3bec74398c..e1e7fd4ae6 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -384,14 +384,6 @@ uint16 Script::validateExportFunc(int pubfunct) { return offset; } -const byte *Script::getSynonyms() const { - return _synonyms; -} - -int Script::getSynonymsNr() const { - return _numSynonyms; -} - byte *Script::findBlock(int type) { byte *buf = _buf; bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY); diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h index ea85a6e764..dce1eb8445 100644 --- a/engines/sci/engine/segment.h +++ b/engines/sci/engine/segment.h @@ -325,12 +325,6 @@ public: byte *_buf; /**< Static data buffer, or NULL if not used */ byte *_heapStart; /**< Start of heap if SCI1.1, NULL otherwise */ - const uint16 *_exportTable; /**< Abs. offset of the export table or 0 if not present */ - int _numExports; /**< Number of entries in the exports table */ - - const byte *_synonyms; /**< Synonyms block or 0 if not present*/ - int _numSynonyms; /**< Number of entries in the synonyms block */ - uint32 getScriptSize() { return _scriptSize; } uint32 getHeapSize() { return _heapSize; } uint32 getBufSize() { return _bufSize; } @@ -342,6 +336,13 @@ private: size_t _scriptSize; size_t _heapSize; size_t _bufSize; + + const uint16 *_exportTable; /**< Abs. offset of the export table or 0 if not present */ + uint16 _numExports; /**< Number of entries in the exports table */ + + const byte *_synonyms; /**< Synonyms block or 0 if not present*/ + uint16 _numSynonyms; /**< Number of entries in the synonyms block */ + Common::Array<CodeBlock> _codeBlocks; public: @@ -432,16 +433,28 @@ public: void setLockers(int lockers); /** + * Retrieves a pointer to the exports of this script + * @return pointer to the exports. + */ + const uint16 *getExportTable() const { return _exportTable; } + + /** + * Retrieves the number of exports of script. + * @return the number of exports of this script + */ + uint16 getExportsNr() const { return _numExports; } + + /** * Retrieves a pointer to the synonyms associated with this script * @return pointer to the synonyms, in non-parsed format. */ - const byte *getSynonyms() const; + const byte *getSynonyms() const { return _synonyms; } /** * Retrieves the number of synonyms associated with this script. * @return the number of synonyms associated with this script */ - int getSynonymsNr() const; + uint16 getSynonymsNr() const { return _numSynonyms; } /** * Validate whether the specified public function is exported by |