internal static string ReadCString(IImageStream stream) { var value = Encoding.UTF8.GetString(stream.ReadBytesUntilByte(0)); stream.Position++; return(value); }
void Populate(IImageStream reader) { reader.Position = 1; while (reader.Position < reader.Length) { uint offset = (uint)reader.Position; var bytes = reader.ReadBytesUntilByte(0); if (bytes == null) { break; } reader.ReadByte(); // terminating zero if (bytes.Length == 0) { continue; } var s = new UTF8String(bytes); if (!cachedDict.ContainsKey(s)) { cachedDict[s] = offset; } } }
string ReadAsciizId(uint?rva) { if (rva == null || rva.Value == 0) { return(null); } reader.Position = (long)peImage.ToFileOffset((RVA)rva.Value); var bytes = reader.ReadBytesUntilByte(0); const int MIN_ID_LEN = 2; const int MAX_ID_LEN = 256; if (bytes == null || bytes.Length < MIN_ID_LEN || bytes.Length > MAX_ID_LEN) { return(null); } foreach (var b in bytes) { var ch = (char)b; if (!(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') || ('0' <= ch && ch <= '9') || ch == '_' || ch == '.')) { return(null); } } var s = Encoding.ASCII.GetString(bytes); if (char.IsNumber(s[0])) { return(null); } return(s); }
// If this method gets updated, also update the writer (ManagedExportsWriter) static string ReadMethodNameASCIIZ(IImageStream reader, long offset) { reader.Position = offset; var stringData = reader.ReadBytesUntilByte(0); return(Encoding.UTF8.GetString(stringData)); }
internal static string ReadCString(IImageStream stream) { var bytes = stream.ReadBytesUntilByte(0); if (bytes == null) { return(string.Empty); } var value = Encoding.UTF8.GetString(bytes); stream.Position++; return(value); }
void Populate(IImageStream reader) { reader.Position = 1; while (reader.Position < reader.Length) { uint offset = (uint)reader.Position; var bytes = reader.ReadBytesUntilByte(0); if (bytes == null) break; reader.ReadByte(); // terminating zero if (bytes.Length == 0) continue; var s = new UTF8String(bytes); if (!cachedDict.ContainsKey(s)) cachedDict[s] = offset; } }
internal static string ReadCString(IImageStream stream) { var value = Encoding.UTF8.GetString(stream.ReadBytesUntilByte(0)); stream.Position++; return value; }