Пример #1
0
        internal static string ReadCString(IImageStream stream)
        {
            var value = Encoding.UTF8.GetString(stream.ReadBytesUntilByte(0));

            stream.Position++;
            return(value);
        }
Пример #2
0
        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;
                }
            }
        }
Пример #3
0
        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);
        }
Пример #4
0
        // 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));
        }
Пример #5
0
        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);
        }
Пример #6
0
		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;
			}
		}
Пример #7
0
		internal static string ReadCString(IImageStream stream) {
			var value = Encoding.UTF8.GetString(stream.ReadBytesUntilByte(0));
			stream.Position++;
			return value;
		}