Skip to content

Commit

Permalink
My mods todate
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvita committed Jul 19, 2020
1 parent dc14c3a commit 7a682ce
Show file tree
Hide file tree
Showing 17 changed files with 4,205 additions and 955 deletions.
14 changes: 8 additions & 6 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
"name": "DKP Aarch64",
"includePath": [
"${workspaceFolder}/**",
"${DEVKITPRO}/devkitA64/include/**",
"${DEVKITPRO}/devkitA64/aarch64-none-elf/include/**",
"${DEVKITPRO}/libnx/include/**",
"${DEVKITPRO}/portlibs/switch/include/**"
"${workspaceFolder}/include/**",
"F:/devkitPro/devkitA64/include/**",
"F:/devkitPro/devkitA64/aarch64-none-elf/include/**",
"F:/devkitPro/libnx/include/**",
"F:/devkitPro/portlibs/switch/include/**"
],
"defines": [
"DEBUG",
"SWITCH",
"__SWITCH__",
"VERSION_STRING=\"3.1.0\""
],
"compilerPath": "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-g++",
"compilerPath": "F:/devkitPro/devkitA64/bin/aarch64-none-elf-g++",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
"intelliSenseMode": "gcc-x64",
"compilerArgs": []
}
],
"version": 4
Expand Down
14 changes: 12 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@
"thread": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp"
}
"valarray": "cpp",
"any": "cpp",
"ranges": "cpp",
"variant": "cpp",
"bit": "cpp",
"compare": "cpp",
"concepts": "cpp",
"stop_token": "cpp",
"numbers": "cpp",
"span": "cpp"
},
"C_Cpp.default.includePath": ["include"]
}
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ include $(DEVKITPRO)/libnx/switch_rules
# - <libnx folder>/default_icon.jpg
#---------------------------------------------------------------------------------
VERSION_MAJOR := 3
VERSION_MINOR := 1
VERSION_MINOR := 5
VERSION_MICRO := 0
NIGHTLY := 1
NIGHTLY :=

APP_TITLE := EdiZon
APP_AUTHOR := WerWolv
APP_TITLE := EdiZon SE
APP_AUTHOR := Tomvita

ifeq ($(NIGHTLY), 1)
APP_VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO} - Nightly
Expand Down
Binary file modified icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 105 additions & 21 deletions include/guis/gui_cheats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
#include <set>
#include <unordered_map>
#include <stdbool.h>

#include <time.h>
#include "helpers/debugger.hpp"
#include "helpers/memory_dump.hpp"

#include "helpers/dmntcht.h"
enum
{
FORMAT_DEC,
FORMAT_HEX
} m_searchValueFormat = FORMAT_DEC;

