コード例 #1
0
ファイル: ShellLinkFile.cs プロジェクト: redrocktx/shellify
 public void SaveAs(string filename)
 {
     using (FileStream stream = new FileStream(filename, FileMode.Create))
     {
         using (BinaryWriter binaryWriter = new BinaryWriter(stream))
         {
             ShellLinkFileHandler writer = new ShellLinkFileHandler(this);
             writer.WriteTo(binaryWriter);
         }
     }
 }
コード例 #2
0
ファイル: ShellLinkFile.cs プロジェクト: redrocktx/shellify
 public static ShellLinkFile Load(byte[] data)
 {
     ShellLinkFile result = new ShellLinkFile();
     using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(data)))
     {
         ShellLinkFileHandler reader = new ShellLinkFileHandler(result);
         reader.ReadFrom(binaryReader);
         return result;
     }
 }
コード例 #3
0
ファイル: ShellLinkFile.cs プロジェクト: redrocktx/shellify
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static List<ShellLinkFile> LoadJumpList(string filename)
        {
            List<ShellLinkFile> results = new List<ShellLinkFile>();
            using (FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read))
            using (BinaryReader binaryReader = new BinaryReader(stream))
            {
                bool process = true;
                do
                {
                    // Seek until we get to a valid looking LNK header
                    bool search = true;
                    do
                    {
                        if (binaryReader.BaseStream.Position + 4 > binaryReader.BaseStream.Length)
                        {
                            return results;
                        }

                        byte[] data = new byte[4];

                        binaryReader.Read(data, 0, 4);

                        int ret = BitConverter.ToInt32(data, 0);
                        if (ret != 76) // Default LNK header length
                        {
                            continue;
                        }

                        if (binaryReader.BaseStream.Position + 16 > binaryReader.BaseStream.Length)
                        {
                            return results;
                        }

                        // Check the LNK file GUID e.g. {00021401-0000-0000-00C0-000000000046} or {01h,14h,02h,00h,00h,00h,00h,00h,C0h,00h,00h,00h,00h,00h,46h}
                        data = new byte[16];
                        binaryReader.Read(data, 0, 16);

                        if (ArraysEqual(data, LNK_GUID) == true)
                        {
                            binaryReader.BaseStream.Seek(-20, SeekOrigin.Current);

                            ShellLinkFile result = new ShellLinkFile();
                            ShellLinkFileHandler reader = new ShellLinkFileHandler(result);
                            reader.ReadFrom(binaryReader);

                            if (result.Header.CreationTime != DateTime.MinValue &
                                result.Header.AccessTime != DateTime.MinValue &
                                result.Header.WriteTime != DateTime.MinValue &
                                result.Header.CreationTime != ShellLinkFile.WindowsEpoch &
                                result.Header.AccessTime != ShellLinkFile.WindowsEpoch &
                                result.Header.WriteTime != ShellLinkFile.WindowsEpoch)
                            {
                                results.Add(result);
                                break;
                            }
                        }

                        // If we get this far then we have read 20 bytes, so lets go back 19 bytes and start again
                        binaryReader.BaseStream.Seek(-19, SeekOrigin.Current);
                    }
                    while (search == true);
                }
                while (process == true);

                return results;
            }
        }
コード例 #4
0
ファイル: ShellLinkFile.cs プロジェクト: redrocktx/shellify
 public static ShellLinkFile Load(string filename)
 {
     ShellLinkFile result = new ShellLinkFile();
     using (FileStream stream = new FileStream(filename, FileMode.Open))
     {
         using (BinaryReader binaryReader = new BinaryReader(stream))
         {
             ShellLinkFileHandler reader = new ShellLinkFileHandler(result);
             reader.ReadFrom(binaryReader);
             return result;
         }
     }
 }