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