class GuiCheats : public Gui {
class GuiCheats : public Gui
{

public:
GuiCheats();
Expand All @@ -27,31 +33,107 @@ class GuiCheats : public Gui {

private:
Debugger *m_debugger;
u8 m_ramBuffer[0x10 * 14] = { 0 };
color_t m_memory[1024] = { 0 };
u8 m_ramBuffer[0x10 * 14] = {0};
color_t m_memory[1024] = {0};

u8 m_selectedEntry = 0;

u8 m_searchValueIndex = 0;
u32 m_addresslist_offset = 0;

searchValue_t m_searchValue[2];
enum { FORMAT_DEC, FORMAT_HEX } m_searchValueFormat = FORMAT_DEC;

enum { CHEATS, CANDIDATES } m_menuLocation = CHEATS;
enum { SEARCH_NONE, SEARCH_TYPE, SEARCH_MODE, SEARCH_REGION, SEARCH_VALUE } m_searchMenuLocation = SEARCH_NONE;
enum
{
CHEATS,
CANDIDATES
} m_menuLocation = CHEATS;
enum
{
SEARCH_NONE,
SEARCH_TYPE,
SEARCH_MODE,
SEARCH_REGION,
SEARCH_VALUE,
SEARCH_editRAM,
SEARCH_POINTER
} m_searchMenuLocation = SEARCH_NONE;

searchType_t m_searchType = SEARCH_TYPE_NONE;
searchMode_t m_searchMode = SEARCH_MODE_NONE;
searchRegion_t m_searchRegion = SEARCH_REGION_NONE;

std::vector<MemoryInfo> m_memoryInfo;
std::vector<MemoryInfo> m_targetmemInfos;

MemoryDump *m_memoryDump;
MemoryDump *m_memoryDump1;
MemoryDump *m_memoryDumpBookmark;
MemoryDump *m_AttributeDumpBookmark;
MemoryDump *m_pointeroffsetDump;
MemoryDump *m_dataDump;
u64 m_target = 0;
u64 m_numoffset = 3;
u64 m_max_source = 200;
u64 m_max_depth = 2;
u64 m_max_range = 0x300;
u64 m_low_main_heap_addr = 0x100000000;
u64 m_high_main_heap_addr = 0x10000000000;

std::map<u64, u64> m_frozenAddresses;

bool m_cheatsPresent = false;
bool m_sysmodulePresent = false;
bool m_editRAM = false;
bool m_nothingchanged = false;

u64 m_addressSpaceBaseAddr = 0x00;
u64 m_addressSpaceSize = 0x00;
u64 m_heapBaseAddr = 0x00;
u64 m_mainBaseAddr = 0x00;

u64 m_EditorBaseAddr = 0x00;
u8 m_addressmod = 0;
time_t m_Time1;
struct helperinfo_t
{
u64 address;
u64 size;
u64 count;
};
struct sourceinfo_t
{
u64 foffset;
u64 offset;
};

#define MAX_NUM_SOURCE_POINTER 200 // bound check for debugging;
#define MAX_POINTER_DEPTH 6 // up to 4 seems OK with forward only search took 94s. 215s for big dump
#define MAX_POINTER_RANGE 0x2000
#define MAX_POINTER_TARGET 3
bool m_forwardonly = false;
bool m_forwarddump = false; // reduce from 138 to 26

struct pointer_chain_t
{
u64 depth;
u64 offset[MAX_POINTER_DEPTH + 1]; // offset to address pointed by pointer
// below is for debugging can consider removing;
u64 fileoffset[MAX_POINTER_DEPTH + 1]; // offset to the file that has the address where the pointer was stored in this instance for debugging
};
struct bookmark_t
{
char label[18];
searchType_t type;
pointer_chain_t pointer;
};
pointer_chain_t m_hitcount;

// void startpointersearch(u64 address, u64 depth, u64 range, u64 num, MemoryDump **displayDump);
// void startpointersearch(u64 address, u64 depth, u64 range, u64 num, MemoryDump **displayDump);
// void pointersearch(u64 targetaddress, MemoryDump **displayDump, MemoryDump **dataDump, pointer_chain_t pointerchain);
void pointersearch(u64 targetaddress, struct pointer_chain_t pointerchain);
void pointercheck();
void startpointersearch(u64 targetaddress); //, MemoryDump **displayDump);
void searchpointer(u64 address, u64 depth, u64 range, pointer_chain_t pointerchain);
u64 m_heapSize = 0;
u64 m_mainSize = 0;

Expand All @@ -62,24 +144,26 @@ class GuiCheats : public Gui {

void drawSearchRAMMenu();

void drawEditRAMMenu();
void drawSearchPointerMenu();
void searchMemoryAddressesPrimary(Debugger *debugger, searchValue_t searchValue1,
searchValue_t searchValue2, searchType_t searchType,
searchMode_t searchMode, searchRegion_t searchRegion,
MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);
searchValue_t searchValue2, searchType_t searchType,
searchMode_t searchMode, searchRegion_t searchRegion,
MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);

void searchMemoryAddressesSecondary(Debugger *debugger, searchValue_t searchValue1,
searchValue_t searchValue2, searchType_t searchType,
searchMode_t searchMode, MemoryDump **displayDump);
searchValue_t searchValue2, searchType_t searchType,
searchMode_t searchMode, MemoryDump **displayDump);

void searchMemoryValuesPrimary(Debugger *debugger, searchType_t searchType, searchMode_t searchMode,
searchRegion_t searchRegion, MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);

searchRegion_t searchRegion, MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);

void searchMemoryValuesSecondary(Debugger *debugger, searchType_t searchType,
searchMode_t searchMode, searchRegion_t searchRegion,
MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);
searchMode_t searchMode, searchRegion_t searchRegion,
MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);

void searchMemoryValuesTertiary(Debugger *debugger, searchType_t searchType,
searchMode_t searchMode, searchRegion_t searchRegion,
MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);
void searchMemoryValuesTertiary(Debugger *debugger, searchValue_t searchValue1,
searchValue_t searchValue2, searchType_t searchType,
searchMode_t searchMode, searchRegion_t searchRegion,
MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);
};
92 changes: 92 additions & 0 deletions include/guis/gui_cheats.hpp1
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#pragma once

#include "guis/gui.hpp"
#include "types.h"

