Move method to Utils.cs
This commit is contained in:
parent
d2ec4e2969
commit
e75386d0f9
|
@ -232,5 +232,22 @@ namespace de4dot.code {
|
||||||
return fileData;
|
return fileData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static uint readEncodedUInt32(BinaryReader reader) {
|
||||||
|
uint val = 0;
|
||||||
|
int bits = 0;
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
byte b = reader.ReadByte();
|
||||||
|
val |= (uint)(b & 0x7F) << bits;
|
||||||
|
if ((b & 0x80) == 0)
|
||||||
|
return val;
|
||||||
|
bits += 7;
|
||||||
|
}
|
||||||
|
throw new ApplicationException("Invalid encoded int32");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int readEncodedInt32(BinaryReader reader) {
|
||||||
|
return (int)readEncodedUInt32(reader);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,14 +154,12 @@ namespace de4dot.code.resources {
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint readUInt32(BinaryReader reader) {
|
static uint readUInt32(BinaryReader reader) {
|
||||||
uint val = 0;
|
try {
|
||||||
for (int i = 0; i < 5; i++) {
|
return Utils.readEncodedUInt32(reader);
|
||||||
byte b = reader.ReadByte();
|
}
|
||||||
val |= b;
|
catch {
|
||||||
if ((b & 0x80) == 0)
|
throw new ResourceReaderException("Invalid encoded int32");
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
throw new ResourceReaderException("Invalid encoded int32");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkReaders() {
|
bool checkReaders() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user