Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into more-unknown-stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Auto committed May 25, 2024
2 parents d05a49d + da0be9a commit 8fffe43
Show file tree
Hide file tree
Showing 123 changed files with 3,619 additions and 4,665 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/autobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

jobs:
prettier:
build:
name: Automated prettier

runs-on: ubuntu-latest
Expand All @@ -17,7 +17,8 @@ jobs:
prettier_options: --write resources/Spelunky2.json
commit_message: "Automated prettier changes"

build:
notify:
needs: build
name: Autobuild

runs-on: windows-latest
Expand All @@ -33,7 +34,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: C:\Qt
key: ${{ runner.os }}-Qt563 # don't think QT version will change?
key: ${{ runner.os }}-Qt563

- name: Download Qt if Needed
if: steps.cache-qt.outputs.cache-hit != 'true'
Expand All @@ -48,7 +49,7 @@ jobs:
uses: actions/cache/save@v3
with:
path: C:\Qt
key: ${{ runner.os }}-Qt563 # don't think QT version will change?
key: ${{ runner.os }}-Qt563

- name: Build
run: |
Expand Down
28 changes: 11 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include(CPM.cmake)

CPMAddPackage(
NAME x64dbg
SOURCE_DIR "${CMAKE_HOME_DIRECTORY}/3rdParty/x64dbg-src"
SYSTEM SOURCE_DIR "${CMAKE_HOME_DIRECTORY}/3rdParty/x64dbg-src"
)

set(Qt5Core_DIR "${Qt5ROOT}/lib/cmake/Qt5Core")
Expand Down Expand Up @@ -67,15 +67,12 @@ x64dbg_plugin(${PROJECT_NAME}
include/Views/ViewTextureDB.h
include/Views/ViewEntity.h
include/Views/ViewEntities.h
include/Views/ViewState.h
include/Views/ViewSaveGame.h
include/Views/ViewGameManager.h
include/Views/ViewStruct.h
include/Views/ViewLevelGen.h
include/Views/ViewVirtualTable.h
include/Views/ViewStringsTable.h
include/Views/ViewLogger.h
include/Views/ViewVirtualFunctions.h
include/Views/ViewOnline.h
include/Views/ViewStdVector.h
include/Views/ViewJournalPage.h
include/Views/ViewThreads.h
Expand All @@ -88,6 +85,7 @@ x64dbg_plugin(${PROJECT_NAME}
include/QtHelpers/WidgetSpelunkyRooms.h
include/QtHelpers/DialogEditSimpleValue.h
include/QtHelpers/DialogEditState.h
include/QtHelpers/DialogEditString.h
include/QtHelpers/TableWidgetItemNumeric.h
include/QtHelpers/TreeWidgetItemNumeric.h
include/QtHelpers/ItemModelVirtualTable.h
Expand All @@ -101,7 +99,9 @@ x64dbg_plugin(${PROJECT_NAME}
include/QtHelpers/WidgetSampling.h
include/QtHelpers/WidgetSamplesPlot.h
include/QtHelpers/ItemModelLoggerSamples.h
include/QtHelpers/DatabaseHelper.h
include/QtHelpers/WidgetDatabaseView.h
include/QtHelpers/WidgetAutorefresh.h
include/QtHelpers/LongLongSpinBox.h
src/Spelunky2.cpp
src/Configuration.cpp
src/Data/EntityDB.cpp
Expand All @@ -121,41 +121,35 @@ x64dbg_plugin(${PROJECT_NAME}
src/Views/ViewTextureDB.cpp
src/Views/ViewEntity.cpp
src/Views/ViewEntities.cpp
src/Views/ViewState.cpp
src/Views/ViewSaveGame.cpp
src/Views/ViewGameManager.cpp
src/Views/ViewStruct.cpp
src/Views/ViewLevelGen.cpp
src/Views/ViewVirtualTable.cpp
src/Views/ViewStringsTable.cpp
src/Views/ViewLogger.cpp
src/Views/ViewVirtualFunctions.cpp
src/Views/ViewOnline.cpp
src/Views/ViewStdVector.cpp
src/Views/ViewStdMap.cpp
src/Views/ViewJournalPage.cpp
src/Views/ViewThreads.cpp
src/QtHelpers/StyledItemDelegateHTML.cpp
src/QtHelpers/StyledItemDelegateColorPicker.cpp
src/QtHelpers/TreeViewMemoryFields.cpp
src/QtHelpers/WidgetMemoryView.cpp
src/QtHelpers/WidgetSpelunkyLevel.cpp
src/QtHelpers/WidgetSpelunkyRooms.cpp
src/QtHelpers/DialogEditSimpleValue.cpp
src/QtHelpers/DialogEditState.cpp
src/QtHelpers/TableWidgetItemNumeric.cpp
src/QtHelpers/TreeWidgetItemNumeric.cpp
src/QtHelpers/DialogEditString.cpp
src/QtHelpers/ItemModelVirtualTable.cpp
src/QtHelpers/ItemModelVirtualFunctions.cpp
src/QtHelpers/SortFilterProxyModelStringsTable.cpp
src/QtHelpers/ItemModelStates.cpp
src/QtHelpers/ItemModelGatherVirtualData.cpp
src/QtHelpers/CPPSyntaxHighlighter.cpp
src/QtHelpers/TableViewLogger.cpp
src/QtHelpers/ItemModelLoggerFields.cpp
src/QtHelpers/WidgetSampling.cpp
src/QtHelpers/WidgetSamplesPlot.cpp
src/QtHelpers/ItemModelLoggerSamples.cpp
src/QtHelpers/DatabaseHelper.cpp
src/QtHelpers/WidgetDatabaseView.cpp
src/QtHelpers/WidgetAutorefresh.cpp
${CMAKE_CURRENT_BINARY_DIR}/include/pluginconfig.h
resources/spelunky2.qrc
)
Expand All @@ -171,7 +165,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core
# Set the plugin as the startup project
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})

target_compile_options(Spelunky2 PRIVATE /W4)
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /W4)

