private IEnumerable <CIDSizeInfo> ProcessRecentKey(RegistryKey key) { var l = new List <CIDSizeInfo>(); try { var mruList = key.Values.Single(t => t.ValueName == "MRUListEx"); var mruPositions = new Dictionary <uint, int>(); var i = 0; var index = 0; var mruPos = BitConverter.ToUInt32(mruList.ValueDataRaw, index); index += 4; while (mruPos != 0xFFFFFFFF) { mruPositions.Add(mruPos, i); i++; mruPos = BitConverter.ToUInt32(mruList.ValueDataRaw, index); index += 4; } //mruPositions now contains a map of positions (the key) to the order it was opened (the value) foreach (var keyValue in key.Values) { if (keyValue.ValueName == "MRUListEx") { continue; } var mru = mruPositions[uint.Parse(keyValue.ValueName)]; var chunks = Encoding.Unicode.GetString(keyValue.ValueDataRaw).Split('\0'); var exeName = chunks[0]; DateTimeOffset?openedOn = null; if (mru == 0) { openedOn = key.LastWriteTime; } var ff = new CIDSizeInfo(exeName, mru, openedOn); l.Add(ff); } } catch (Exception ex) { Errors.Add($"Error processing CIDSizeMRU key: {ex.Message}"); } if (Errors.Count > 0) { AlertMessage = "Errors detected. See Errors information in lower right corner of plugin window"; } return(l.OrderBy(t => t.MRUPosition)); }
private IEnumerable<CIDSizeInfo> ProcessRecentKey(RegistryKey key) { var l = new List<CIDSizeInfo>(); try { var mruList = key.Values.Single(t => t.ValueName == "MRUListEx"); var mruPositions = new Dictionary<uint, int>(); var i = 0; var index = 0; var mruPos = BitConverter.ToUInt32(mruList.ValueDataRaw, index); index += 4; while (mruPos != 0xFFFFFFFF) { mruPositions.Add(mruPos, i); i++; mruPos = BitConverter.ToUInt32(mruList.ValueDataRaw, index); index += 4; } //mruPositions now contains a map of positions (the key) to the order it was opened (the value) foreach (var keyValue in key.Values) { if (keyValue.ValueName == "MRUListEx") { continue; } var mru = mruPositions[uint.Parse(keyValue.ValueName)]; var chunks = Encoding.Unicode.GetString(keyValue.ValueDataRaw).Split('\0'); var exeName = chunks[0]; DateTimeOffset? openedOn = null; if (mru == 0) { openedOn = key.LastWriteTime; } var ff = new CIDSizeInfo(exeName, mru, openedOn); l.Add(ff); } } catch (Exception ex) { Errors.Add($"Error processing CIDSizeMRU key: {ex.Message}"); } if (Errors.Count > 0) { AlertMessage = "Errors detected. See Errors information in lower right corner of plugin window"; } return l.OrderBy(t => t.MRUPosition); }