wisp-cvs Mailing List for Wisp interpreter (Page 8)
Status: Alpha
Brought to you by:
digg
You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(30) |
Sep
(312) |
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(5) |
Feb
(131) |
Mar
(17) |
Apr
(184) |
May
(252) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
|
From: <di...@us...> - 2003-05-16 15:02:41
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv4140
Modified Files:
make-pe-exe.py
Log Message:
merged .istubs to .text
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- make-pe-exe.py 16 May 2003 14:56:59 -0000 1.64
+++ make-pe-exe.py 16 May 2003 15:02:36 -0000 1.65
@@ -74,8 +74,6 @@
print 'TEXT'; text.dump()
-istubs = Linkie('<')
-
data = Linkie('<')
data.place_symbol('&message')
data.emit_string('Hello, world!\x0D\x0A')
@@ -86,8 +84,8 @@
imports = Linkie('<')
-sections = {'.text': text, '.istubs': istubs, '.data': data, '.bss': bss, '.imports': imports}
-sectnames = ['.text', '.istubs', '.data', '.bss', '.imports']
+sections = {'.text': text, '.data': data, '.bss': bss, '.imports': imports}
+sectnames = ['.text', '.data', '.bss', '.imports']
e = Linkie('<');
e.glue(0, make_pe_mz_stub('OS too broken'), 0x100)
@@ -104,7 +102,6 @@
e.place_symbol('#' + s + '/reloc', 0)
e.place_symbol('#' + s + '/lineno', 0)
e.place_symbol('#.text/flags', 0x60000020)
-e.place_symbol('#.istubs/flags', 0x60000020)
e.place_symbol('#.data/flags', 0xc0000040)
e.place_symbol('#.bss/flags', 0xc0000080)
e.place_symbol('#.imports/flags', 0xc0000040)
@@ -166,10 +163,10 @@
# generate stub procedures
for dll in imports_by_dlls.keys():
for sym in imports_by_dlls[dll].keys():
- istubs.align(8)
- istubs.place_symbol('&' + sym + '@' + dll)
- istubs[::1] = 0xFF, 0x25
- istubs.emit_tetra_sum(['&.imports/slot/' + sym + '@' + dll])
+ text.align(8)
+ text.place_symbol('&' + sym + '@' + dll)
+ text[::1] = 0xFF, 0x25
+ text.emit_tetra_sum(['&.imports/slot/' + sym + '@' + dll])
# paste sections together
e.align(512)
@@ -206,7 +203,7 @@
e.place_symbol('#aout/magic', 0x010B) # PE32
e.place_symbol('#aout/linker-version-major', 0)
e.place_symbol('#aout/linker-version-minor', 1)
-e.place_symbol('#aout/text-size', roundup(text.memsz(), 0x200) + roundup(istubs.memsz(), 0x200))
+e.place_symbol('#aout/text-size', roundup(text.memsz(), 0x200))
e.place_symbol('#aout/data-size', roundup(data.memsz(), 0x200))
e.place_symbol('#aout/bss-size', roundup(bss.memsz(), 0x200))
e.place_symbol('#aout/image-base', 0x00400000)
|
|
From: <di...@us...> - 2003-05-16 14:57:02
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv790
Modified Files:
make-pe-exe.py pe.py
Log Message:
moved make_pe_section_header to pe.py
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- make-pe-exe.py 16 May 2003 14:55:01 -0000 1.63
+++ make-pe-exe.py 16 May 2003 14:56:59 -0000 1.64
@@ -59,21 +59,6 @@
# 0x4000 should only be run on uniprocessor machines
return h
-def make_pe_section_header (name):
- t = Linkie('<')
- t.align(4)
- t.emit_string((name + '\0' * 8)[:8])
- t[::4] = '#%s/memsz' % name
- t[::4] = '&%s #rva' % name
- t[::4] = '#%s/filesz' % name
- t[::4] = '!%s' % name
- t[::4] = '!%s/reloc' % name
- t[::4] = '!%s/lineno' % name
- t[::2] = '#%s/reloc' % name
- t[::2] = '#%s/lineno' % name
- t[::4] = '#%s/flags' % name
- return t
-
text = Linkie('<') # ia32
text.place_symbol('&_start')
text[::1] = 0x68; text[::4] = -11 # push -11
Index: pe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- pe.py 16 May 2003 14:21:40 -0000 1.3
+++ pe.py 16 May 2003 14:56:59 -0000 1.4
@@ -132,3 +132,18 @@
h.emit_tetra_sum(['#COM+-runtime-header/size'])
h.emit_tetra(0); h.emit_tetra(0) # reserved
return h
+
+def make_pe_section_header (name):
+ t = Linkie('<')
+ t.align(4)
+ t.emit_string((name + '\0' * 8)[:8])
+ t[::4] = '#%s/memsz' % name
+ t[::4] = '&%s #rva' % name
+ t[::4] = '#%s/filesz' % name
+ t[::4] = '!%s' % name
+ t[::4] = '!%s/reloc' % name
+ t[::4] = '!%s/lineno' % name
+ t[::2] = '#%s/reloc' % name
+ t[::2] = '#%s/lineno' % name
+ t[::4] = '#%s/flags' % name
+ return t
|
|
From: <di...@us...> - 2003-05-16 14:55:06
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv32013
Modified Files:
make-pe-exe.py
Log Message:
renamed make_section_header in make-pe-exe.py to make_pe_section_header
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- make-pe-exe.py 16 May 2003 14:21:40 -0000 1.62
+++ make-pe-exe.py 16 May 2003 14:55:01 -0000 1.63
@@ -59,7 +59,7 @@
# 0x4000 should only be run on uniprocessor machines
return h
-def make_section_header (name):
+def make_pe_section_header (name):
t = Linkie('<')
t.align(4)
t.emit_string((name + '\0' * 8)[:8])
@@ -113,7 +113,7 @@
e.glue(e.memsz(), make_coff_header(), None)
e.glue(e.memsz(), make_pe_aout_header(), None)
for s in sectnames:
- e.glue(e.memsz(), make_section_header(s), None)
+ e.glue(e.memsz(), make_pe_section_header(s), None)
e.place_symbol('!' + s + '/reloc', 0)
e.place_symbol('!' + s + '/lineno', 0)
e.place_symbol('#' + s + '/reloc', 0)
|
|
From: <di...@us...> - 2003-05-16 14:21:44
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv13357
Modified Files:
make-pe-exe.py pe.py
Log Message:
added constants for #aout/subsys to pe.py
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- make-pe-exe.py 16 May 2003 14:13:04 -0000 1.61
+++ make-pe-exe.py 16 May 2003 14:21:40 -0000 1.62
@@ -237,8 +237,7 @@
# 4.0 = MSW95
e.place_symbol('#aout/subsys-version-major', 4)
e.place_symbol('#aout/subsys-version-minor', 0)
-# 3 = Windows character
-e.place_symbol('#aout/subsys', 3)
+e.place_symbol('#aout/subsys', PE_SUBSYS.WINDOWS_CHAR)
e.place_symbol('#aout/dll-flags', 0)
e.place_symbol('#aout/stack-reserve-size', 1024 * 1024) # one megabyte
e.place_symbol('#aout/stack-commit-size', 0x1000) # one page
Index: pe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pe.py 16 May 2003 14:13:04 -0000 1.2
+++ pe.py 16 May 2003 14:21:40 -0000 1.3
@@ -8,6 +8,16 @@
from mz import *
+class PE_SUBSYS:
+ UNKNOWN = 0
+ NATIVE = 1
+ WINDOWS_GUI = 2
+ WINDOWS_CHAR = 3
+ OS2_CHAR = 5
+ POSIX_CHAR = 7
+ NATIVE_WINDOWS = 8
+ WINDOWS_CE_GUI = 9
+
def make_pe_mz_stub (message = 'OS too broken'):
# The result's assumed origin address is 0x100.
if message.find('$') != -1:
@@ -77,14 +87,6 @@
h.emit_tetra_sum(['!aout/header-end'])
h.emit_tetra(0) # checksum
h.emit_wyde_sum(['#aout/subsys'])
- # Known values for #aout/subsys
- # 0x0000 - unknown
- # 0x0001 - native
- # 0x0002 - Windows GUI
- # 0x0003 - Windows character
- # 0x0005 - OS/2 character
- # 0x0007 - POSIX character
- # 0x0009 - Windows CE GUI
h.emit_wyde_sum(['#aout/dll-flags'])
# Known flags for #aout/dll-flags
# 0x0001 - per-process library initialization
@@ -130,4 +132,3 @@
h.emit_tetra_sum(['#COM+-runtime-header/size'])
h.emit_tetra(0); h.emit_tetra(0) # reserved
return h
-
|
|
From: <di...@us...> - 2003-05-16 14:13:07
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv8863
Modified Files:
make-pe-exe.py pe.py
Log Message:
moved make_pe_aout_header to pe.py
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- make-pe-exe.py 16 May 2003 14:09:56 -0000 1.60
+++ make-pe-exe.py 16 May 2003 14:13:04 -0000 1.61
@@ -74,87 +74,6 @@
t[::4] = '#%s/flags' % name
return t
-def make_pe_aout_header ():
- h = Linkie('<')
- h.align(4)
- # #aout/magic = 0x10B
- h[::2] = '#aout/magic'
- h[::1] = '#aout/linker-version-major', '#aout/linker-version-minor'
- h[::4] = '#aout/text-size', '#aout/data-size', '#aout/bss-size'
- h[::4] = '&_start #rva', '&.text #rva',
- h[::4] = '&.data #rva' # not present in PE32+ (?)
- # #aout/image-base must be multiple of 64ki
- h[::4] = '#aout/image-base'
- h[::4] = '#aout/memory-align'
- # #aout/file-align must be a power of 2 in range of [512 ... 64Ki]
- h[::4] = '#aout/file-align'
- h[::2] = '#aout/os-version-major'
- h[::2] = '#aout/os-version-minor'
- h[::2] = '#aout/image-version-major'
- h[::2] = '#aout/image-version-minor'
- h[::2] = '#aout/subsys-version-major'
- h[::2] = '#aout/subsys-version-minor'
- h[::4] = 0
- # &aout/image-end must be a multiple of #aout/memory-align
- h.emit_tetra_sum(['&aout/image-end', '#rva'])
- # !aout/header-end must be a multiple of #aout/file-align
- h.emit_tetra_sum(['!aout/header-end'])
- h.emit_tetra(0) # checksum
- h.emit_wyde_sum(['#aout/subsys'])
- # Known values for #aout/subsys
- # 0x0000 - unknown
- # 0x0001 - native
- # 0x0002 - Windows GUI
- # 0x0003 - Windows character
- # 0x0005 - OS/2 character
- # 0x0007 - POSIX character
- # 0x0009 - Windows CE GUI
- h.emit_wyde_sum(['#aout/dll-flags'])
- # Known flags for #aout/dll-flags
- # 0x0001 - per-process library initialization
- # 0x0002 - per-process library termination
- # 0x0004 - per-thread library initialization
- # 0x0008 - per-thread library termination
- # All others must be zero.
- h.emit_tetra_sum(['#aout/stack-reserve-size'])
- h.emit_tetra_sum(['#aout/stack-commit-size'])
- h.emit_tetra_sum(['#aout/heap-reserve-size'])
- h.emit_tetra_sum(['#aout/heap-commit-size'])
- h.emit_tetra(0) # loader flags - obsolete
- h.emit_tetra_sum(['#aout/dict-entry-count'])
- h.emit_tetra_sum(['&export-table', '#rva'])
- h.emit_tetra_sum(['#export-table/size'])
- h.emit_tetra_sum(['&.imports', '#rva'])
- h.emit_tetra_sum(['#.imports/memsz'])
- h.emit_tetra_sum(['&resource-table', '#rva'])
- h.emit_tetra_sum(['#resource-table/size'])
- h.emit_tetra_sum(['&exception-table', '#rva'])
- h.emit_tetra_sum(['#exception-table/size'])
- h.emit_tetra_sum(['!certificate-table'])
- h.emit_tetra_sum(['#certificate-table/size'])
- h.emit_tetra_sum(['&base-relocation-table', '#rva'])
- h.emit_tetra_sum(['#base-relocation-table/size'])
- h.emit_tetra_sum(['&debug-data', '#rva'])
- h.emit_tetra_sum(['#debug-data/size'])
- h.emit_tetra_sum(['&architecture-specific', '#rva'])
- h.emit_tetra_sum(['#architecture-specific/size'])
- h.emit_tetra_sum(['&global-pointer', '#rva'])
- h.emit_tetra(0)
- h.emit_tetra_sum(['&thread-local-storage', '#rva'])
- h.emit_tetra_sum(['#thread-local-storage/size'])
- h.emit_tetra_sum(['&load-config-table', '#rva'])
- h.emit_tetra_sum(['#load-config-table/size'])
- h.emit_tetra_sum(['&bound-import-table', '#rva'])
- h.emit_tetra_sum(['#bound-import-table/size'])
- h.emit_tetra_sum(['&import-address-table', '#rva'])
- h.emit_tetra_sum(['#import-address-table/size'])
- h.emit_tetra_sum(['&delay-import-descriptor', '#rva'])
- h.emit_tetra_sum(['#delay-import-descriptor/size'])
- h.emit_tetra_sum(['&COM+-runtime-header', '#rva'])
- h.emit_tetra_sum(['#COM+-runtime-header/size'])
- h.emit_tetra(0); h.emit_tetra(0) # reserved
- return h
-
text = Linkie('<') # ia32
text.place_symbol('&_start')
text[::1] = 0x68; text[::4] = -11 # push -11
Index: pe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- pe.py 16 May 2003 14:09:55 -0000 1.1
+++ pe.py 16 May 2003 14:13:04 -0000 1.2
@@ -50,3 +50,84 @@
b.place_symbol('#mz/blocks-in-file', (b.filesz() + 0x1FF) / 0x200)
return b
+def make_pe_aout_header ():
+ h = Linkie('<')
+ h.align(4)
+ # #aout/magic = 0x10B
+ h[::2] = '#aout/magic'
+ h[::1] = '#aout/linker-version-major', '#aout/linker-version-minor'
+ h[::4] = '#aout/text-size', '#aout/data-size', '#aout/bss-size'
+ h[::4] = '&_start #rva', '&.text #rva',
+ h[::4] = '&.data #rva' # not present in PE32+ (?)
+ # #aout/image-base must be multiple of 64ki
+ h[::4] = '#aout/image-base'
+ h[::4] = '#aout/memory-align'
+ # #aout/file-align must be a power of 2 in range of [512 ... 64Ki]
+ h[::4] = '#aout/file-align'
+ h[::2] = '#aout/os-version-major'
+ h[::2] = '#aout/os-version-minor'
+ h[::2] = '#aout/image-version-major'
+ h[::2] = '#aout/image-version-minor'
+ h[::2] = '#aout/subsys-version-major'
+ h[::2] = '#aout/subsys-version-minor'
+ h[::4] = 0
+ # &aout/image-end must be a multiple of #aout/memory-align
+ h.emit_tetra_sum(['&aout/image-end', '#rva'])
+ # !aout/header-end must be a multiple of #aout/file-align
+ h.emit_tetra_sum(['!aout/header-end'])
+ h.emit_tetra(0) # checksum
+ h.emit_wyde_sum(['#aout/subsys'])
+ # Known values for #aout/subsys
+ # 0x0000 - unknown
+ # 0x0001 - native
+ # 0x0002 - Windows GUI
+ # 0x0003 - Windows character
+ # 0x0005 - OS/2 character
+ # 0x0007 - POSIX character
+ # 0x0009 - Windows CE GUI
+ h.emit_wyde_sum(['#aout/dll-flags'])
+ # Known flags for #aout/dll-flags
+ # 0x0001 - per-process library initialization
+ # 0x0002 - per-process library termination
+ # 0x0004 - per-thread library initialization
+ # 0x0008 - per-thread library termination
+ # All others must be zero.
+ h.emit_tetra_sum(['#aout/stack-reserve-size'])
+ h.emit_tetra_sum(['#aout/stack-commit-size'])
+ h.emit_tetra_sum(['#aout/heap-reserve-size'])
+ h.emit_tetra_sum(['#aout/heap-commit-size'])
+ h.emit_tetra(0) # loader flags - obsolete
+ h.emit_tetra_sum(['#aout/dict-entry-count'])
+ h.emit_tetra_sum(['&export-table', '#rva'])
+ h.emit_tetra_sum(['#export-table/size'])
+ h.emit_tetra_sum(['&.imports', '#rva'])
+ h.emit_tetra_sum(['#.imports/memsz'])
+ h.emit_tetra_sum(['&resource-table', '#rva'])
+ h.emit_tetra_sum(['#resource-table/size'])
+ h.emit_tetra_sum(['&exception-table', '#rva'])
+ h.emit_tetra_sum(['#exception-table/size'])
+ h.emit_tetra_sum(['!certificate-table'])
+ h.emit_tetra_sum(['#certificate-table/size'])
+ h.emit_tetra_sum(['&base-relocation-table', '#rva'])
+ h.emit_tetra_sum(['#base-relocation-table/size'])
+ h.emit_tetra_sum(['&debug-data', '#rva'])
+ h.emit_tetra_sum(['#debug-data/size'])
+ h.emit_tetra_sum(['&architecture-specific', '#rva'])
+ h.emit_tetra_sum(['#architecture-specific/size'])
+ h.emit_tetra_sum(['&global-pointer', '#rva'])
+ h.emit_tetra(0)
+ h.emit_tetra_sum(['&thread-local-storage', '#rva'])
+ h.emit_tetra_sum(['#thread-local-storage/size'])
+ h.emit_tetra_sum(['&load-config-table', '#rva'])
+ h.emit_tetra_sum(['#load-config-table/size'])
+ h.emit_tetra_sum(['&bound-import-table', '#rva'])
+ h.emit_tetra_sum(['#bound-import-table/size'])
+ h.emit_tetra_sum(['&import-address-table', '#rva'])
+ h.emit_tetra_sum(['#import-address-table/size'])
+ h.emit_tetra_sum(['&delay-import-descriptor', '#rva'])
+ h.emit_tetra_sum(['#delay-import-descriptor/size'])
+ h.emit_tetra_sum(['&COM+-runtime-header', '#rva'])
+ h.emit_tetra_sum(['#COM+-runtime-header/size'])
+ h.emit_tetra(0); h.emit_tetra(0) # reserved
+ return h
+
|
|
From: <di...@us...> - 2003-05-16 14:09:59
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv7709
Modified Files:
Makefile.am make-pe-exe.py
Added Files:
pe.py
Log Message:
renamed make_mz_prefix to make_pe_mz_stub and moved it to pe.py
--- NEW FILE: pe.py ---
#### pe.py - the PE executable format
#
# Copyleft © 2003 by Andres Soolo (di...@us...)
# This file is licensed under the GNU GPL v2. If you
# don't know what that means, please do read the GPL.
#
#### @(#) $Id: pe.py,v 1.1 2003/05/16 14:09:55 digg Exp $
from mz import *
def make_pe_mz_stub (message = 'OS too broken'):
# The result's assumed origin address is 0x100.
if message.find('$') != -1:
raise 'MZ message may not contain dollar signs', message
if message.find('\r') == -1: # if no CRs, insert them
message = '\r\n'.join(message.split('\n'))
b = make_mz_header()
b.place_symbol('#mz/reloc-count', 0) # no relocation
b.place_symbol('#mz/header-size', 0) # empty MZ header--load it all
b.place_symbol('#mz/low-memory-limit', 0x40)
b.place_symbol('#mz/high-memory-limit', 0x40)
b.place_symbol('#mz/ss', -0x10)
b.place_symbol('#mz/sp', 0x100)
b.place_symbol('#mz/checksum', 0)
b.place_symbol('#mz/ip', 0x100 + b.memsz())
b.place_symbol('#mz/cs', -0x10)
b.place_symbol('!mz/reloc', 0)
b.place_symbol('#mz/overlay', 0)
b[::1] = 0x8C, 0xC8, 0x8E, 0xD8 # mov %ax, %cs; mov %ds, mov %ax
b[::1] = 0xB4, 0x09 # mov %ah, 0x09
b[::1] = 0xBA; b[::2] = '&mz/message' # mov %dx, message
b[::1] = 0xCD, 0x21 # int 0x21
b[::1] = 0xB8, 0xFF, 0x4C, 0xCD, 0x21 # mov %ax, 0x4CFF; int 0x21
message += '$' # Dollar the Terminator
# a pointer to the PE signature must appear at the offset 0x003C
room = 0x003C - b.filesz()
if message[0] == '!': room += 1
if len(message) <= room:
b.place_symbol('&mz/message')
b.emit_string(message)
b.emit_string('\x00' * (0x003C - b.filesz()))
b[::4] = '!pe'
else:
b.emit_string('\x00' * (0x003C - b.filesz()))
b[::4] = '!pe'
b.place_symbol('&mz/message')
b.emit_string(message)
b.place_symbol('#mz/bytes-in-last-block', b.filesz() % 0x200)
b.place_symbol('#mz/blocks-in-file', (b.filesz() + 0x1FF) / 0x200)
return b
Index: Makefile.am
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/Makefile.am,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- Makefile.am 16 May 2003 14:05:38 -0000 1.12
+++ Makefile.am 16 May 2003 14:09:56 -0000 1.13
@@ -7,7 +7,7 @@
#### @(#) $Id$
EXTRA_DIST = .cvsignore .pycheckrc struburn.wisp bits.py linkie.py \
- coff.py elf.py \
+ coff.py elf.py pe.py \
makehello.py elfdump.py
all:
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- make-pe-exe.py 16 May 2003 13:52:01 -0000 1.59
+++ make-pe-exe.py 16 May 2003 14:09:56 -0000 1.60
@@ -9,7 +9,7 @@
#### @(#) $Id$
from linkie import Linkie
-from mz import *
+from pe import *
import time
# This file is *very* incomplete
@@ -17,48 +17,6 @@
def roundup (value, boundary):
return (value + boundary - 1) & ~(boundary - 1)
-def make_mz_prefix (message = 'OS too broken'):
- # The result's assumed origin address is 0x100.
- if message.find('$') != -1:
- raise 'MZ message may not contain dollar signs', message
- if message.find('\r') == -1: # if no CRs, insert them
- message = '\r\n'.join(message.split('\n'))
- b = make_mz_header()
- b.place_symbol('#mz/reloc-count', 0) # no relocation
- b.place_symbol('#mz/header-size', 0) # empty MZ header--load it all
- b.place_symbol('#mz/low-memory-limit', 0x40)
- b.place_symbol('#mz/high-memory-limit', 0x40)
- b.place_symbol('#mz/ss', -0x10)
- b.place_symbol('#mz/sp', 0x100)
- b.place_symbol('#mz/checksum', 0)
- b.place_symbol('#mz/ip', 0x100 + b.memsz())
- b.place_symbol('#mz/cs', -0x10)
- b.place_symbol('!mz/reloc', 0)
- b.place_symbol('#mz/overlay', 0)
- b[::1] = 0x8C, 0xC8, 0x8E, 0xD8 # mov %ax, %cs; mov %ds, mov %ax
- b[::1] = 0xB4, 0x09 # mov %ah, 0x09
- b[::1] = 0xBA; b[::2] = '&mz/message' # mov %dx, message
- b[::1] = 0xCD, 0x21 # int 0x21
- b[::1] = 0xB8, 0xFF, 0x4C, 0xCD, 0x21 # mov %ax, 0x4CFF; int 0x21
-
- message += '$' # Dollar the Terminator
- # a pointer to the PE signature must appear at the offset 0x003C
- room = 0x003C - b.filesz()
- if message[0] == '!': room += 1
- if len(message) <= room:
- b.place_symbol('&mz/message')
- b.emit_string(message)
- b.emit_string('\x00' * (0x003C - b.filesz()))
- b[::4] = '!pe'
- else:
- b.emit_string('\x00' * (0x003C - b.filesz()))
- b[::4] = '!pe'
- b.place_symbol('&mz/message')
- b.emit_string(message)
- b.place_symbol('#mz/bytes-in-last-block', b.filesz() % 0x200)
- b.place_symbol('#mz/blocks-in-file', (b.filesz() + 0x1FF) / 0x200)
- return b
-
def make_coff_header ():
h = Linkie('<')
h.align(4)
@@ -228,7 +186,7 @@
sectnames = ['.text', '.istubs', '.data', '.bss', '.imports']
e = Linkie('<');
-e.glue(0, make_mz_prefix('OS too broken'), 0x100)
+e.glue(0, make_pe_mz_stub('OS too broken'), 0x100)
if e.memsz() < 0x80: e.align(0x80) # attempt to create a file(1)-friendly exe
e.align(8) # PE header must be aligned to 8
e.place_symbol('!pe')
|
|
From: <di...@us...> - 2003-05-16 14:07:47
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv5188
Added Files:
coff.py
Log Message:
wrote make_coff_section_header
--- NEW FILE: coff.py ---
#### coff.py - COFF object format
#
# Copyleft © 2003 by Andres Soolo (di...@us...)
# This file is licensed under the GNU GPL v2. If you
# don't know what that means, please do read the GPL.
#
#### @(#) $Id: coff.py,v 1.1 2003/05/16 14:03:29 digg Exp $
from linkie import Linkie
def make_coff_section_header (byte_order, name):
h = Linkie(byte_order)
h.align(4)
h.emit_string((name + '\0' * 8)[:8])
h[::4] = '&%s' % name # physical address
h[::4] = '&%s' % name # virtual address
h[::4] = '#%s/filesz' % name
h[::4] = '!%s' % name
h[::4] = '!%s/reloc' % name
h[::4] = '!%s/lineno' % name
h[::2] = '#%s/reloc' % name
h[::2] = '#%s/lineno' % name
h[::4] = '#%s/flags' % name
return h
|
|
From: <di...@us...> - 2003-05-16 14:05:42
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv6050 Modified Files: Makefile.am Log Message: added coff.py to EXTRA_DIST Index: Makefile.am =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/Makefile.am,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- Makefile.am 26 Apr 2003 17:36:17 -0000 1.11 +++ Makefile.am 16 May 2003 14:05:38 -0000 1.12 @@ -6,8 +6,9 @@ # #### @(#) $Id$ -EXTRA_DIST = .cvsignore .pycheckrc struburn.wisp bits.py elf.py \ - linkie.py makehello.py elfdump.py +EXTRA_DIST = .cvsignore .pycheckrc struburn.wisp bits.py linkie.py \ + coff.py elf.py \ + makehello.py elfdump.py all: |
|
From: <di...@us...> - 2003-05-16 13:52:10
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv32233
Modified Files:
make-pe-exe.py
Added Files:
mz.py
Log Message:
extracted make_mz_header from make_mz_prefix
--- NEW FILE: mz.py ---
#### mz.py - MZ-EXE generation
#
# Copyleft © 2003 by Andres Soolo (di...@us...)
# This file is licensed under the GNU GPL v2. If you
# don't know what that means, please do read the GPL.
#
#### @(#) $Id: mz.py,v 1.1 2003/05/16 13:52:02 digg Exp $
from linkie import Linkie
def make_mz_header ():
h = Linkie('<')
h[::1] = 0x4d, 0x5a # magic
h[::2] = '#mz/bytes-in-last-block', '#mz/blocks-in-file'
h[::2] = '#mz/reloc-count'
h[::2] = '#mz/header-size'
h[::2] = '#mz/low-memory-limit', '#mz/high-memory-limit'
h[::2] = '#mz/ss', '#mz/sp'
h[::2] = '#mz/checksum'
h[::2] = '#mz/ip', '#mz/cs'
h[::2] = '!mz/reloc'
h[::2] = '#mz/overlay'
return h
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- make-pe-exe.py 16 May 2003 13:34:55 -0000 1.58
+++ make-pe-exe.py 16 May 2003 13:52:01 -0000 1.59
@@ -9,6 +9,7 @@
#### @(#) $Id$
from linkie import Linkie
+from mz import *
import time
# This file is *very* incomplete
@@ -22,18 +23,18 @@
raise 'MZ message may not contain dollar signs', message
if message.find('\r') == -1: # if no CRs, insert them
message = '\r\n'.join(message.split('\n'))
- b = Linkie('<')
- b[::1] = 0x4d, 0x5a # 'MZ'
- b[::2] = '#mz/bytes-in-last-block', '#mz/blocks-in-file'
- b[::2] = 0 # no relocation
- b[::2] = 0 # empty MZ header--load it all into memory
- b[::2] = 0x40, 0x40 # low and high memory limits in paragraphs
- b[::2] = -0x10, 0x100 # initial SS, SP
- b[::2] = 0 # no checksum
- b[::2] = '&mz/_start', -0x10 # initial IP, CS
- b[::2] = 0 # relocation table offset
- b[::2] = 0 # not an overlay
- b.place_symbol('&mz/_start')
+ b = make_mz_header()
+ b.place_symbol('#mz/reloc-count', 0) # no relocation
+ b.place_symbol('#mz/header-size', 0) # empty MZ header--load it all
+ b.place_symbol('#mz/low-memory-limit', 0x40)
+ b.place_symbol('#mz/high-memory-limit', 0x40)
+ b.place_symbol('#mz/ss', -0x10)
+ b.place_symbol('#mz/sp', 0x100)
+ b.place_symbol('#mz/checksum', 0)
+ b.place_symbol('#mz/ip', 0x100 + b.memsz())
+ b.place_symbol('#mz/cs', -0x10)
+ b.place_symbol('!mz/reloc', 0)
+ b.place_symbol('#mz/overlay', 0)
b[::1] = 0x8C, 0xC8, 0x8E, 0xD8 # mov %ax, %cs; mov %ds, mov %ax
b[::1] = 0xB4, 0x09 # mov %ah, 0x09
b[::1] = 0xBA; b[::2] = '&mz/message' # mov %dx, message
|
|
From: <di...@us...> - 2003-05-16 13:37:24
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv16333 Modified Files: elf.py Log Message: fixed the blurb at the top of elf.py Index: elf.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- elf.py 13 May 2003 12:34:55 -0000 1.55 +++ elf.py 16 May 2003 13:37:20 -0000 1.56 @@ -1,4 +1,4 @@ -#### elf.py - ELF constants +#### elf.py - ELF constants and object files # # Copyleft © 2003 by Andres Soolo (di...@us...) # This file is licensed under the GNU GPL v2. If you |
|
From: <di...@us...> - 2003-05-16 13:34:59
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv13814
Modified Files:
make-pe-exe.py
Log Message:
simplified MZ-stub generation
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- make-pe-exe.py 16 May 2003 10:23:12 -0000 1.57
+++ make-pe-exe.py 16 May 2003 13:34:55 -0000 1.58
@@ -45,12 +45,8 @@
room = 0x003C - b.filesz()
if message[0] == '!': room += 1
if len(message) <= room:
- if message[0] != '!':
- b.place_symbol('&mz/message')
- b.emit_string(message)
- else:
- b.place_symbol('&mz/message', b.filesz() - 1)
- b.emit_string(message[1:])
+ b.place_symbol('&mz/message')
+ b.emit_string(message)
b.emit_string('\x00' * (0x003C - b.filesz()))
b[::4] = '!pe'
else:
|
|
From: <di...@us...> - 2003-05-16 10:23:15
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv6027
Modified Files:
make-pe-exe.py
Log Message:
attempt to create file(1)-friendly executables by placing the PE header at offset 0x80
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- make-pe-exe.py 16 May 2003 10:13:29 -0000 1.56
+++ make-pe-exe.py 16 May 2003 10:23:12 -0000 1.57
@@ -232,6 +232,7 @@
e = Linkie('<');
e.glue(0, make_mz_prefix('OS too broken'), 0x100)
+if e.memsz() < 0x80: e.align(0x80) # attempt to create a file(1)-friendly exe
e.align(8) # PE header must be aligned to 8
e.place_symbol('!pe')
e.emit_string('PE\0\0')
|
|
From: <di...@us...> - 2003-05-16 10:13:31
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv2162
Modified Files:
make-pe-exe.py
Log Message:
generate hint-name table too
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- make-pe-exe.py 15 May 2003 22:08:10 -0000 1.55
+++ make-pe-exe.py 16 May 2003 10:13:29 -0000 1.56
@@ -267,12 +267,20 @@
imports.align(4)
import_table_start = imports.memsz()
for dll in imports_by_dlls.keys():
- imports[::4] = 0, 0 # hint-name pointer, timestamp
+ imports[::4] = '&.imports/%s/hint-name #rva' % dll
+ imports[::4] = 0 # timestamp
imports[::4] = '#.imports/%s/forwarder-chain' % dll
imports[::4] = '&.imports/%s/dll-name #rva' % dll
imports[::4] = '&.imports/%s/first-thunk #rva' % dll
imports.place_symbol('#.imports/' + dll + '/forwarder-chain', 0)
imports.emit_string('\0' * 20)
+# emit hint/name lists
+for dll in imports_by_dlls.keys():
+ imports.align(4)
+ imports.place_symbol('&.imports/%s/hint-name' % dll)
+ for sym in imports_by_dlls[dll].keys():
+ imports[::4] = '&.imports/thunk/%s@%s #rva' % (sym, dll)
+ imports.emit_tetra(0)
# emit thunk lists
for dll in imports_by_dlls.keys():
imports.align(4)
|
|
From: <di...@us...> - 2003-05-15 22:08:14
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv15713
Modified Files:
make-pe-exe.py
Log Message:
don't put a section at RVA 0
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- make-pe-exe.py 15 May 2003 22:04:19 -0000 1.54
+++ make-pe-exe.py 15 May 2003 22:08:10 -0000 1.55
@@ -308,6 +308,7 @@
base_address = 0x00400000
base_address = roundup(base_address, 0x1000) # to page boundary
memory_boundary = base_address
+memory_boundary += 0x1000 # skip the first page
for s in sectnames:
# file alignment
e.align(512)
|
|
From: <di...@us...> - 2003-05-15 22:04:23
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv13964
Modified Files:
make-pe-exe.py
Log Message:
indicate that the symbols are stripped in #coff/flags
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- make-pe-exe.py 13 May 2003 21:46:49 -0000 1.53
+++ make-pe-exe.py 15 May 2003 22:04:19 -0000 1.54
@@ -333,7 +333,7 @@
e.place_symbol('!coff/symptr', 0)
e.place_symbol('#coff/nsyms', 0)
e.place_symbol('#coff/opthdr', 0x00E0)
-e.place_symbol('#coff/flags', 0x0207)
+e.place_symbol('#coff/flags', 0x020F)
e.place_symbol('#aout/magic', 0x010B) # PE32
e.place_symbol('#aout/linker-version-major', 0)
e.place_symbol('#aout/linker-version-minor', 1)
|
|
From: <di...@us...> - 2003-05-15 21:11:59
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv24187 Modified Files: ia32.tran Log Message: introduced the $o16, $o32, $a16, and $a32 prefix instructions Index: ia32.tran =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/ia32.tran,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ia32.tran 22 Apr 2003 17:34:08 -0000 1.4 +++ ia32.tran 15 May 2003 21:11:56 -0000 1.5 @@ -6,12 +6,21 @@ \ \\\\ @(#) $Id$ +\ These are prefixes for 32-bit mode +:macro $o16 #x66 b, ; +:macro $o32 ; +:macro $a16 #x67 b, ; +:macro $a32 ; + \ registers :regs reg32 %eax %ecx %edx %ebx %esp %ebp %esi %edi ; :regs reg16 %ax %cx %dx %bx %sp %bp %si %di ; :regs reg8 %al %cl %dl %bl %ah %ch %dh %bh ; // lit :macro $int #xCD b, b, ; -// reg32 lit :macro $mov swap minor #o270 + b, t, ; -// lit :macro $push #x68 b, t, ; +// reg32 lit :macro $mov $o32 swap minor #o270 + b, t, ; // reg32 :macro $push minor #o120 + b, ; + +\ These instructions are not completely register width portable: + +// lit :macro $push #x68 b, t, ; |
|
From: <di...@us...> - 2003-05-15 13:45:30
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv8208
Modified Files:
tran.py
Log Message:
replaced Preprocessor.push_macro by Preprocessor.push
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- tran.py 15 May 2003 12:27:30 -0000 1.71
+++ tran.py 15 May 2003 13:45:26 -0000 1.72
@@ -141,8 +141,8 @@
def __init__ (this, filename):
Lexer.__init__(this, filename)
this.tss = []
- def push_macro (this, l):
- this.tss.append(Macro_Cursor(l))
+ def push (this, toksrc):
+ this.tss.append(toksrc)
def get_token (this):
tok = None
while this.tss and tok == None:
@@ -230,7 +230,7 @@
except StopIteration:
raise 'meaningless word', root
m = Meaning[tok]
- if isinstance(m, list): prep.push_macro(m)
+ if isinstance(m, list): prep.push(Macro_Cursor(m))
elif isinstance(m, Stackable): Regstack.append(m)
else: # assume tuple
mtype = m[0]
|
|
From: <di...@us...> - 2003-05-15 12:27:33
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv20699
Modified Files:
tran.py
Log Message:
renamed Preprocessor.macros to Preprocessor.tss
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- tran.py 15 May 2003 06:10:12 -0000 1.70
+++ tran.py 15 May 2003 12:27:30 -0000 1.71
@@ -137,16 +137,17 @@
return datum
class Preprocessor (Lexer):
+ __slots__ = ['tss']
def __init__ (this, filename):
Lexer.__init__(this, filename)
- this.macros = []
+ this.tss = []
def push_macro (this, l):
- this.macros.append(Macro_Cursor(l))
+ this.tss.append(Macro_Cursor(l))
def get_token (this):
tok = None
- while this.macros and tok == None:
- tok = this.macros[-1].get_token()
- if tok == None: this.macros.pop()
+ while this.tss and tok == None:
+ tok = this.tss[-1].get_token()
+ if tok == None: this.tss.pop()
if tok <> None: return tok
else: return Lexer.get_token(this)
|
|
From: <di...@us...> - 2003-05-15 06:10:18
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv16230
Modified Files:
tran.py
Log Message:
added docstring to the Token_Source class
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- tran.py 15 May 2003 05:57:30 -0000 1.69
+++ tran.py 15 May 2003 06:10:12 -0000 1.70
@@ -100,6 +100,9 @@
Semicolon = Unique_Token(';')
class Token_Source (object):
+ """After creation, a Token_Source instance will deliver one token
+each time its get_token method is called, until the token stream ends.
+After that, it will return None."""
get_token = abstract
class Lexer (shlex, Token_Source):
|
|
From: <di...@us...> - 2003-05-15 05:57:33
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv9155
Modified Files:
tran.py
Log Message:
implemented Token_Source interface for Macro_Cursor
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- tran.py 15 May 2003 05:39:50 -0000 1.68
+++ tran.py 15 May 2003 05:57:30 -0000 1.69
@@ -123,11 +123,11 @@
def push_file (this, filename):
this.push_source(open(filename, 'r'), filename)
-class Macro_Cursor (object):
+class Macro_Cursor (Token_Source):
def __init__ (this, sequence):
this.sequence = sequence
this.current = 0
- def get_next (this):
+ def get_token (this):
if this.current >= len(this.sequence): return None
datum = this.sequence[this.current]
this.current += 1
@@ -142,7 +142,7 @@
def get_token (this):
tok = None
while this.macros and tok == None:
- tok = this.macros[-1].get_next()
+ tok = this.macros[-1].get_token()
if tok == None: this.macros.pop()
if tok <> None: return tok
else: return Lexer.get_token(this)
|
|
From: <di...@us...> - 2003-05-15 05:39:53
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv32167
Modified Files:
tran.py
Log Message:
introduced the Token_Source abstraction layer class
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- tran.py 13 May 2003 18:15:53 -0000 1.67
+++ tran.py 15 May 2003 05:39:50 -0000 1.68
@@ -99,7 +99,10 @@
Semicolon = Unique_Token(';')
-class Lexer (shlex):
+class Token_Source (object):
+ get_token = abstract
+
+class Lexer (shlex, Token_Source):
def __init__ (this, filename):
shlex.__init__(this, instream = open(filename, 'r'), infile = filename)
this.commenters = '\\'
|
|
From: <di...@us...> - 2003-05-13 21:46:53
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv6216
Modified Files:
make-pe-exe.py
Log Message:
fixed the MZ signature
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- make-pe-exe.py 13 May 2003 21:40:29 -0000 1.52
+++ make-pe-exe.py 13 May 2003 21:46:49 -0000 1.53
@@ -23,7 +23,7 @@
if message.find('\r') == -1: # if no CRs, insert them
message = '\r\n'.join(message.split('\n'))
b = Linkie('<')
- b[::2] = 0x4d, 0x5a # 'MZ'
+ b[::1] = 0x4d, 0x5a # 'MZ'
b[::2] = '#mz/bytes-in-last-block', '#mz/blocks-in-file'
b[::2] = 0 # no relocation
b[::2] = 0 # empty MZ header--load it all into memory
|
|
From: <di...@us...> - 2003-05-13 21:40:32
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv3767
Modified Files:
make-pe-exe.py
Log Message:
use clearer syntax
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- make-pe-exe.py 13 May 2003 21:35:10 -0000 1.51
+++ make-pe-exe.py 13 May 2003 21:40:29 -0000 1.52
@@ -132,14 +132,14 @@
h[::4] = '#aout/image-base'
h[::4] = '#aout/memory-align'
# #aout/file-align must be a power of 2 in range of [512 ... 64Ki]
- h.emit_tetra_sum(['#aout/file-align'])
- h.emit_wyde_sum(['#aout/os-version-major'])
- h.emit_wyde_sum(['#aout/os-version-minor'])
- h.emit_wyde_sum(['#aout/image-version-major'])
- h.emit_wyde_sum(['#aout/image-version-minor'])
- h.emit_wyde_sum(['#aout/subsys-version-major'])
- h.emit_wyde_sum(['#aout/subsys-version-minor'])
- h.emit_tetra(0)
+ h[::4] = '#aout/file-align'
+ h[::2] = '#aout/os-version-major'
+ h[::2] = '#aout/os-version-minor'
+ h[::2] = '#aout/image-version-major'
+ h[::2] = '#aout/image-version-minor'
+ h[::2] = '#aout/subsys-version-major'
+ h[::2] = '#aout/subsys-version-minor'
+ h[::4] = 0
# &aout/image-end must be a multiple of #aout/memory-align
h.emit_tetra_sum(['&aout/image-end', '#rva'])
# !aout/header-end must be a multiple of #aout/file-align
|
|
From: <di...@us...> - 2003-05-13 21:35:19
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv1751
Modified Files:
make-pe-exe.py
Log Message:
use clearer syntax
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- make-pe-exe.py 13 May 2003 21:30:55 -0000 1.50
+++ make-pe-exe.py 13 May 2003 21:35:10 -0000 1.51
@@ -129,8 +129,8 @@
h[::4] = '&_start #rva', '&.text #rva',
h[::4] = '&.data #rva' # not present in PE32+ (?)
# #aout/image-base must be multiple of 64ki
- h.emit_tetra_sum(['#aout/image-base'])
- h.emit_tetra_sum(['#aout/memory-align'])
+ h[::4] = '#aout/image-base'
+ h[::4] = '#aout/memory-align'
# #aout/file-align must be a power of 2 in range of [512 ... 64Ki]
h.emit_tetra_sum(['#aout/file-align'])
h.emit_wyde_sum(['#aout/os-version-major'])
|
|
From: <di...@us...> - 2003-05-13 21:30:58
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv32479
Modified Files:
make-pe-exe.py pedump.py
Log Message:
made result of make-pe-hello.py edible to pedump.py
Index: make-pe-exe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- make-pe-exe.py 13 May 2003 21:17:03 -0000 1.49
+++ make-pe-exe.py 13 May 2003 21:30:55 -0000 1.50
@@ -279,12 +279,12 @@
imports.place_symbol('&.imports/%s/first-thunk' % dll)
for sym in imports_by_dlls[dll].keys():
imports.place_symbol('&.imports/slot/' + sym + '@' + dll)
- imports.emit_tetra_sum(['&.imports/thunk/%s@%s #rva' % (sym, dll)])
+ imports[::4] = '&.imports/thunk/%s@%s #rva' % (sym, dll)
imports.emit_tetra(0)
# emit thunk structures
for dll in imports_by_dlls.keys():
for sym in imports_by_dlls[dll].keys():
- imports.place_symbol('&.imports/thunk/%s@%s #rva' % (sym, dll))
+ imports.place_symbol('&.imports/thunk/%s@%s' % (sym, dll))
imports.align(2)
imports[::2] = 0 # ordinal
imports.emit_string(sym)
@@ -390,6 +390,7 @@
e.place_symbol('#delay-import-descriptor/size', 0)
e.place_symbol('&COM+-runtime-header', base_address)
e.place_symbol('#COM+-runtime-header/size', 0)
+e.align(512)
e.link()
e.dump()
Index: pedump.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pedump.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- pedump.py 22 Apr 2003 22:29:30 -0000 1.5
+++ pedump.py 13 May 2003 21:30:55 -0000 1.6
@@ -189,14 +189,17 @@
print 'Forwarder chain: 0x%08x' % fwdr_chain
print 'DLL name: 0x%08x %r' % (dll_name, string_by_rva(dll_name))
print 'First thunk: 0x%08x' % first_thunk
- print 'Hint name array:'
h = hint_name
- herva, = struct.unpack('<L', by_rva[h:h + 4]); h += 4
- while herva <> 0:
- exord, = struct.unpack('<H', by_rva[herva:herva + 2])
- print ' [%08x] %04x %r' % (herva, exord,
- string_by_rva(herva + 2))
+ if h <> 0:
+ print 'Hint/name array:'
herva, = struct.unpack('<L', by_rva[h:h + 4]); h += 4
+ while herva <> 0:
+ exord, = struct.unpack('<H', by_rva[herva:herva + 2])
+ print ' [%08x] %04x %r' % (herva, exord,
+ string_by_rva(herva + 2))
+ herva, = struct.unpack('<L', by_rva[h:h + 4]); h += 4
+ else:
+ print 'Hint/name array is empty'
print 'Thunk array:'
t = first_thunk
terva, = struct.unpack('<L', by_rva[t:t + 4]); t += 4
|