# Copy the plugin to the x64dbg plugins folder

Expand Down
25 changes: 14 additions & 11 deletions include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <QColor>
#include <QMetaEnum>
#include <cstdint>
#include <memory>
#include <nlohmann/json.hpp>
#include <string>
#include <string_view>
Expand All @@ -27,7 +26,7 @@ namespace S2Plugin
* [[ Roles explanation: ]]
* The first 5 roles are all saved to the name field
* those are used as information about the row
* memory address in the name field are used just for row update and should not be used for anything else
* memory address in the name field are used just for row update and shouldn't really be used for anything else
*
* value, comparison value, memoryaddress and delta fields all should contain the `gsRoleRawValue` data
* (may differ with some special types)
Expand All @@ -53,10 +52,6 @@ namespace S2Plugin
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 char* gsJSONDragDropMemoryField_UID = "uid";
constexpr char* gsJSONDragDropMemoryField_Address = "addr";
constexpr char* gsJSONDragDropMemoryField_Type = "type";

// new types need to be added to
// - the MemoryFieldType enum
// - gsMemoryFieldType in Configuration.cpp
Expand Down Expand Up @@ -116,7 +111,7 @@ namespace S2Plugin
EntitySubclass, // a subclass of an entity defined in json
DefaultStructType, // a struct defined in json
UndeterminedThemeInfoPointer, // used to look up the theme pointer in the levelgen and show the correct theme name
ThemeInfoName, // same as above, but does not add struct tree
ThemeInfoPointer, // same as above, but does not add struct tree
LevelGenRoomsPointer, // used to make the level gen rooms title clickable
LevelGenRoomsMetaPointer, // used to make the level gen rooms title clickable
JournalPagePointer, // used to make journal page in vector clickable
Expand Down Expand Up @@ -156,6 +151,7 @@ namespace S2Plugin
std::string firstParameterType;
std::string secondParameterType;
std::string comment;
// size in bytes
size_t get_size() const;

// For checking duplicate names
Expand All @@ -177,8 +173,8 @@ namespace S2Plugin
RoomCode(uint16_t _id, std::string _name, QColor _color) : id(_id), name(_name), color(_color){};
};

Q_DECLARE_METATYPE(S2Plugin::MemoryFieldType)
Q_DECLARE_METATYPE(std::string)
Q_DECLARE_METATYPE(S2Plugin::MemoryFieldType);
Q_DECLARE_METATYPE(std::string);

