first commit
This commit is contained in:
commit
7dd9dd689e
40 changed files with 4100 additions and 0 deletions
41
Utils/ProgressReporter.cpp
Normal file
41
Utils/ProgressReporter.cpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#include "pch.h"
|
||||
#include "ProgressReporter.h"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
ProgressReporter::ProgressReporter(int totalItems, int barWidth)
|
||||
: m_total(totalItems), m_width(barWidth),
|
||||
m_lastDraw(std::chrono::steady_clock::now())
|
||||
{
|
||||
}
|
||||
|
||||
bool ProgressReporter::update(int currentIndex) {
|
||||
// Compute percent
|
||||
int percent = static_cast<int>(100.0 * currentIndex / (m_total - 1));
|
||||
if (percent == m_lastPercent) {
|
||||
// Throttle to ~30 FPS
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
if (std::chrono::duration_cast<std::chrono::milliseconds>(now - m_lastDraw).count() < 33)
|
||||
return false;
|
||||
}
|
||||
m_lastPercent = percent;
|
||||
m_lastDraw = std::chrono::steady_clock::now();
|
||||
|
||||
// Build bar
|
||||
int pos = m_width * percent / 100;
|
||||
std::cout << "\r\33[2K[";
|
||||
|
||||
for (int i = 0; i < m_width; i++)
|
||||
std::cout << (i <= pos ? '#' : ' ');
|
||||
|
||||
std::cout
|
||||
<< "] " << std::fixed << std::setprecision(1)
|
||||
<< percent << "% (" << currentIndex << "/" << (m_total - 1) << ")"
|
||||
<< std::flush;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProgressReporter::finish() {
|
||||
std::cout << "\n";
|
||||
}
|
||||
21
Utils/ProgressReporter.h
Normal file
21
Utils/ProgressReporter.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
|
||||
class ProgressReporter {
|
||||
public:
|
||||
ProgressReporter(int totalItems, int barWidth = 50);
|
||||
|
||||
/// Call every iteration with the current index (0-based).
|
||||
/// Returns false if you should “throttle” (i.e. skip redraw).
|
||||
bool update(int currentIndex);
|
||||
|
||||
/// Call once at the end to clear or finalize the line.
|
||||
void finish();
|
||||
|
||||
private:
|
||||
int m_total;
|
||||
int m_width;
|
||||
int m_lastPercent{ -1 };
|
||||
std::chrono::steady_clock::time_point m_lastDraw;
|
||||
};
|
||||
126
Utils/ScriptJson.cpp
Normal file
126
Utils/ScriptJson.cpp
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
// https://github.com/thexeondev/GracefulDumper/blob/master/idapy-gen/src/lib.rs
|
||||
|
||||
#include "pch.h"
|
||||
#include "scriptjson.h"
|
||||
#include "Il2CppApi.h"
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void ScriptJsonGenerator::WriteEscapedString(stringstream& ss, const string& value) {
|
||||
for (char c : value) {
|
||||
switch (c) {
|
||||
case '"': ss << "\\\""; break;
|
||||
case '\\': ss << "\\\\"; break;
|
||||
case '\n': ss << "\\n"; break;
|
||||
case '\r': ss << "\\r"; break;
|
||||
case '\t': ss << "\\t"; break;
|
||||
default: ss << c; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
string ScriptJsonGenerator::GenerateJson() {
|
||||
stringstream ss;
|
||||
ss << "{";
|
||||
|
||||
// ScriptString (empty array)
|
||||
ss << "\"ScriptString\":[],";
|
||||
|
||||
// ScriptMetadata
|
||||
ss << "\"ScriptMetadata\":";
|
||||
WriteTypeMetadata(ss);
|
||||
ss << ",";
|
||||
|
||||
// ScriptMethod
|
||||
ss << "\"ScriptMethod\":";
|
||||
WriteMethods(ss);
|
||||
ss << ",";
|
||||
|
||||
// ScriptMetadataMethod
|
||||
ss << "\"ScriptMetadataMethod\":";
|
||||
WriteMethodRefs(ss);
|
||||
|
||||
ss << "}";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
void ScriptJsonGenerator::WriteMethods(stringstream& ss) {
|
||||
vector<string> entries;
|
||||
ss << "[";
|
||||
|
||||
for (int index = 0; index <= 56983; ++index) {
|
||||
if (Il2CppClass* klass = Il2CppApi::GetTypeInfoFromTypeDefinitionIndex(index)) {
|
||||
void* methodIter = nullptr;
|
||||
while (auto method = Il2CppApi::ClassGetMethods(klass, &methodIter)) {
|
||||
stringstream entry;
|
||||
entry << "{"
|
||||
<< "\"Address\":" << ((*(uint64_t*)((char*)method + 8)) - il2CppOffsets::gIBaseAddress) << ","
|
||||
<< "\"Name\":\"" << Il2CppApi::ClassGetName(klass) << "$$" << Il2CppApi::MethodGetName(method) << "\","
|
||||
<< "\"Signature\":\"\","
|
||||
<< "\"TypeSignature\":\"\""
|
||||
<< "}";
|
||||
entries.push_back(entry.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
if (i > 0) ss << ",";
|
||||
ss << entries[i];
|
||||
}
|
||||
ss << "]";
|
||||
}
|
||||
|
||||
void ScriptJsonGenerator::WriteTypeMetadata(stringstream& ss) {
|
||||
vector<string> entries;
|
||||
ss << "[";
|
||||
|
||||
for (int index = 0; index <= 56983; ++index) {
|
||||
if (Il2CppClass* klass = Il2CppApi::GetTypeInfoFromTypeDefinitionIndex(index)) {
|
||||
stringstream entry;
|
||||
entry << "{"
|
||||
<< "\"Address\":" << (reinterpret_cast<uintptr_t>(klass) - il2CppOffsets::gIBaseAddress) << ","
|
||||
<< "\"Name\":\"" << Il2CppApi::ClassGetName(klass) << "_TypeInfo\","
|
||||
<< "\"Signature\":\"" << Il2CppApi::ClassGetName(klass) << "_c*\""
|
||||
<< "}";
|
||||
entries.push_back(entry.str());
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
if (i > 0) ss << ",";
|
||||
ss << entries[i];
|
||||
}
|
||||
ss << "]";
|
||||
}
|
||||
|
||||
void ScriptJsonGenerator::WriteMethodRefs(stringstream& ss) {
|
||||
vector<string> entries;
|
||||
ss << "[";
|
||||
|
||||
for (int index = 0; index <= 56983; ++index) {
|
||||
if (Il2CppClass* klass = Il2CppApi::GetTypeInfoFromTypeDefinitionIndex(index)) {
|
||||
void* methodIter = nullptr;
|
||||
while (auto method = Il2CppApi::ClassGetMethods(klass, &methodIter)) {
|
||||
stringstream entry;
|
||||
entry << "{"
|
||||
<< "\"Address\":" << (reinterpret_cast<uintptr_t>(method) - il2CppOffsets::gIBaseAddress) << ","
|
||||
<< "\"Name\":\"" << Il2CppApi::ClassGetName(klass) << "_" << Il2CppApi::MethodGetName(method) << "\","
|
||||
<< "\"MethodAddress\":" << (*(uint64_t*)((char*)method + 8) - il2CppOffsets::gIBaseAddress)
|
||||
<< "}";
|
||||
entries.push_back(entry.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
if (i > 0) ss << ",";
|
||||
ss << entries[i];
|
||||
}
|
||||
ss << "]";
|
||||
}
|
||||
15
Utils/ScriptJson.h
Normal file
15
Utils/ScriptJson.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include "Il2CppApi.h"
|
||||
#include "Il2CppMetadata.h"
|
||||
|
||||
class ScriptJsonGenerator {
|
||||
public:
|
||||
static std::string GenerateJson();
|
||||
|
||||
private:
|
||||
static void WriteEscapedString(std::stringstream& ss, const std::string& value);
|
||||
static void WriteMethods(std::stringstream& ss);
|
||||
static void WriteTypeMetadata(std::stringstream& ss);
|
||||
static void WriteMethodRefs(std::stringstream& ss);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue