unit pe2lety;

interface

type
  speicherfeld_typ      =array[0..1024*1024*500] of byte;
  speicherfeld_z_typ    =^speicherfeld_typ;
  longint_z             =^longint;
  smallword_z           =^smallword;

  pe_kopf_typ=
    record
      sig               :array[0..3] of char;
      cpu               :smallword;
      num_obj           :smallword;
      timdate           :longint;
      res1              :longint;
      res2              :longint;
      nthdrsize         :smallword;
      flags             :smallword;
      res3              :smallword;
      lmajor            :byte;
      lminor            :byte;
      res_1c            :longint;
      res_20            :longint;
      res_24            :longint;
      entrypoint        :longint;
      res_2c            :longint;
      res_30            :longint;
      image_base        :longint;
      object_align      :longint;
      file_align        :longint;
      osmajor           :byte;
      osminor           :byte;
      usermajor         :byte;
      userminor         :byte;
      subsysmajor       :byte;
      subsysminor       :byte;
      res_4c            :longint;
      image_size        :longint;
      header_size       :longint;
      file_checksum     :longint;
      subsystem         :smallword;
      dll_flags         :smallword;
      stack_reserve_size:longint;
      stack_commit_size :longint;
      heap_reserve_size :longint;
      heap_commit_size  :longint;
      res_70            :longint;
      interestings      :longint;
      export_table      :longint;
      export_data_size  :longint;
      import_table      :longint;
      import_data_size  :longint;
      resource_table    :longint;
      resource_data_size:longint;
      exception_table   :longint;
      exception_table_size:longint;
      security_table    :longint;
      security_size     :longint;
      fixup             :longint;
      fixup_size        :longint;
      debug             :longint;
      debug_directories :longint;
      image_description :longint;
      description_size  :longint;
      machine_specific  :longint;
      machine_specific_size:longint;
      thread_local_storage:longint;
      tls_size          :longint;
    end;

  pe_obj_typ=
    record
      name              :array[0..7] of char;
      virtual_size      :longint;
      rva               :longint;
      physical_size     :longint;
      physical_offset   :longint;
      res1,res2,res3    :longint;
      obj_flags         :longint;
    end;

  pe_obj_typen=(code32,_bss,const32,idata,reloc,res);

  le_kopf_typ=
    record
      sig               :array[0..1] of char;
      byte_order        :byte;
      word_order        :byte;
      executable_format_level:longint;
      cpu_typ           :smallword;
      target_os         :smallword;
      module_version    :longint;
      module_type       :longint;
      number_of_memory_pages:longint;
      cs_obj_nummer     :longint;
      eip_obj_ofs       :longint;
      ss_obj_nummer     :longint;
      esp_obj_ofs       :longint;
      memory_page_size  :longint;
      bytes_on_last_page:longint;
      fixup_section_size:longint;
      fixup_section_checksum            :longint;
      loader_section_size               :longint;
      loader_section_checksum           :longint;
      offset_of_object_table            :longint;
      object_table_entries              :longint;
      object_page_map_table_offset      :longint;
      object_iterate_data_map_offset    :longint;
      resource_table_offset             :longint;
      resource_table_entries            :longint;
      resident_names_table_offset       :longint;
      entry_table_offset                :longint;
      module_directives_table_offset    :longint;
      Module_Directives_entries         :longint;
      Fixup_page_table_offset           :longint;
      Fixup_record_table_offset         :longint;
      imported_modules_name_table_offset:longint;
      imported_modules_count            :longint;
      imported_procedures_name_table_offset:longint;
      perpage_checksum_table_offset     :longint;
      data_pages_offset                 :longint;
      preload_page_count                :longint;
      nonresident_names_table_offset    :longint;
      nonresident_names_table_length    :longint;
      nonresident_names_checksum        :longint;
      automatic_data_object             :longint;
      debug_information_offset          :longint;
      debug_information_length          :longint;
      preload_instance_pages_number     :longint;
      demand_instance_pages_number      :longint;
      extra_heap_allocation             :longint;
      reserved          :array[$ac..$b7] of byte;
      vxd_schrott       :array[$b8..$c3] of byte;
    end;

  le_obj_typ=
    record
      virtual_size_in_bytes:longint;
      relocation_base_address:longint;
      object_flags      :longint;
        (* 0      readable
           1      writable
           2      executable
           3      resource
           4      discardable
           5      shared
           6      preloaded
           7      invalid
           8-9    type
                  00 normal
                  01 zero-filled
                  10 resident
                  11 resident and contiguous
           10     resident and long-lockable
           11     reserved
           12     16:16 alias required
           13     "BIG" (Huge: 32-bit)
           14     conforming
           15     "OBJECT_I/O_PRIVILEGE_LEVEL"
           16-31  reserved                       *)

      page_map_index    :longint;
      page_map_entries  :longint;
      reserved          :array[$14..$17] of byte;
    end;

  page_map_entry_typ=
    record
      res_0                     :byte;
      index_into_fixup_table    :smallword;
        (* 0000h if no relocation info *)
      type_                     :byte;
        (* 00h hard copy in file, 03h some relocation needed *)
    end;

  page_map_entry_feld_typ       =array[1..80000] of page_map_entry_typ;
  page_map_entry_feld_z_typ     =^page_map_entry_feld_typ;

  Fixup_page_table_typ          =array[1..80000] of longint;

  Fixup_page_table_z_typ        =^Fixup_page_table_typ;

  pe_relo_typ=
    record
      page_rva          :longint;
      block_size        :longint;
      fixup             :array[1..8000] of smallword;
    end;
  pe_relo_z_typ         =^pe_relo_typ;

  le_relo_typ=
    record
      type_                             :byte;
       (* bits 7-4: modifier (0001 single, 0011 multiple)
          bits 3-0: type
                  0000 byte offset
                  0010 word segment
                  0011 16-bit far pointer (DWORD)
                  0101 16-bit offset
                  0110 32-bit far pointer (PWORD)
                  0111 32-bit offset
                  1000 near call or jump, WORD/DWORD based on seg attrib *)
      linear_executable_fixup_type      :byte;
       (* 7      ordinal is BYTE rather than WORD
          6      16-rather than 8-object number/module ordinal
          5      addition with DWORD rather than WORD
          4      relocation info has size with new two bytes at end
          3      reserved (0)
          2      set if add to destination, clear to replace destination
          1-0    type
                 00 internal fixup
                 01 external fixup, imported by ordinal
                 10 external fixup, imported by name
                 11 internal fixup via entry table                       *)
      number_of_items                   :byte;
      object_number                     :byte;
      ofs_t                             :array[0..255] of smallword;
    end;
  le_relo_z_typ=^le_relo_typ;

  exe_kopf_typ=
    record
      sig               :array[0..1] of char;
      mod512,
      page512,
      relo_anz,
      kopfgroesse,
      min,max,
      _ss,
      _sp,
      pruefsumme,
      _ip,
      _cs,
      relo_ofs,
      ov_nummer         :smallword;
      rest              :array[$1c..$3b] of byte;
      x_exe_zeiger      :longint;
    end;

  info_block_typ=
    record
      ofs,
      phys_laenge,
      log_laenge        :longint;
    end;

  abschnitte=(startcode,
              resource,
              code,
              bss,
              daten,
              alles_zusammen);

  info_block_tabelle_typ=array[startcode..alles_zusammen] of info_block_typ;

  startcode_typ=(startcode_kein,startcode_watcom,startcode_relopack,startcode_debug);


implementation

end.