#include <vector>
#include <set>
#include <unordered_map>
#include <stdbool.h>
#include <time.h>
#include "helpers/debugger.hpp"
#include "helpers/memory_dump.hpp"

#include "helpers/dmntcht.h"
enum { FORMAT_DEC, FORMAT_HEX } m_searchValueFormat = FORMAT_DEC;

class GuiCheats : public Gui {

public:
GuiCheats();
~GuiCheats();

void update();
void draw();
void onInput(u32 kdown);
void onTouch(touchPosition &touch);
void onGesture(touchPosition startPosition, touchPosition endPosition, bool finish);

private:
Debugger *m_debugger;
u8 m_ramBuffer[0x10 * 14] = { 0 };
color_t m_memory[1024] = { 0 };

u8 m_selectedEntry = 0;
u8 m_searchValueIndex = 0;
u8 m_addresslist_offset = 0;

searchValue_t m_searchValue[2];

enum { CHEATS, CANDIDATES } m_menuLocation = CHEATS;
enum { SEARCH_NONE, SEARCH_TYPE, SEARCH_MODE, SEARCH_REGION, SEARCH_VALUE } m_searchMenuLocation = SEARCH_NONE;

searchType_t m_searchType = SEARCH_TYPE_NONE;
searchMode_t m_searchMode = SEARCH_MODE_NONE;
searchRegion_t m_searchRegion = SEARCH_REGION_NONE;

std::vector<MemoryInfo> m_memoryInfo;
MemoryDump *m_memoryDump;
MemoryDump *m_memoryDump1;
MemoryDump *m_memoryDumpBookmark;


std::map<u64, u64> m_frozenAddresses;

bool m_cheatsPresent = false;
bool m_sysmodulePresent = false;

u64 m_addressSpaceBaseAddr = 0x00;
u64 m_heapBaseAddr = 0x00;
u64 m_mainBaseAddr = 0x00;

u64 m_heapSize = 0;
u64 m_mainSize = 0;

u8 m_buildID[0x20];

DmntCheatEntry *m_cheats;
u64 m_cheatCnt;

void drawSearchRAMMenu();

void searchMemoryAddressesPrimary(Debugger *debugger, searchValue_t searchValue1,
searchValue_t searchValue2, searchType_t searchType,
searchMode_t searchMode, searchRegion_t searchRegion,
MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);

void searchMemoryAddressesSecondary(Debugger *debugger, searchValue_t searchValue1,
searchValue_t searchValue2, searchType_t searchType,
searchMode_t searchMode, MemoryDump **displayDump);

void searchMemoryValuesPrimary(Debugger *debugger, searchType_t searchType, searchMode_t searchMode,
searchRegion_t searchRegion, MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);


void searchMemoryValuesSecondary(Debugger *debugger, searchType_t searchType,
searchMode_t searchMode, searchRegion_t searchRegion,
MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);

void searchMemoryValuesTertiary(Debugger *debugger, searchType_t searchType,
searchMode_t searchMode, searchRegion_t searchRegion,
MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);
};
14 changes: 8 additions & 6 deletions include/helpers/memory_dump.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,35 @@

#include <string>
#include <vector>

class MemoryDump {
extern bool print_details;
class MemoryDump
{
public:
MemoryDump(std::string filePath, DumpType dumpType, bool discardFile);
~MemoryDump();

void setBaseAddresses(u64 addrSpaceBase, u64 heapBase, u64 mainBase, u64 heapSize, u64 mainSize);
void setSearchParams(searchType_t searchDataType, searchMode_t searchMode, searchRegion_t searchRegion, searchValue_t searchValue1, searchValue_t searchValue2);

void setPointerSearchParams(u64 max_depth, u64 numoffset, u64 maxrange, u8 buildID[0x20]);
void addData(u8 *buffer, size_t bufferSize);
size_t size();
void clear();

int getData(u64 addr, void *buffer, size_t bufferSize);
int putData(u64 addr, void *buffer, size_t bufferSize);
u8 operator[](u64 index);

data_header_t getDumpInfo();
data_header_t getDumpInfo();

void setDumpType(enum DumpType dumpType);
void setDumpType(enum DumpType dumpType);
void flushBuffer();

private:
FILE *m_dumpFile;
std::string m_filePath;
std::vector<u8> m_data;

data_header_t m_dataHeader;
data_header_t m_dataHeader;

bool isFileOpen();
void writeHeader();
Expand Down
Loading

0 comments on commit 7a682ce

Please sign in to comment.