Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More build in types #5

Merged
merged 20 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
013aa0e
add 'Array' type
Mr-Auto May 28, 2024
c305a23
implement Matrix, slightly change Array implementation
Mr-Auto May 30, 2024
6c2d63b
fix editing float and double value, fix level view since adding array…
Mr-Auto Jun 1, 2024
0a284b8
Implement EntityList view, also display when container is empty (Enti…
Mr-Auto Jun 1, 2024
824ed21
improve performance by using the new EntityList class
Mr-Auto Jun 1, 2024
bff3f4b
Rename `WidgetDatabaseView` to `AbstractDatabaseView`, also `vectorty…
Mr-Auto Jun 2, 2024
910ecf0
add this giant array that sits below ai targets
Mr-Auto Jun 2, 2024
56db4ad
add template for container view, improve the StdSet a little bit
Mr-Auto Jun 2, 2024
5cbf288
add view for StdList
Mr-Auto Jun 2, 2024
ed37b0e
add current std::list implementation
Mr-Auto Jun 2, 2024
7545cd7
implement unordered map and it's view
Mr-Auto Jun 8, 2024
024530f
improvements to the map
Mr-Auto Jun 9, 2024
5d4aea6
add `explicit` to the constructors just in case
Mr-Auto Jun 10, 2024
b0757ce
add pagination, some fixes and rearrangements in the code, adjust siz…
Mr-Auto Jun 16, 2024
d79bdf6
some post self review changes
Mr-Auto Jun 16, 2024
f8b6196
re-arrange toolbar, add HUD and GameAPI view, fix mistake in edit val…
Mr-Auto Jun 22, 2024
bee776c
add OnHeapPointer, EntityFactory, separate LiquidPhysics to it's own …
Mr-Auto Jun 25, 2024
fbe48ce
little bit more unknown stuff
Mr-Auto Jun 28, 2024
d4245c6
Automated clang-format changes
Jun 28, 2024
0b660a4
fix formatting in the CMakeList
Mr-Auto Jun 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ find_package(Qt5Widgets REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
if(QT_NAMESPACE)
add_definitions(-DQT_NAMESPACE=${QT_NAMESPACE})
add_definitions(-DQT_NAMESPACE=${QT_NAMESPACE})
endif()


Expand Down Expand Up @@ -60,6 +60,9 @@ x64dbg_plugin(${PROJECT_NAME}
include/Data/Logger.h
include/Data/StdString.h
include/Data/StdMap.h
include/Data/EntityList.h
include/Data/StdList.h
include/Data/StdUnorderedMap.h
include/Views/ViewToolbar.h
include/Views/ViewEntityDB.h
include/Views/ViewParticleDB.h
Expand All @@ -77,6 +80,10 @@ x64dbg_plugin(${PROJECT_NAME}
include/Views/ViewJournalPage.h
include/Views/ViewThreads.h
include/Views/ViewStdMap.h
include/Views/ViewStdUnorderedMap.h
include/Views/ViewStdList.h
include/Views/ViewEntityList.h
include/Views/ViewEntityFactory.h
include/QtHelpers/StyledItemDelegateHTML.h
include/QtHelpers/StyledItemDelegateColorPicker.h
include/QtHelpers/TreeViewMemoryFields.h
Expand All @@ -99,9 +106,11 @@ x64dbg_plugin(${PROJECT_NAME}
include/QtHelpers/WidgetSampling.h
include/QtHelpers/WidgetSamplesPlot.h
include/QtHelpers/ItemModelLoggerSamples.h
include/QtHelpers/WidgetDatabaseView.h
include/QtHelpers/AbstractDatabaseView.h
include/QtHelpers/AbstractContainerView.h
include/QtHelpers/WidgetAutorefresh.h
include/QtHelpers/LongLongSpinBox.h
include/QtHelpers/WidgetPagination.h
src/Spelunky2.cpp
src/Configuration.cpp
src/Data/EntityDB.cpp
Expand Down Expand Up @@ -129,8 +138,11 @@ x64dbg_plugin(${PROJECT_NAME}
src/Views/ViewVirtualFunctions.cpp
src/Views/ViewStdVector.cpp
src/Views/ViewStdMap.cpp
src/Views/ViewStdUnorderedMap.cpp
src/Views/ViewStdList.cpp
src/Views/ViewJournalPage.cpp
src/Views/ViewThreads.cpp
src/Views/ViewEntityList.cpp
src/QtHelpers/StyledItemDelegateHTML.cpp
src/QtHelpers/TreeViewMemoryFields.cpp
src/QtHelpers/WidgetMemoryView.cpp
Expand All @@ -148,7 +160,8 @@ x64dbg_plugin(${PROJECT_NAME}
src/QtHelpers/ItemModelLoggerFields.cpp
src/QtHelpers/WidgetSamplesPlot.cpp
src/QtHelpers/ItemModelLoggerSamples.cpp
src/QtHelpers/WidgetDatabaseView.cpp
src/QtHelpers/AbstractDatabaseView.cpp
src/QtHelpers/AbstractContainerView.cpp
src/QtHelpers/WidgetAutorefresh.cpp
${CMAKE_CURRENT_BINARY_DIR}/include/pluginconfig.h
resources/spelunky2.qrc
Expand Down
78 changes: 54 additions & 24 deletions include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ namespace S2Plugin
constexpr uint16_t gsRoleStdContainerFirstParameterType = Qt::UserRole + 8;
constexpr uint16_t gsRoleStdContainerSecondParameterType = Qt::UserRole + 9;
constexpr uint16_t gsRoleSize = Qt::UserRole + 10;
constexpr uint16_t gsRoleEntityAddress = Qt::UserRole + 11; // for entity uid to not look for the uid twice
constexpr uint16_t gsRoleColumns = Qt::UserRole + 11; // for Matrix
constexpr uint16_t gsRoleEntityAddress = Qt::UserRole + 12; // for entity uid to not look for the uid twice

// new types need to be added to
// - the MemoryFieldType enum
Expand All @@ -69,6 +70,7 @@ namespace S2Plugin
Dummy, // dummy type for uses like fake parent type in StdMap
CodePointer,
DataPointer,
OnHeapPointer,
Byte,
UnsignedByte,
Word,
Expand All @@ -88,9 +90,14 @@ namespace S2Plugin
State32, // this is signed, can be negative!
Skip,
GameManager,
GameAPI,
Hud,
EntityFactory,
State,
SaveGame,
LevelGen,
LiquidPhysics,
LiquidPhysicsPointer,
EntityDB,
EntityPointer,
EntityDBPointer,
Expand Down Expand Up @@ -126,6 +133,12 @@ namespace S2Plugin
Online,
IPv4Address,
Double,
Array,
Matrix,
EntityList,
OldStdList,
StdList,
StdUnorderedMap,
};

struct VirtualFunction
Expand All @@ -139,7 +152,7 @@ namespace S2Plugin
VirtualFunction(size_t i, std::string n, std::string p, std::string r, std::string t) : index(i), name(n), params(p), returnValue(r), type(t){};
};

struct MemoryField
struct MemoryField // TODO this got big over time, consider size optimaizations
{
std::string name;
MemoryFieldType type{MemoryFieldType::None};
Expand All @@ -148,11 +161,21 @@ namespace S2Plugin
// jsonName only if applicable: if a type is not a MemoryFieldType, but fully defined in the json file
// then save its name so we can compare later
std::string jsonName;
// parameter types for stuff like vectors, maps etc.
std::string firstParameterType;
std::string secondParameterType;
std::string comment;
// size in bytes
size_t get_size() const;
union
{
// length, size of array etc.
size_t numberOfElements{0};
// row count for matrix
size_t rows;
};
// column count for matrix
size_t columns{0};

// For checking duplicate names
bool operator==(const MemoryField& other) const
Expand Down Expand Up @@ -186,7 +209,7 @@ namespace S2Plugin
{
return get() != nullptr;
}

// Accessors
const std::unordered_map<std::string, std::string>& entityClassHierarchy() const noexcept
{
return mEntityClassHierarchy;
Expand All @@ -195,6 +218,19 @@ namespace S2Plugin
{
return mDefaultEntityClassTypes;
}
const EntityNamesList& entityList() const noexcept
{
return entityNames;
}
const ParticleEmittersList& particleEmittersList() const noexcept
{
return particleEmitters;
}
const std::vector<std::string>& getJournalPageNames() const noexcept
{
return mJournalPages;
}
//
std::vector<std::string> classHierarchyOfEntity(const std::string& entityName) const;

const std::vector<MemoryField>& typeFields(const MemoryFieldType& type) const;
Expand All @@ -209,42 +245,36 @@ namespace S2Plugin
static std::string_view getTypeDisplayName(MemoryFieldType type);
static size_t getBuiltInTypeSize(MemoryFieldType type);
static bool isPointerType(MemoryFieldType type);
MemoryField nameToMemoryField(const std::string& typeName) const;

uintptr_t offsetForField(const std::vector<MemoryField>& fields, std::string_view fieldUID, uintptr_t base_addr = 0) const;
uintptr_t offsetForField(MemoryFieldType type, std::string_view fieldUID, uintptr_t base_addr = 0) const;

// equivalent to alignof operator
int getAlingment(const std::string& type) const;
bool isPermanentPointer(const std::string& type) const
{
return std::find(mPointerTypes.begin(), mPointerTypes.end(), type) != mPointerTypes.end();
}
bool isJsonStruct(const std::string type) const
{
return mTypeFieldsStructs.find(type) != mTypeFieldsStructs.end();
}
uint8_t getAlingment(const std::string& type) const;
uint8_t getAlingment(MemoryFieldType type) const;
uint8_t getAlingment(const MemoryField& type) const;

std::string flagTitle(const std::string& fieldName, uint8_t flagNumber) const;
std::string stateTitle(const std::string& fieldName, int64_t state) const;
const std::vector<std::pair<int64_t, std::string>>& refTitlesOfField(const std::string& fieldName) const;

size_t getTypeSize(const std::string& typeName, bool entitySubclass = false);
const EntityList& entityList() const
{
return entityNames;
};

const ParticleEmittersList& particleEmittersList() const
{
return particleEmitters;
}

RoomCode roomCodeForID(uint16_t code) const;
std::string getEntityName(uint32_t type) const;

const std::vector<std::string>& getJournalPageNames()
bool isPermanentPointer(const std::string& type) const
{
return mJournalPages;
return std::find(mPointerTypes.begin(), mPointerTypes.end(), type) != mPointerTypes.end();
}
bool isPermanentPointer(const std::string_view type) const
{
return std::find(mPointerTypes.begin(), mPointerTypes.end(), type) != mPointerTypes.end();
}
bool isJsonStruct(const std::string& type) const
{
return mTypeFieldsStructs.find(type) != mTypeFieldsStructs.end();
}

private:
Expand Down Expand Up @@ -275,7 +305,7 @@ namespace S2Plugin
void processRoomCodesJSON(nlohmann::ordered_json& json);
MemoryField populateMemoryField(const nlohmann::ordered_json& field, const std::string& struct_name);

EntityList entityNames;
EntityNamesList entityNames;
ParticleEmittersList particleEmitters;

Configuration();
Expand Down
2 changes: 1 addition & 1 deletion include/Data/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace S2Plugin
class Entity
{
public:
Entity(uintptr_t addr) : mEntityPtr(addr){};
explicit Entity(uintptr_t addr) : mEntityPtr(addr){};
Entity() = delete;

std::string entityClassName() const;
Expand Down
Loading
Loading