Exemplo n.º 1
0
        private Dictionary <Address32, ImportReference> LoadImports()
        {
            Dictionary <Address32, ImportReference> imports = new Dictionary <Address32, ImportReference>();

            XbeLibrary kernelLibrary = new XbeLibrary(rdr.ReadAt(ctx.KernelLibraryAddress - ctx.BaseAddress, (rdr) =>
            {
                return(rdr.ReadStruct <XbeLibraryVersion>());
            }));

            rdr.Seek(ctx.KernelThunkAddress - ctx.BaseAddress, System.IO.SeekOrigin.Begin);

            for (uint i = 0; ; i++)
            {
                Address32 ordinalAddress = (Address32)ctx.KernelThunkAddress.Add(i * 4);
                if (!rdr.TryReadUInt32(out uint dword))
                {
                    throw new BadImageFormatException("Unexpected EOF while reading import table.");
                }
                if (dword == 0)
                {
                    break;
                }
                else if ((dword >> 31) == 0)
                {
                    throw new NotSupportedException("Named ordinals not expected in XBE files.");
                }
                int ordinalValue = (int)(dword & 0x7FFFFFFF);
                imports.Add(ordinalAddress, new OrdinalImportReference(ordinalAddress, kernelLibrary.LibraryName, ordinalValue, SymbolType.ExternalProcedure));
            }

            return(imports);
        }
Exemplo n.º 2
0
        public bool ReadDirectorySector(LeImageReader rdr, List <ArchiveDirectoryEntry> entries)
        {
            byte nextDirTrack  = 0;
            byte nextDirSector = 0;

            for (int i = 0; i < 8; ++i)
            {
                if (i == 0)
                {
                    nextDirTrack  = rdr.ReadByte();
                    nextDirSector = rdr.ReadByte();
                }
                else
                {
                    rdr.Seek(2);
                }
                var fileType   = (FileType)rdr.ReadByte();
                var fileTrack  = rdr.ReadByte();
                var fileSector = rdr.ReadByte();
                var sName      = Encoding.ASCII.GetString(rdr.ReadBytes(16))
                                 .TrimEnd((char)0xA0);
                var relTrack  = rdr.ReadByte();
                var relSector = rdr.ReadByte();
                var rel       = rdr.ReadByte();
                rdr.Seek(6);
                var sectorSize = rdr.ReadLeInt16();
                if ((fileType & FileType.FileTypeMask) != FileType.DEL)
                {
                    entries.Add(new D64FileEntry(
                                    sName,
                                    RawImage,
                                    SectorOffset(fileTrack, fileSector),
                                    fileType));
                }
            }
            if (nextDirTrack != 0)
            {
                rdr.Offset = (uint)SectorOffset(nextDirTrack, nextDirSector);
                return(true);
            }
            else
            {
                return(false);
            }
        }