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