[Python-il] [python-il]location in file

Yitzhak Wiener Yitzhak.Wiener at dspg.com
Mon May 24 17:55:01 IDT 2010


Hi Dear people,

 

I am searching for data in file. The file is from type of text. I was
using RE for finding the location in file that I was interested in. So I
found the string that begins the section, and now I want to read
information from that section according to its address (offset from
beginning of the file).

 

For better understanding here is part of my file:

41c0 06cb 41c0 06cb 41c0 06cb 41c0 06cb 

41c0 06cb 41c0 06cb 41c0 06cb 41c0 06cb 

41c0 06cb 41c0 06cb 41c0 06cb 41c0 06cb 

41c0 06cb 41c0 06cb 41c0 06cb 41c0 06cb 

41c0 06cb 41c0 06cb 41c0 06cb 41c0 06cb 

41c0 06cb 

 

48. MultiProgPage_Data at c2 - SECTION HEADER:

s_paddr   = 0x52a

s_vaddr   = 0x0

s_size    = 420

s_scnptr  = 244630

s_relptr  = 0

s_lnnoptr = 0

s_nreloc  = 0

s_nlnno   = 0

s_flags   = 0x8        ( Data section, Mapped in code memory )

RAW DATA:

0002 bec3 0002 d3f2 0002 c331 0002 d3d6 

0000 0540 0001 10f4 0002 64a7 0002 ec5d 

0002 ed11 0002 c3e4 0002 f908 0002 a139 

0002 9aee 0002 b325 0002 ca22 0001 39ac 

0000 0596 0002 d62a 0002 bb4e 0001 4ec6 

0001 3d1a 0001 3cae 0001 4a85 0001 47ee 

0001 19c8 0002 ff2b 0002 e535 0001 2ea7 

0001 4772 0001 3db9 0000 c452 0001 4aa5 

0002 85bb 0001 4c14 0001 4a25 0001 49d0 

0002 f1d5 0001 3c77 0001 4afd 0001 4c09 

0001 4a35 0001 48fa 0001 3ac0 0001 3771 

0001 3d84 0001 4631 0001 30f4 0002 b9bf 

0001 3224 0000 c43f 0002 eb9e 0002 400c 

0002 f6d6 0001 44eb 0002 ef9d 0001 4a55 

0001 4ab4 0001 416b 0002 4b50 0002 b72c 

0002 9f7d 0001 4d94 0001 3695 0001 49be 

0002 d60f 0002 5cff 0001 20da 0002 ad34 

0000 f818 0001 342f 0002 c9a0 0001 4df7 

0002 df25 0002 c235 0001 4879 0001 3f0e 

0001 3891 0001 3b82 0001 3c3b 0001 43c1 

0001 4ba8 0000 f837 0001 278c 0002 3c92 

0002 ff0a 0001 4615 0001 46f0 0002 d819 

0001 4d64 0001 4e32 0001 4193 0001 42a2 

0002 7a74 0001 4547 0002 c76e 0002 d444 

0002 7975 0002 7fef 0002 2fa0 0001 1f90 

0002 fc3e 0001 4e50 0001 1ce7 0001 1b79 

0001 2f9d 

 

49. beeper_FW_bg_Task at c2 - SECTION HEADER:

 

 

The data that I need is colored in red. What I would like to do is
according to input offset, read the hexadecimal word in red that located
in that offset from beginning of the file or of the red section. For
example offset 3 = d3f2.

What is a correct method to refer to this data?

FYI To get to the beginning of the section I used re.match as follows:

s = file(r" project_release.dump").read().splitlines()

bInsideSection = False

for line in s:

 

   if re.match(".*MultiProgPage_Code at c0 - SECTION HEADER.*", line,
re.S):

      bInsideSection=True

   if re.match(r".*RAW DATA.*", line):

 

 

 

Thanks for your help,

Yitzhak

 


______________________________________________________________________
DSP Group, Inc. automatically scans all emails and attachments using MessageLabs Email Security System.
_____________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://hamakor.org.il/pipermail/python-il/attachments/20100524/36c053c1/attachment.htm 


More information about the Python-il mailing list