diff options
| author | serpilliere <devnull@localhost> | 2012-07-27 16:10:40 +0200 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2012-07-27 16:10:40 +0200 |
| commit | d2d28c982402e57bfeaf9c4b9683b61d374b9031 (patch) | |
| tree | 6323789cc60fc0cd12067f6970ed964eda27307f | |
| parent | daafebd2a0e0e3941ac5415ea12b4620988035f1 (diff) | |
| download | miasm-d2d28c982402e57bfeaf9c4b9683b61d374b9031.tar.gz miasm-d2d28c982402e57bfeaf9c4b9683b61d374b9031.zip | |
bin_stream_vm: add getitem
| -rw-r--r-- | miasm/tools/to_c_helper.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/miasm/tools/to_c_helper.py b/miasm/tools/to_c_helper.py index 3bbb9a24..37bf5324 100644 --- a/miasm/tools/to_c_helper.py +++ b/miasm/tools/to_c_helper.py @@ -1121,6 +1121,16 @@ class bin_stream_vm(): def setoffset(self, val): val = val & 0xFFFFFFFF self.offset = val + def __getitem__(self, item): + if not type(item) is slice: # integer + self.offset = item + return self.readbs(1) + start = item.start + stop = item.stop + step = item.step + self.offset = start + s = self.readbs(stop-start) + return s[::step] |