X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FObjectFile.h;h=2bdcb125c63aa5ec2c3a57b5c79fc8126776e669;hb=abfa371d1d2c14052d4cbfc885b8383c6da7d499;hp=b497e344b500ea45ba9fa4e80cbbbda1946c9629;hpb=7b3710c47f24e64e0d01378a4564730bcb2f6ef2;p=l2e.git diff --git a/src/loader/ObjectFile.h b/src/loader/ObjectFile.h index b497e34..2bdcb12 100644 --- a/src/loader/ObjectFile.h +++ b/src/loader/ObjectFile.h @@ -11,7 +11,7 @@ struct Export { /// Offset of the identifier in the file. unsigned int nameOffset; /// Type ID of referenced object. - unsigned int typeId; + int typeId; /// File-offset of the object's actual data. unsigned int dataOffset; }; @@ -22,26 +22,45 @@ struct External { unsigned int nameOffset; /// Target position for linking/inlining. unsigned int referenceOffset; - /// Nonzero if the object should be copied rather that + /// Target type. + int typeId; + /// True if the object should be copied rather that /// just writing a reference. - unsigned int inlined; + bool inlined; +}; + +struct Image { + /// File-relative offset to the image's path string. + unsigned int pathOffset; + /// File-relative offset of the target position of the + /// image's reference. + unsigned int destOffset; }; struct Object { - unsigned int typeId; + int typeId; unsigned int size; + char *RawObject(); Object *Next(); }; struct Array { - unsigned int typeId; + int typeId; unsigned int size; bool ref; + char *Data(); Array *Next(); }; +struct Script { + unsigned int size; + + char *Text(); + Script *Next(); +}; + struct ObjectFileHeader { /// Has to be "L2E\n" char ident[4]; @@ -69,6 +88,12 @@ struct ObjectFileHeader { unsigned int externalsBegin; unsigned int externalsEnd; + /// File-relative offsets of the image section's begin and + /// end respectively. + /// Denotes an array of Image structs. + unsigned int imagesBegin; + unsigned int imagesEnd; + /// File-relative offsets of the objet section's begin /// and end respectively. /// Each object begins with its type ID followed by its @@ -91,6 +116,13 @@ struct ObjectFileHeader { unsigned int arraysBegin; unsigned int arraysEnd; + /// File-relative offsets of the script section's begin + /// and end respectively. + /// Each script is an unsigned int with the length in + /// bytes followed by the script text. + unsigned int scriptsBegin; + unsigned int scriptsEnd; + ObjectFileHeader(); /// Check if there are any problems with the file header. @@ -100,10 +132,20 @@ struct ObjectFileHeader { Export *ExportsEnd(); External *ExternalsBegin(); External *ExternalsEnd(); + Image *ImagesBegin(); + Image *ImagesEnd(); Object *ObjectsBegin(); Object *ObjectsEnd(); Array *ArraysBegin(); Array *ArraysEnd(); + Script *ScriptsBegin(); + Script *ScriptsEnd(); + +private: + bool CheckSection( + unsigned int begin, + unsigned int end, + unsigned int fsize) const; }; struct LoadedExport {