mirror of https://github.com/x64dbg/btparser
Switch to size_t for sizes
This commit is contained in:
parent
07a7b308e8
commit
74474b8dd6
|
@ -11,7 +11,7 @@ using namespace Types;
|
||||||
|
|
||||||
TypeManager::TypeManager(size_t pointerSize)
|
TypeManager::TypeManager(size_t pointerSize)
|
||||||
{
|
{
|
||||||
auto p = [this](const std::string & n, Primitive p, int size)
|
auto p = [this](const std::string & n, Primitive p, size_t size)
|
||||||
{
|
{
|
||||||
primitivesizes[p] = size;
|
primitivesizes[p] = size;
|
||||||
auto splits = StringUtils::Split(n, ',');
|
auto splits = StringUtils::Split(n, ',');
|
||||||
|
@ -96,7 +96,7 @@ bool TypeManager::AddUnion(const std::string & owner, const std::string & name)
|
||||||
return addStructUnion(u);
|
return addStructUnion(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TypeManager::AddMember(const std::string & parent, const QualifiedType& type, const std::string & name, int arrsize, int offset)
|
bool TypeManager::AddMember(const std::string & parent, const QualifiedType& type, const std::string & name, size_t arrsize, int offset)
|
||||||
{
|
{
|
||||||
if(!isDefined(type.name))
|
if(!isDefined(type.name))
|
||||||
return false;
|
return false;
|
||||||
|
@ -129,7 +129,7 @@ bool TypeManager::AddMember(const std::string & parent, const QualifiedType& typ
|
||||||
pad.type = QualifiedType("char");
|
pad.type = QualifiedType("char");
|
||||||
pad.arrsize = offset - s.size;
|
pad.arrsize = offset - s.size;
|
||||||
char padname[32] = "";
|
char padname[32] = "";
|
||||||
sprintf_s(padname, "padding%d", pad.arrsize);
|
sprintf_s(padname, "padding%zu", pad.arrsize);
|
||||||
pad.name = padname;
|
pad.name = padname;
|
||||||
s.members.push_back(pad);
|
s.members.push_back(pad);
|
||||||
s.size += pad.arrsize;
|
s.size += pad.arrsize;
|
||||||
|
@ -150,7 +150,7 @@ bool TypeManager::AddMember(const std::string & parent, const QualifiedType& typ
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TypeManager::AppendMember(const QualifiedType& type, const std::string & name, int arrsize, int offset)
|
bool TypeManager::AppendMember(const QualifiedType& type, const std::string & name, size_t arrsize, int offset)
|
||||||
{
|
{
|
||||||
return AddMember(laststruct, type, name, arrsize, offset);
|
return AddMember(laststruct, type, name, arrsize, offset);
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ bool TypeManager::AppendArg(const QualifiedType& type, const std::string & name)
|
||||||
return AddArg(lastfunction, type, name);
|
return AddArg(lastfunction, type, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TypeManager::Sizeof(const std::string& type) const
|
size_t TypeManager::Sizeof(const std::string& type) const
|
||||||
{
|
{
|
||||||
auto foundT = types.find(type);
|
auto foundT = types.find(type);
|
||||||
if(foundT != types.end())
|
if(foundT != types.end())
|
||||||
|
@ -227,7 +227,7 @@ int TypeManager::Sizeof(const std::string& type) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TypeManager::Sizeof(const QualifiedType& type) const
|
size_t TypeManager::Sizeof(const QualifiedType& type) const
|
||||||
{
|
{
|
||||||
if (type.isPointer())
|
if (type.isPointer())
|
||||||
return primitivesizes.at(Pointer);
|
return primitivesizes.at(Pointer);
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Types
|
||||||
std::string owner; //Type owner
|
std::string owner; //Type owner
|
||||||
std::string name; //Type identifier.
|
std::string name; //Type identifier.
|
||||||
Primitive primitive = Void; //Primitive type.
|
Primitive primitive = Void; //Primitive type.
|
||||||
int size = 0; //Size in bytes.
|
size_t size = 0; //Size in bytes.
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QualifiedType
|
struct QualifiedType
|
||||||
|
@ -91,7 +91,7 @@ namespace Types
|
||||||
{
|
{
|
||||||
std::string name; //Member identifier
|
std::string name; //Member identifier
|
||||||
QualifiedType type; // Qualified Type
|
QualifiedType type; // Qualified Type
|
||||||
int arrsize = 0; //Number of elements if Member is an array (unused for function arguments)
|
size_t arrsize = 0; //Number of elements if Member is an array (unused for function arguments)
|
||||||
int offset = -1; //Member offset (only stored for reference)
|
int offset = -1; //Member offset (only stored for reference)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ namespace Types
|
||||||
std::vector<Member> members; //StructUnion members
|
std::vector<Member> members; //StructUnion members
|
||||||
std::vector<Function> vtable;
|
std::vector<Function> vtable;
|
||||||
bool isunion = false; //Is this a union?
|
bool isunion = false; //Is this a union?
|
||||||
int size = 0;
|
size_t size = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EnumValue
|
struct EnumValue
|
||||||
|
@ -164,7 +164,7 @@ namespace Types
|
||||||
std::string kind;
|
std::string kind;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string owner;
|
std::string owner;
|
||||||
int size = 0;
|
size_t size = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit TypeManager(size_t pointerSize);
|
explicit TypeManager(size_t pointerSize);
|
||||||
|
@ -173,14 +173,14 @@ namespace Types
|
||||||
bool AddEnum(const std::string& owner, const std::string& name, const std::string & type);
|
bool AddEnum(const std::string& owner, const std::string& name, const std::string & type);
|
||||||
bool AddStruct(const std::string & owner, const std::string & name);
|
bool AddStruct(const std::string & owner, const std::string & name);
|
||||||
bool AddUnion(const std::string & owner, const std::string & name);
|
bool AddUnion(const std::string & owner, const std::string & name);
|
||||||
bool AddMember(const std::string & parent, const QualifiedType & type, const std::string & name, int arrsize = 0, int offset = -1);
|
bool AddMember(const std::string & parent, const QualifiedType & type, const std::string & name, size_t arrsize = 0, int offset = -1);
|
||||||
bool AppendMember(const QualifiedType & type, const std::string & name, int arrsize = 0, int offset = -1);
|
bool AppendMember(const QualifiedType & type, const std::string & name, size_t arrsize = 0, int offset = -1);
|
||||||
bool AddFunction(const std::string & owner, const std::string & name, const QualifiedType& rettype, CallingConvention callconv = Cdecl, bool noreturn = false, bool typeonly = false);
|
bool AddFunction(const std::string & owner, const std::string & name, const QualifiedType& rettype, CallingConvention callconv = Cdecl, bool noreturn = false, bool typeonly = false);
|
||||||
bool AddEnumerator(const std::string& enumType, const std::string& name, uint64_t value);
|
bool AddEnumerator(const std::string& enumType, const std::string& name, uint64_t value);
|
||||||
bool AddArg(const std::string & function, const QualifiedType & type, const std::string & name);
|
bool AddArg(const std::string & function, const QualifiedType & type, const std::string & name);
|
||||||
bool AppendArg(const QualifiedType& type, const std::string & name);
|
bool AppendArg(const QualifiedType& type, const std::string & name);
|
||||||
int Sizeof(const QualifiedType& type) const;
|
size_t Sizeof(const QualifiedType& type) const;
|
||||||
int Sizeof(const std::string& type) const;
|
size_t Sizeof(const std::string& type) const;
|
||||||
bool Visit(const std::string & type, const std::string & name, Visitor & visitor) const;
|
bool Visit(const std::string & type, const std::string & name, Visitor & visitor) const;
|
||||||
void Clear(const std::string & owner = "");
|
void Clear(const std::string & owner = "");
|
||||||
bool RemoveType(const std::string & type);
|
bool RemoveType(const std::string & type);
|
||||||
|
@ -191,7 +191,7 @@ namespace Types
|
||||||
bool GenerateStubs() const;
|
bool GenerateStubs() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<Primitive, int> primitivesizes;
|
std::unordered_map<Primitive, size_t> primitivesizes;
|
||||||
std::unordered_map<Primitive, std::string> primitivenames;
|
std::unordered_map<Primitive, std::string> primitivenames;
|
||||||
std::unordered_map<std::string, Type> types;
|
std::unordered_map<std::string, Type> types;
|
||||||
std::unordered_map<std::string, Types::Enum> enums;
|
std::unordered_map<std::string, Types::Enum> enums;
|
||||||
|
|
Loading…
Reference in New Issue