home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.6)
-
- RT_STRING = 6
- _use_unicode = 0
-
- try:
- _use_unicode = unicode
- except NameError:
-
- try:
- import pywintypes
- except ImportError:
- raise ImportError, 'Could not import StringTables, no unicode available'
- except:
- None<EXCEPTION MATCH>ImportError
-
-
- None<EXCEPTION MATCH>ImportError
-
- if _use_unicode:
-
- def w32_uc(text):
- return unicode(text, 'unicode-escape').encode('utf-16-le')
-
- else:
-
- def w32_uc(text):
- return pywintypes.Unicode(text).raw
-
-
- class StringTable:
-
- def __init__(self):
- self.strings = { }
-
-
- def add_string(self, id, text):
- self.strings[id] = text
-
-
- def sections(self):
- ids = self.strings.keys()
- ids.sort()
- sections = { }
- for id in ids:
- sectnum = id / 16 + 1
- table = sections.get(sectnum)
- if table is None:
- table = sections[sectnum] = { }
-
- table[id % 16] = self.strings[id]
-
- return sections
-
-
- def binary(self):
- import struct
- sections = []
- for key, sect in self.sections().items():
- data = ''
- for i in range(16):
- ustr = w32_uc(sect.get(i, ''))
- fmt = 'h%ds' % len(ustr)
- data = data + struct.pack(fmt, len(ustr) / 2, ustr)
-
- sections.append((key, data))
-
- return sections
-
-
- if __name__ == '__main__':
- st = StringTable()
- st.add_string(32, 'Hallo')
- st.add_string(33, 'Hallo1')
- st.add_string(34, 'Hallo2')
- st.add_string(35, 'Hallo3')
- st.add_string(1023, '__service__.VCULogService')
- st.add_string(1024, '__service__.VCULogService')
- st.add_string(1025, '__service__.VCULogService')
- st.add_string(1026, '__service__.VCULogService')
- import sys
- sys.path.append('c:/tmp')
- from hexdump import hexdump
- for sectnum, data in st.binary():
- print 'ID', sectnum
- hexdump(data)
-
-
-