|
1 GENSHIMSRC |
|
2 15/08/03 |
|
3 |
|
4 Here is the user documentation that GENSHIMSRC.BAT itself produces: |
|
5 |
|
6 genshimsrc |
|
7 |
|
8 Generate source for a shim DLL and its associated deffile from a supplied deffile |
|
9 |
|
10 Usage: |
|
11 genshimsrc [options] deffile |
|
12 |
|
13 Where: |
|
14 [deffile] The source deffile |
|
15 |
|
16 Options: |
|
17 --srcpath the path for the output source file (defaults to CWD) |
|
18 --defpath the path for the output DEF file (defaults to srcpath) |
|
19 --name the name to use for the output files (defaults to shim) |
|
20 --version the version to use for the output DEF file (defaults to 0.0) |
|
21 --alignstack use shims which align the stack to an 8 byte boundary |
|
22 |
|
23 The following invocation |
|
24 |
|
25 genshimsrc.bat --name=xuser-7_0 xuseru.def |
|
26 |
|
27 would produce two files: xuser-7_0.cia and xuser-7_0{00000000}.def (in CWD). |
|
28 |
|
29 The version encoded in the DEF file name can be changed by supplying |
|
30 the --version option. e.g. |
|
31 |
|
32 genshimsrc.bat --name=xuser-7_0 --version=1.0 xuseru.def |
|
33 |
|
34 would produce two files: xuser-7_0.cia and xuser-7_0{00010000}.def (in CWD). |
|
35 |
|
36 The primary purpose of GENSHIMSRC is to allow 'DLL ordinal skew' to be |
|
37 repaired. It achieves this by generating 'trampoline' functions at the |
|
38 old ordinal which get linked against import stubs which will be |
|
39 resolved by the loader at the new ordinal. However the generated files |
|
40 make it easy for the programmer to inject code into the trampoline if |
|
41 the need arises by identifying each trampoline with the function it is |
|
42 derived from. The generated .DEF file also permits a usable IMPORT lib |
|
43 to be produced for the shim DLL if it is necessary. |
|
44 |
|
45 As alluded to above, for each entry in the supplied .DEF file |
|
46 GENSHIMSRC generates an exported (trampoline) function in the .CIA |
|
47 file and a corresponding entry in the associated .DEF file. Assume the |
|
48 following entry appears in the supplied .DEF file |
|
49 |
|
50 AddL__9CObjectIxP7CObject @ 11 NONAME ; CObjectIx::AddL(CObject *)xxxxx |
|
51 |
|
52 This results in the following source code being generated in the .CIA file |
|
53 |
|
54 EXPORT_C __NAKED__ int export_at_ordinal_11() |
|
55 // |
|
56 // CObjectIx::AddL(CObject *) |
|
57 // |
|
58 { |
|
59 asm("B AddL__9CObjectIxP7CObject"); |
|
60 } |
|
61 |
|
62 and the following entry being generated in the generated .DEF file |
|
63 |
|
64 AddL__9CObjectIxP7CObject=export_at_ordinal_11__Fv @ 11 NONAME ; CObjectIx::AddL(CObject *) |
|
65 |
|
66 These can be incorporated into a buildable project by providing a MMP file which contains: |
|
67 |
|
68 |
|
69 version 0.0 explicit |
|
70 target xuser.dll |
|
71 targettype dll |
|
72 sourcepath . |
|
73 source xuser-7_0.cia |
|
74 library xuser{1.0}.lib |
|
75 systeminclude ..\..\include |
|
76 deffile ..\..\~\xuser-7_0.def |
|
77 |
|
78 |
|
79 N.B. There is nothing special about the MMP file. |