class Configuration
{
Expand Down Expand Up @@ -221,7 +217,7 @@ namespace S2Plugin
int getAlingment(const std::string& type) const;
bool isPermanentPointer(const std::string& type) const
{
return mPointerTypes.find(type) != mPointerTypes.end();
return std::find(mPointerTypes.begin(), mPointerTypes.end(), type) != mPointerTypes.end();
}
bool isJsonStruct(const std::string type) const
{
Expand All @@ -246,6 +242,11 @@ namespace S2Plugin
RoomCode roomCodeForID(uint16_t code) const;
std::string getEntityName(uint32_t type) const;

const std::vector<std::string>& getJournalPageNames()
{
return mJournalPages;
}

private:
static Configuration* ptr;
bool initialisedCorrectly = false;
Expand All @@ -257,7 +258,9 @@ namespace S2Plugin
std::unordered_map<MemoryFieldType, std::vector<MemoryField>> mTypeFieldsMain;
std::unordered_map<std::string, std::vector<MemoryField>> mTypeFieldsEntitySubclasses;
std::unordered_map<std::string, std::vector<MemoryField>> mTypeFieldsStructs;
std::unordered_set<std::string> mPointerTypes; // pointers defined in pointer_types in json
std::vector<std::string> mPointerTypes; // pointers defined in pointer_types in json

std::vector<std::string> mJournalPages;

std::unordered_map<std::string, size_t> mTypeFieldsStructsSizes;

Expand Down
3 changes: 3 additions & 0 deletions include/Data/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace S2Plugin
{
constexpr size_t gSmallEntityBucket = 0xD0;
constexpr size_t gBigEntityBucket = 0x188;

class Entity
{
public:
Expand Down
5 changes: 3 additions & 2 deletions include/Data/IDNameList.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ namespace S2Plugin
{
class IDNameList
{
public:
protected:
IDNameList(const std::string& relFilePath, const std::regex& regex);

public:
uint32_t idForName(const std::string& name) const;
std::string nameForID(uint32_t id) const;
uint32_t highestID() const noexcept
Expand All @@ -23,7 +24,7 @@ namespace S2Plugin
{
return mEntries.size();
}
QStringList names() const noexcept
const QStringList& names() const noexcept
{
return mNames;
}
Expand Down
5 changes: 3 additions & 2 deletions include/Data/Logger.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <QColor>
#include <QObject>
#include <QTimer>
#include <any>
#include <cstdint>
Expand Down Expand Up @@ -43,7 +44,7 @@ namespace S2Plugin
}

void addField(const LoggerField& field);
void removeFieldAt(size_t fieldIndex);
void removeFieldAt(int fieldIndex);
void updateFieldColor(size_t fieldIndex, const QColor& newColor)
{
mFields.at(fieldIndex).color = newColor;
Expand All @@ -63,7 +64,7 @@ namespace S2Plugin
}
std::pair<int64_t, int64_t> sampleBounds(const LoggerField& field) const;

void start(size_t samplePeriod, size_t duration);
void start(int samplePeriod, int duration);

signals:
void samplingEnded();
Expand Down
2 changes: 0 additions & 2 deletions include/Data/State.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once

#include <cstdint>
#include <string>
#include <unordered_map>

namespace S2Plugin
{
Expand Down
18 changes: 12 additions & 6 deletions include/Data/StdMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ namespace S2Plugin
struct StdMap
{
// only for the template
StdMap(size_t addr) : address(addr)
StdMap(uintptr_t addr) : address(addr)
{
keytype_size = sizeof(Key);
valuetype_size = sizeof(Value);
set_offsets();
};

// value size only needed for value() function
StdMap(size_t addr, uint8_t keyAlignment, uint8_t valueAlignment, size_t keySize) : address(addr)
StdMap(uintptr_t addr, uint8_t keyAlignment, uint8_t valueAlignment, size_t keySize) : address(addr)
{
keytype_size = keySize;
valuetype_size = sizeof(Value);
set_offsets(keyAlignment, valueAlignment);
};
StdMap(size_t addr, uint8_t keyAlignment, uint8_t valueAlignment, size_t keySize, size_t valueSize) : address(addr)
StdMap(uintptr_t addr, uint8_t keyAlignment, uint8_t valueAlignment, size_t keySize, size_t valueSize) : address(addr)
{
keytype_size = keySize;
valuetype_size = valueSize;
Expand Down Expand Up @@ -72,11 +72,11 @@ namespace S2Plugin
}
return (Value)Script::Memory::ReadQword(value_address);
}
size_t key_ptr() const
uintptr_t key_ptr() const
{
return node_ptr + parent_map->key_offset;
}
size_t value_ptr() const
uintptr_t value_ptr() const
{
return node_ptr + parent_map->value_offset;
}
Expand All @@ -103,6 +103,11 @@ namespace S2Plugin
{
return (bool)Script::Memory::ReadByte(node_ptr + 0x19);
}
// returning value ptr instead of value itself since it's more usefull for us
std::pair<Key, uintptr_t> operator*()
{
return {key(), value_ptr()};
}
Node operator++()
{
if (is_nil())
Expand Down Expand Up @@ -159,9 +164,10 @@ namespace S2Plugin
{
return other.node_ptr != node_ptr;
}
size_t node_ptr;

private:
uintptr_t node_ptr;
// need reference to the map object so we can get offsets and alignments
const StdMap<Key, Value>* parent_map;
};

Expand Down
3 changes: 1 addition & 2 deletions include/Data/StdString.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "pluginmain.h"
#include <cstdint>
#include <memory>
#include <string>

namespace S2Plugin
Expand Down Expand Up @@ -77,5 +76,5 @@ namespace S2Plugin
};

using StdString = StdBasicString<char>;
using StdWstring = StdBasicString<char16_t>;
using StdWstring = StdBasicString<ushort>;
} // namespace S2Plugin
2 changes: 1 addition & 1 deletion include/Data/StringsTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace S2Plugin
{
return ptr + idx * sizeof(uintptr_t);
}
uintptr_t stringaddressOfIndex(uint32_t idx) const;
uintptr_t stringAddressOfIndex(uint32_t idx) const;
size_t count() const
{
return size;
Expand Down
7 changes: 6 additions & 1 deletion include/Data/TextureDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ namespace S2Plugin
{
return mTextures;
}
size_t highestID() const
{
return mHighestID;
}

private:
size_t ptr{0};
uintptr_t ptr{0};
std::unordered_map<uint32_t, std::pair<std::string, uintptr_t>> mTextures; // id -> {name, address}
QStringList mTextureNamesStringList;
size_t mHighestID;

TextureDB() = default;
~TextureDB(){};
Expand Down
Loading

0 comments on commit 8fffe43

Please sign in to comment.