Skip to content

Instantly share code, notes, and snippets.

@maxd
Created March 24, 2010 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxd/342207 to your computer and use it in GitHub Desktop.
Save maxd/342207 to your computer and use it in GitHub Desktop.
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 1:0:3300:0
}
.assembly HelloWorld
{
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module HelloWorld.dll
.imagebase 0x00400000
.subsystem 0x00000003
.file alignment 512
.corflags 0x00000002 // ### CHANGE #### -> Change Image CoreFlag to COMIMAGE_FLAGS_32BITSREQUIRED to fix the potential WinXP pitfall
.vtfixup [1] int32 fromunmanaged at VT_01 // ### CHANGE #### -> Create a VTable entry wich will contain the needed data to identify our function
.data VT_01 = int32(0) // ### CHANGE #### -> Create a data entry to hold the Virtual Address to our function
.namespace HelloWorldDll
{
.class public auto ansi beforefieldinit HelloWorldClass extends [mscorlib]System.Object{}
}
.namespace HelloWorldDll
{
.class public auto ansi beforefieldinit HelloWorldClass extends [mscorlib]System.Object
{
.method public hidebysig static string SayHello(string name) cil managed
{
.vtentry 1 : 1 // ### CHANGE #### -> Specify wich VTable entry to use for this function
.export [1] as SayHello // ### CHANGE #### -> Export the method as unmanaged code with the alias "SayHello"
.maxstack 2
.locals init (string V_0)
IL_0000: ldstr "Hello "
IL_0005: ldarg.0
IL_0006: call string [mscorlib]System.String::Concat(string, string)
IL_000b: stloc.0
IL_000c: br.s IL_000e
IL_000e: ldloc.0
IL_000f: ret
}
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed
{
.maxstack 1
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment