예제 #1
0
        private FileItem ConvertLnk4ToGeneral(Lnk4FileItem item, string fileName)
        {
            FileItem FileItem = new FileItem(this.container);

            FileItem.FileName   = fileName;
            FileItem.FileOffset = item.startOffset + this.dataOffset;
            FileItem.FileSize   = item.length;
            return(FileItem);
        }
예제 #2
0
        private Lnk4FileItem ConvertGeneralToLnk4(FileItem item, uint fileId)
        {
            Lnk4FileItem FileItem = new Lnk4FileItem();

            FileItem.fileId      = fileId;
            FileItem.startOffset = (uint)(item.FileOffset - this.dataOffset);
            FileItem.length      = item.FileSize;
            return(FileItem);
        }
예제 #3
0
        /// <summary>
        /// Parse the file table.
        /// </summary>
        /// <returns>Number of files found.</returns>
        public override int ParseFileTable()
        {
            long offset = 8;
            uint fid    = 0;

            this.fileTable = new List <FileItem>();

            string fileNameBase;

            { // Get file name base
                int fileNameStart = this.container.Name.LastIndexOf('\\') + 1;
                int fileNameEnd   = this.container.Name.LastIndexOf('.');
                if (fileNameEnd == -1)
                {
                    fileNameEnd = this.container.Name.Length;
                }
                fileNameBase = this.container.Name.Substring(fileNameStart, fileNameEnd - fileNameStart);
            }

            while (true)
            {
                Lnk4FileItem item = new Lnk4FileItem();
                item.fileId      = fid;
                item.startOffset = StreamUtility.ReadUIntFromStream(this.container, offset, false) << 11;
                offset          += 4;
                item.length      = StreamUtility.ReadUIntFromStream(this.container, offset, false) << 10;
                offset          += 4;

                if (item.isValid())
                {
                    FileItem FileItem       = ConvertLnk4ToGeneral(item, fileNameBase + "-" + Convert.ToSingle(item.fileId));
                    uint     fileIdentifier = StreamUtility.ReadUIntFromStream(this.container, FileItem.FileOffset);
                    string   fileExt        = StreamUtility.GetFileExtension(fileIdentifier);
                    FileItem.FileName += "." + fileExt;
                    fileTable.Add(FileItem);
                }
                else
                {
                    break;
                }

                fid++;
            }

            return(fileTable.Count);
        }