Портал освітньо-інформаційних послуг «Студентська консультація»

  
Телефон +3 8(066) 185-39-18
Телефон +3 8(093) 202-63-01
 (093) 202-63-01
 studscon@gmail.com
 facebook.com/studcons

<script>

  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)

  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

 

  ga('create', 'UA-53007750-1', 'auto');

  ga('send', 'pageview');

 

</script>

Дизасемблювання TPU, TPP, TPW модулів, написаних на Паскалі

Тип роботи: 
Курсова робота
К-сть сторінок: 
82
Мова: 
Українська
Оцінка: 

style="text-align: justify;">  end;

  base := 0;
  codeofs := 0;
  while codeofs < codelimit do
  begin
    code_block := add_only_offset(buffer,codebase+codeofs);
    write('---');
    case seg of
      code_seg:  write_code_block_name(unit_list[1],codeofs);
      const_seg: write_const_block_name(code_block^.owner);
    end;
    write('---(block ',hexwordblank(codeofs),')');
    ofs := 0;
    limit := code_block^.size;
    dumpbytes(add_only_offset(code_buf,base)^,0,limit);
    inc(base,limit);
    inc(codeofs,sizeof(block_rec));
  end;
end;
 
end.
 
Skalpel.pas
 
program intrfc;
{  Prints out the information contained in a TPU file  }
{$I SWITCHES.INC}
 
uses
  test1,nametype,util,globals,loader,head,blocks3,{namelist}{srcfiles}code,
        {reloc}dump,params1,dos;
 
var
  i,j,t:word;
  result : word;
  this_unit : obj_ptr;
  tpu_size : longint;
  main_list : list_ptr;
  s, p, x: string;
  path: dirstr;
  name: namestr;
begin
  WriteOutput('Skalpel version 1.03.  Written by O.V. Khabarov');
 
  {parse_params;}
  {$I-}
  writeln('Enter path to unit or "0" to exit');
  writeln('Unit to disassemble: ');
  readln(x);
  if x='0' then halt(1);
  unitname:={'g:\U152.tpu'}x;
        fsplit(unitname,path,name,unit_ext);
        unitname := path+name;
        for i:=2 to 4 do unit_ext[i]:=upcase(unit_ext[i]);
        if unit_ext='.TPU' then
          tpl_name:='TURBO.TPL'
        else if unit_ext='.TPP' then
          tpl_name:='TPP.TPL'
        else if unit_ext='.TPW' then
          tpl_name:='TPW.TPL'
        else HaltError('Invalid extension (TPU,TPP,TPW)');
        {tpl_name:='TURBO.TPL';}
        active_options := [do_header..do_locals];
  writeln('Output file: ');
  readln(x);
        p:={'g:\zu.dat'}x;
        Assign(output,p);
        Rewrite(output);
        if IOResult<>0 then
          HaltError('Cannot write to file '+P);
  {$I+}
  writeln('Dump of file ',unitname,unit_ext);
 
  S:=unitname+unit_ext;
  ReadPathFile(S,header);
  if header = nil then
  begin
    S:=tpl_name;
    ReadPathFile(S,header);
  end;
  if header = nil then
    syntax_exit('Error: can''t find unit '+unitname+unit_ext+', '+
                'TURBO.TPL, TPP.TPL or TPW.TPL.');
  dispose(header);
 
  loadtpl;
  num_known := 0;
  fillchar(unit_list,sizeof(unit_list),0);
  add_unit(unitname,nil);
  if not unit_list[1]^.has_symbols then
    syntax_exit('');
 
  buffer := unit_list[1]^.buffer;
  header := header_ptr(buffer);
 
  {Make this unit refer to itself}
  this_unit := add_only_offset(buffer,header^.ofs_this_unit);
  unit_ptr(add_only_offset(buffer,
           header^.ofs_this_unit+length(this_unit^.name)+4))^.target := 1;
 
  with header^ do
    begin
{$IFDEF UNIT60}
      code_ofs  := roundup(sym_size,16);
{$ELSE}
      browser_ofs := roundup(sym_size,16);
      code_ofs  := browser_ofs + roundup(browser_size,16);
{$ENDIF}
      const_ofs := code_ofs + roundup(code_size,16);
      reloc_ofs := const_ofs + roundup(const_size,16);
      const_reloc_ofs   := reloc_ofs + roundup(reloc_size,16);
      tpu_size := longint(roundup(sym_size,16))
{$IFNDEF UNIT60}
                 +longint(roundup(browser_size,16))
{$ENDIF}
                 +longint(roundup(code_size,16))
                 +longint(roundup(const_size,16))
                 +longint(roundup(reloc_size,16))
                 +longint(roundup(const_reloc_size,16));
    end;
 
  hash_table := add_only_offset(buffer,header^.ofs_hashtable);
  if do_implementation in active_options then
    hash_table := add_only_offset(buffer,header^.ofs_full_hash);
 
  {Build main object list}
 
  build_list(main_list,buffer,hash_table);
  unit_list[1]^.obj_list := main_list;
 
  {Print}
  in_function := false;
  NowEnum := nil;
  indentation := 0;
  if do_header in active_options then
    print_header;
  if [do_name_list,do_implementation]*active_options <> [] then
    print_name_list(main_list);
  if do_src_files in active_options then
    print_src_files;
  if do_src_lines in active_options then
    print_src_lines;
  if do_entry_pts in active_options then
    print_entries;
  if do_code_blocks in active_options then
    print_code_blocks;
  if do_const_blocks in active_options then
    print_const_blocks;
  if do_var_blocks in active_options then
    print_var_blocks;
  if do_dll_blocks in active_options then
    print_dll_blocks;
  if do_unit_blocks in active_options then
    print_unit_blocks;
{$IFNDEF UNIT60}
Фото Капча