1, be sure to set valid paths for nasmw.exe and (link.exe or ar.exe)
   The lib tool is optional, if ommited you will have to use .obj file instead .lib, but #use "xxx.obj"
   will always include the xxx into your executable
2. select a dll to convert (try with aurora/redist/dx3d9r.dll or /windows/system32/dx3d9r.dll)
3. setup options:
  a) export standard names: export "InitD3DFullScreen"
  b) add prefix ... :       export "__imp_InitD3DFullScreen"
     default prefix is "__imp_"

  c) compress dll: (yes/no) If yes, you have two options to decompress it:
     1. check option "embed zlib as" and choose a name for label (internal usage)
        the zlib1.dll will be embedded in output library and loaded from memory to unpack youe dll
     2. do not check "embed zlib as", and while compiling your final executable, be sure to link with
        zlib import or static library

  d) embed zlib as: see c)

4. setup labels (any label must be unique, all the labels are used in single asm file as pointers to code/data):
  a) add prefix ...:  prefix for imported name, used only in import libraries.
     if you declared InitD3DFullScreen as extern (and all others), this prefix is not required, and the option
     "export standard names" can be unchecked,
     If you declared InitD3DFullScreen  as import, this option is required to avoid unresolved externals.

  b) Dll data label: data label where your dll (dx3d9r.dll) will be stored. This label is required to load
     dll from memory pointed to by this label ...

  c) Embed zlib as ...: [read 3.c] if you embed zlib as dll, this label will be required to load zlib1.dll
     from memory pointed to by this label ...

  d) load: function name that you must call before any function from youe dll is called.
     This function loads your dll "from memory to memory" and retrieves all exported function pointers.
     After this you can use the dll.

  e) Unload: function name that you should call as the last function in your program before exiting, to free
     memory occupied by loaded (from memory) dll


/////////////////////////////////////////////////

template settings for dx3d9r.dll

Dll to convert:        c:\WINDOWS\system32\dx3d9r.dll
Output lirary path:    d:\aurora\libs\dx3d9r_m.lib    // use your aurora path
Export standard names: NO                             // not required
Add prefix:            YES: __imp_                    // all functions are declared as "declare import"
Dll data label:        dx3d9r_dll
Compress dll:          YES
Embed zlib as:         NO, we use zlib.lib to decompress dx3d9r.dll
Load:                  __Loaddx3d9r_dll
Unload:                __Unloaddx3d9r_dll

press Create, go to aurora/examples/d3d and open landscape.src
Rename function main() to main2()
append this code:

/////////////////////////////////////////////////
#use "dx3d9r_m.lib"
#use "zlib.lib"                  // remember to copy zlib.lib from this zip to aurora/libs
extern int __Loaddx3d9r_dll();
extern void __Unloaddx3d9r_dll();

sub main()
{
	__Loaddx3d9r_dll();
	main2();
	__Unloaddx3d9r_dll();
}
/////////////////////////////////////////////////


compile it and look at the landscape.exe ... 559 KB, open it with any PE viewer/editor (eXeScope, LordPE, PeID...) and search in import tables for dx3d9r.dll ... not here? :)
Run the exe ... hey, it works! Now you can enumerate loaded modules using any better tool than taskmgr, i prefer ProcessExplorer from http://www.microsoft.com/technet/sysinternals/utilities/ProcessExplorer.mspx
Set view to "Dll", select landscape.exe and in lower pane search for dx3d9r.dll

////////////////////////////////////////////////////////////////////////////
RESTRICTIONS

1. Module functions: This version does not add your dll into process environment block, so GetModuleFileName, GetModuleHandle, and other fill fail.
2. Thread notifications: so simple code is unable do detect that a new thread has been created/destroyed, to notify the dll about this.
3. TLS initialization is not supported (it should be executed before DllMain, if present)
4. You can access only functions exported by name, but it is possible to access functions exported only by ordinal
   manually scanning the dll imports (__Loaddx3d9r_dll returns HMODULE, also pointer to IMAGE_DOS_HEADER)
5. ??


////////////////////////////////////////////////////////////////////////////
where to get nasmw.exe, link.exe or ar.exe

1. if you have aurora, ibasic pro, ebasic - look in \bin directory for tools
2. dev-cpp  in \bin you can find only ar.exe
3. masm32, ddk, visual studio [all versions] - in \bin you can find link.exe
4. nasmw download: http://sourceforge.net/projects/nasm
5. link.exe download (current masm9 pak) http://www.masm32.com
