80 lines
No EOL
2 KiB
C++
80 lines
No EOL
2 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <cstdint>
|
|
#include <algorithm>
|
|
#include <map>
|
|
#include <optional>
|
|
|
|
#include "Il2CppHelper.h"
|
|
|
|
#include "ProtoUtil.h"
|
|
#include "ProtoCache.h"
|
|
#include "ProtoOutput.h"
|
|
|
|
// Constantes equivalentes a cadenas estáticas de Rust
|
|
constexpr const char* CODED_INPUT_STREAM = "CELNCCLEKFP";
|
|
constexpr const char* MERGE_FROM = "MMANOOLJPGC";
|
|
constexpr const char* GET_CMD_ID = "PIGAAPNKIGC";
|
|
constexpr const char* PROTO_CLASS = "KKAGGNDBDHE";
|
|
constexpr const char* BYTE_STRING = "HIHGFFMNNDN";
|
|
|
|
struct CachedFieldInfo {
|
|
int field_number;
|
|
int wire_type;
|
|
size_t offset;
|
|
bool is_enum;
|
|
bool is_object;
|
|
};
|
|
|
|
// Equivalente a OneofVariantInfo
|
|
struct OneofVariantInfo {
|
|
size_t oneof_enum_offset;
|
|
const Il2CppType* variant_type;
|
|
};
|
|
|
|
// Equivalente a FieldMinimalInfo
|
|
struct FieldMinimalInfo {
|
|
uint32_t xor_;
|
|
size_t offset;
|
|
uint32_t tag;
|
|
std::optional<OneofVariantInfo> oneof_extra_data;
|
|
};
|
|
|
|
// Equivalente a MessageMinimalInfo
|
|
struct MessageMinimalInfo {
|
|
uint16_t cmd_id;
|
|
std::vector<FieldMinimalInfo> fields;
|
|
|
|
MessageMinimalInfo(uint16_t cmd_id_) : cmd_id(cmd_id_) {}
|
|
};
|
|
|
|
// Equivalente a FieldDetectionInfo
|
|
struct FieldDetectionInfo {
|
|
size_t offset;
|
|
std::optional<OneofVariantInfo> oneof_extra_data;
|
|
};
|
|
|
|
class Bruteforcer {
|
|
public:
|
|
Il2CppObject* object;
|
|
const uint8_t* merge_from_method;
|
|
|
|
std::vector<CachedFieldInfo> cached_fields;
|
|
|
|
// Constructor
|
|
Bruteforcer(TypeCache type_cache, Il2CppObject* obj);
|
|
// Método input
|
|
std::optional<FieldDetectionInfo> input(uint32_t wire_tag);
|
|
private:
|
|
std::optional<int> build_field_number(uint32_t wire_tag);
|
|
std::optional<FieldDetectionInfo> build_field_oneof(uint32_t wire_tag);
|
|
};
|
|
|
|
class ProtoMetadata {
|
|
public:
|
|
static std::string DumpProto(Il2CppClass* klass);
|
|
static Il2CppObject* CreateInputStream(const std::vector<uint8_t>& buf);
|
|
private:
|
|
static std::string CsharpTypeToProtobufType(const TypeCache& cache, const Il2CppType* ty);
|
|
}; |