Header-only library for Blockland DLL developers to handle known object layouts in memory
Queuenard eac8dbf38e Added class functions, fixed typo | 1 år sedan | |
---|---|---|
BLstructs | 1 år sedan | |
README.md | 2 år sedan |
This is a header-only library for Blockland DLL developers to handle known object layouts in memory. There are also two class-checking functions, one specific to SimObject derivatives and one for all other C++ classes.
It is recommended to have an "include" folder in your project and to have these headers inside a "BLstructs" folder.
The following will include everything defined by this project:
#include "BLstructs/include.hpp"
As an example, 31 of the 32 fields of SimObject and all 3 fields of SimSet are known:
//0 + 52 bytes
#define ClassStruct_SimObject \
void* vftable; \
const char* objectName; \
SimObject* nextNameObject; \
SimObject* nextManagerNameObject; \
SimObject* nextIdObject; \
SimGroup* mGroup; \
U32 mFlags; \
Notify* mNotifyList; \
U32 id; /* +32 */ \
Namespace* mNamespace; /* +36 */ \
unsigned int mTypeMask; \
void* SimObject_0[1]; \
void* mFieldDictionary; \
struct SimObject
{
ClassStruct_SimObject
};
//52 + 12 bytes
#define ClassStruct_SimSet \
U32 mElementCount; /* +52 */ \
U32 mArraySize; /* +56 */ \
SimObject* (*mArray)[]; /* +60 */ \
struct SimSet
{
ClassStruct_SimObject
ClassStruct_SimSet
};
You can then use these structs in functions and also test classnames. Example usage:
int get_simset_size(ADDR objADDR, int argc, const char *argv[])
{
//There is also the option of casting directly to SimSet* but you must not forget to stop any processing if the class check fails
SimObject* obj = (SimObject*)objADDR;
if(NamespaceClasses_instanceOf(obj, "SimSet") <= 0)
return -1;
SimSet* objSimSet = (SimSet*)obj;
return objSimSet->mElementCount;
}