Home | History | Annotate | Download | only in LauterbachT32
      1 ;
      2 ; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
      3 ; 
      4 ; This program and the accompanying materials                          
      5 ; are licensed and made available under the terms and conditions of the BSD License         
      6 ; which accompanies this distribution.  The full text of the license may be found at        
      7 ; http://opensource.org/licenses/bsd-license.php                                            
      8 ; 
      9 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
     10 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
     11 ; 
     12 
     13   LOCAL &imgstart &filehdrstart &debugdirentryrva &debugtype &debugrva &dwarfsig &baseofcode &baseofdata &elfbase &elfpath &pathoffset
     14   ENTRY &imgstart
     15 
     16   &imgstart=&imgstart
     17   print "PE32 image found at &imgstart"
     18 
     19   ; offset from dos hdr to PE file hdr
     20   &filehdrstart=&imgstart+Data.Long(c:&imgstart+0x3C)
     21 
     22   ; offset to debug dir in PE hdrs
     23   &debugdirentryrva=Data.Long(c:&filehdrstart+0xA8)
     24   if &debugdirentryrva==0
     25   (
     26     print "no debug dir for image at &imgstart"
     27     enddo
     28   )
     29   
     30   &debugtype=Data.Long(c:&imgstart+&debugdirentryrva+0xc)
     31   if (&debugtype!=0xdf)&&(&debugtype!=0x02)
     32   (
     33     print "debug type is not dwarf for image at &imgstart, it's &debugtype"
     34     enddo
     35   )
     36   
     37   &debugrva=Data.Long(c:&imgstart+&debugdirentryrva+0x14)
     38   &dwarfsig=Data.Long(c:&imgstart+&debugrva)
     39   
     40   if &dwarfsig==0x66727764
     41   (
     42     &pathoffset=0xc
     43   )
     44   else
     45   (
     46     if &dwarfsig==0x3031424E
     47     (
     48       &pathoffset=0x10
     49     )
     50     else
     51     (
     52       print "debug signature not found for image at &imgstart, its &dwarfsig"
     53       enddo
     54     )
     55   )
     56 
     57   &elfpath=Data.String(c:&imgstart+&debugrva+&pathoffset)
     58 
     59   &baseofcode=&imgstart+Data.Long(c:&filehdrstart+0x28)
     60   &baseofdata=&imgstart+Data.Long(c:&filehdrstart+0x2c)
     61  
     62   if (&baseofcode<&baseofdata)&&(&baseofcode!=0)
     63   (
     64     &elfbase=&baseofcode;
     65   )
     66   else
     67   (
     68     &elfbase=&baseofdata;
     69   )
     70 
     71   print "found path &elfpath"
     72         ON ERROR GOSUB
     73               return
     74   data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR
     75         ON error
     76 
     77 enddo
     78