private void Guess(int off, bool auto = false)
{
if (off + 4 >= memsize)
return;
uint n = BitConverter.ToUInt32(memory, off);
if (n >= Names.Length)
return;
string s = Names[n];
for (int i = 0; i < Definitions.Count; i++)
if (tempClass == Definitions[i].name)
for (int j = 0; j < Definitions[i].props.Count; j++)
{
if (Definitions[i].props[j].name + "\0" == s)
{
int pos = off;
Property p = Definitions[i].props[j];
for (int k = 0; k < Definitions[i].props[j].Meta.Count; k++)
{
UPropertyReader.PropertyMeta m = Definitions[i].props[j].Meta[k];
if (m.type == 0)
switch (m.size)
{
case 1:
p.value += memory[pos] + " ";
break;
case 2:
p.value += BitConverter.ToUInt16(memory, pos) + " ";
break;
case 4:
p.value += BitConverter.ToUInt32(memory, pos) + " ";
break;
}
if (m.type == 1)
switch (m.size)
{
case 2:
p.value += getFloat16(pos) + " ";
break;
case 4:
p.value += BitConverter.ToSingle(memory, pos) + " ";
break;
default:
p.value += "";
break;
}
if (m.type == 2)
{
uint z = BitConverter.ToUInt32(memory, pos);
if (z >= 0 && z < Names.Count() && k != 0)
p.value += clr0(Names[z]) + " ";
}
pos += m.size;
}
p.raw = new byte[pos - off];
p.offset = off;
for (int k = 0; k < pos - off; k++)
p.raw[k] = memory[off + k];
tempProps.Add(p);
if (auto)
{
Guess(pos, auto);
return;
}
}
if (s == "ArrayProperty\0")
{
int pos = off;
int len = BitConverter.ToInt32(memory, pos + 8);
int count = BitConverter.ToInt32(memory, pos + 16);
int size;
if (count == 0)
size = len;
else
size = (len - 4) / count;
Property p = new Property();
p.offset = pos;
pos += 20;
p.name = s;
for(int k=0;k<count;k++)
{
switch(size)
{
case 1:
p.value += memory[pos] + " ";
pos += 4;
break;
case 2:
p.value += BitConverter.ToUInt16(memory, pos) + " ";
pos += 4;
break;
case 4:
p.value += BitConverter.ToUInt32(memory, pos) + " ";
pos += 4;
break;
default :
p.value = "";
pos += size;
break;
}
}
p.raw = new byte[pos - off];
for (int k = 0; k < pos - off; k++)
p.raw[k] = memory[off + k];
tempProps.Add(p);
if (auto)
{
Guess(pos, auto);
return;
}
}
if (s == "StrProperty\0")
{
int pos = off;
int len = BitConverter.ToInt32(memory, pos + 16)*-1;
Property p = new Property();
p.offset = pos;
pos += 20;
p.name = s;
p.value = "";
for (int k = 0; k < len; k++)
{
p.value += (char)memory[pos];
pos += 2;
}
p.raw = new byte[pos - off];
for (int k = 0; k < pos - off; k++)
p.raw[k] = memory[off + k];
tempProps.Add(p);
if (auto)
{
Guess(pos, auto);
return;
}
}
if (s == "m_aObjComment\0")
{
int pos = off;
int len = BitConverter.ToInt32(memory, pos + 28) * -1;
Property p = new Property();
p.offset = pos;
pos += 32;
p.name = s;
p.value = "";
for (int k = 0; k < len; k++)
{
p.value += (char)memory[pos];
pos += 2;
}
p.raw = new byte[pos - off];
for (int k = 0; k < pos - off; k++)
p.raw[k] = memory[off + k];
tempProps.Add(p);
if (auto)
{
Guess(pos, auto);
return;
}
}
}
}