Beispiel #1
0
        /// <summary>Get message block entries from starting address</summary>
        /// <param name="reader">Mapped bytes</param>
        /// <param name="block">message block header</param>
        /// <exception cref="T:NotImplementedException">Unknown string encoding specified</exception>
        /// <returns></returns>
        private IEnumerable <ResourceMessageTable.MessageResourceEntry> GetMessageBlockEntries(PinnedBufferReader reader, WinNT.Resource.MESSAGE_RESOURCE_BLOCK block)
        {
            UInt32 padding = block.OffsetToEntries;
            UInt32 entryId = block.LowId;

            while (entryId <= block.HighId)
            {
                WinNT.Resource.MESSAGE_RESOURCE_ENTRY entry = reader.BytesToStructure <WinNT.Resource.MESSAGE_RESOURCE_ENTRY>(ref padding);

                String message;
                switch (entry.Flags)
                {
                case WinNT.Resource.ResourceEncodingType.Ansi:
                    message = System.Text.Encoding.ASCII.GetString(reader.GetBytes(padding, entry.MessageLength));
                    break;

                case WinNT.Resource.ResourceEncodingType.Unicode:
                    message = System.Text.Encoding.Unicode.GetString(reader.GetBytes(padding, entry.MessageLength));
                    break;

                default:
                    throw new NotImplementedException();
                }
                yield return(new ResourceMessageTable.MessageResourceEntry()
                {
                    EntryId = entryId, EntryName = message,
                });

                padding += entry.MessageLength;
                entryId++;
            }
        }
Beispiel #2
0
 /// <summary>Get all messages from block</summary>
 /// <param name="block">Message block from witch read all messages</param>
 /// <returns>Messages array</returns>
 public IEnumerable <ResourceMessageTable.MessageResourceEntry> GetMessageBlockEntries(WinNT.Resource.MESSAGE_RESOURCE_BLOCK block)
 {
     using (PinnedBufferReader reader = base.CreateDataReader())
         return(this.GetMessageBlockEntries(reader, block));
 }