Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LibMbinMem {
- /*
- *****************************************************
- * *
- * libMbinMem by RaYRoD TV *
- * - Serves as a wrapper around libMBIN - *
- * *
- *****************************************************
- */
- public:
- // Index of this Class:
- // [SECTION] Getters
- // [SECTION] Setters
- //-----------------------------------------------------------------------------
- // - Resolves info of Fields -
- static std::string RemoveArrayString(std::string arrayString);
- static std::string RemoveArrayString(String^ arrayString);
- static void ResolveFieldInfo(Type^ classType, FieldInfo^ fieldInfo, String^ inheritedFieldIndex, uintptr_t currentAddress);
- static void ResolveFieldInfo(Type^ classType, FieldInfo^ fieldInfo, String^ inheritedFieldIndex);
- static std::string ResolveFieldType(Type^ classType, String^ fieldName);
- static Type^ ResolveFieldTypeID(Type^ fieldType);
- static Type^ ResolveFieldTypeInfo(Type^ classType, String^ fieldName);
- static int ResolveFieldPadding(String^ fieldName);
- static uintptr_t ResolveFieldAddress(Type^ classType, uintptr_t baseAddress, String^ fieldName);
- //-----------------------------------------------------------------------------
- // [SECTION] Print
- //-----------------------------------------------------------------------------
- // - Prints all Array fields in a class (eg. hierarchy, types, names, addresses) -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- static void PrintFieldArrayTypes(Type^ classType);
- // - Prints all List fields in a class (eg. hierarchy, types, names, addresses) -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- static void PrintFieldListTypes(Type^ classType);
- //-----------------------------------------------------------------------------
- // [SECTION] Getters
- //-----------------------------------------------------------------------------
- // - Gets the type of a specified field in a class -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- // Param 2: fieldName - The name of the field to search for
- static std::string GetFieldType(Type^ classType, String^ fieldName);
- // - Gets the memory address of a specified field in a class -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- static uintptr_t GetField(Type^ classType, uintptr_t baseAddress, String^ fieldName);
- // - Gets the memory addresses of a 'Colour' field & stores them in a Colour object -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- static Colour GetColour(Type^ classType, uintptr_t baseAddress, String^ fieldName);
- // - Gets the memory addresses of a 'Vector2f' field & stores them in a Vector2f object -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- static Vector2f GetVector2f(Type^ classType, uintptr_t baseAddress, String^ fieldName);
- // - Gets the memory addresses of a 'Vector3f' field & stores them in a Vector3f object -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- static Vector3f GetVector3f(Type^ classType, uintptr_t baseAddress, String^ fieldName);
- // - Gets the memory addresses of a 'Vector4f' field & stores them in a Vector4f object -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- static Vector4f GetVector4f(Type^ classType, uintptr_t baseAddress, String^ fieldName);
- // - Gets the memory addresses of a 'Quaternion' field & stores them in a Quaternion object -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- static Quaternion GetQuaternion(Type^ classType, uintptr_t baseAddress, String^ fieldName);
- // - Gets the memory addresses of a 'String' field -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- static uintptr_t GetString(Type^ classType, uintptr_t baseAddress, String^ fieldName);
- // - Gets/Dereferences the memory address of a 'List' field in a class -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: padding - the number of bytes to jump at the initial dereference at the resolved location
- // Param 4: fieldName - The name of the field to search for
- static uintptr_t GetList(Type^ classType, uintptr_t baseAddress, int padding, String^ fieldName);
- // - Gets the memory addresses of a 'One Dimensional Array' field & stores them in an std::vector variable -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: arrayLength - The length of the array (number of elements in it)
- // Param 4: fieldName - The name of the field to search for
- static MemVec_t GetArray(Type^ classType, uintptr_t baseAddress, int arrayLength, String^ arrayFieldName);
- // - Gets the memory addresses of a 'Two Dimensional Array/Matrix' field & stores them in an std::vector variable -
- // eg. MapLargeAreaPrimaryDefaultColours[0][1] = MapLargeAreaPrimaryDefaultColours 'Colour index 0, R')
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: xMatrix - The size of the 2D array (array index count)
- // Param 4: yMatrix - The length of each array element (number of elements in each xMatrix index)
- // Param 5: arrayField - The name of the first array to search for
- // Param 6: fieldName - The name of the field to search for
- static MemVec2D_t Get2DArray(Type^ classType, uintptr_t baseAddress, int xMatrix, int yMatrix, String^ arrayField, String^ fieldName);
- // - Gets the memory addresses of a 'Three Dimensional Array/Matrix' field & stores them in an std::vector variable -
- // eg.
- //field[0] = MarkerSettings array(index)
- //field[0][0] = Colours array(index)
- //field[0][0][0] = Colour field at Colours array(index)
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcGalaxyGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: xMatrix - The size of the 3D array (array index count)
- // Param 4: yMatrix - The size of the nested array (array index count)
- // Param 5: zMatrix - The length of each array element (number of elements in each yMatrix index)
- // Param 6: arrayField1 - The name of the first array to search for
- // Param 7: arrayField2 - The name of the nested array to search for
- // Param 8: fieldName - The name of the field in the nested array to search for
- static MemVec3D_t Get3DArray(Type^ classType, uintptr_t baseAddress, int xMatrix, int yMatrix, int zMatrix, String^ arrayField1, String^ arrayField2, String^ fieldName);
- //-----------------------------------------------------------------------------
- // [SECTION] Setters
- //-----------------------------------------------------------------------------
- // - Sets/Writes to the memory addresses of a 'Bool Array' - ( eg. { false, true, false ... } ) -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcUIGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- // Param 4: value to set - eg. { false, true, false, true }
- // for reference: - LibMbinMem::SetBoolArray(parentClassType, baseAddr, "ClassType.BoolFieldName", { false, true });
- static void SetBoolArray(Type^ classType, uintptr_t baseAddress, String^ fieldName, vector<bool> valueToSet);
- // - Sets/Writes to the memory addresses of an 'Int Array' - ( eg. { 0, 1, 2 ... } ) -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcUIGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- // Param 4: value to set - eg. { 1, 2, 3, 4 }
- // for reference: - LibMbinMem::SetIntArray(parentClassType, baseAddr, "ClassType.IntFieldName", { 1, 2, 3, 4 });
- static void SetIntArray(Type^ classType, uintptr_t baseAddress, String^ fieldName, vector<int> valueToSet);
- // - Sets/Writes to the memory addresses of a 'Float Array' class ( eg. { 0.f, 1.f, 2.f ... } ) -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcUIGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- // Param 4: value to set - eg. { 1.f, 2.f, 3.f, 4.f, 5.f }
- // for reference: - LibMbinMem::SetFloatArray(parentClassType, baseAddr, "ClassType.FloatFieldName", { 1.f, 2.f, 3.f, 4.f, 5.f });
- static void SetFloatArray(Type^ classType, uintptr_t baseAddress, String^ fieldName, vector<float> valueToSet);
- // - Sets/Writes to the memory addresses of a 'Vector2f Field' class ( eg. { 0.f, 1.f, } = X.Y ) -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcUIGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- // Param 4: value to set - eg. { 1.f, 2.f }
- // for reference: - LibMbinMem::SetFloatArray(parentClassType, baseAddr, "ClassType.Vector2f_FieldName", { 1.f, 2.f});
- static void SetVector2f(Type^ classType, uintptr_t baseAddress, String^ fieldName, vector<float> valueToSet);
- // - Sets/Writes to the memory addresses of a 'Vector3f Field' class ( eg. { 0.f, 1.f, 2.f } = X.Y.Z ) -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcUIGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- // Param 4: value to set - eg. { 1.f, 2.f, 3.f }
- // for reference: - LibMbinMem::SetFloatArray(parentClassType, baseAddr, "ClassType.Vector3f_FieldName", { 1.f, 2.f, 3.f });
- static void SetVector3f(Type^ classType, uintptr_t baseAddress, String^ fieldName, vector<float> valueToSet);
- // - Sets/Writes to the memory addresses of a 'Vector4f Field' class ( eg. { 0.f, 1.f, 2.f, 3.f } = X.Y.Z.T ) -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcUIGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- // Param 4: value to set - eg. { 1.f, 2.f, 3.f, 4.f }
- // for reference: - LibMbinMem::SetFloatArray(parentClassType, baseAddr, "ClassType.Vector4f_FieldName", { 1.f, 2.f, 3.f, 4.f });
- static void SetVector4f(Type^ classType, uintptr_t baseAddress, String^ fieldName, vector<float> valueToSet);
- // - Sets/Writes to the memory addresses of a 'Quaternion Field' class ( eg. { 0.f, 1.f, 2.f, 3.f } = X.Y.Z.T ) -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcUIGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- // Param 4: value to set - eg. { 1.f, 2.f, 3.f, 4.f }
- // for reference: - LibMbinMem::SetFloatArray(parentClassType, baseAddr, "ClassType.Vector4f_FieldName", { 1.f, 2.f, 3.f, 4.f });
- static void SetQuaternion(Type^ classType, uintptr_t baseAddress, String^ fieldName, vector<float> valueToSet);
- // - Sets/Writes to the memory addresses of a 'Colour field' in a class -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcUIGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- // Param 4: Colour to set - eg. #B0807D49
- // for reference: - LibMbinMem::SetColour(parentClassType, baseAddr, "ClassType.ColourFieldName", "#B0807D49");
- static void SetColour(Type^ classType, uintptr_t baseAddress, String^ fieldName, std::string colourToSet);
- // - Sets/Writes to the memory addresses of a 'String field' in a class -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcUIGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- // Param 4: String to set - eg. "METADATA/SIMULATION/SOLARSYSTEM/BIOMES/LUSH/LUSHBIOME.MBIN"
- // for reference: - LibMbinMem::SetString(parentClassType, baseAddr, "ClassType.StringFieldName", "String");
- static void SetString(Type^ classType, uintptr_t baseAddress, String^ fieldName, char* stringToSet);
- // - Sets/Writes to the memory addresses of a 'field' in a class -
- // Param 1: classType - Class Type ID ( eg. NMS::Globals::GcUIGlobals::typeid; )
- // Param 2: baseAddress - Base Address of class in memory
- // Param 3: fieldName - The name of the field to search for
- // Param 4: Value to set
- // for reference: - LibMbinMem::SetValue(parentClassType, baseAddr, "ClassType.ColourFieldName", value);
- template <typename T>
- static uintptr_t SetValue(Type^ classType, uintptr_t baseAddress, String^ fieldName, T valueToSet) {
- auto address{ ResolveFieldAddress(classType, baseAddress, fieldName) };
- *(T*)address = valueToSet;
- return address;
- }
- };
- inline LibMbinMem libMbinMem;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement