Greetings,
uhm ... whats the problem with the learn-by-doing method?
If someone supplies the result you will never learn something new nor understand how things work.
1) Get tools to compile a dynamic library from C sources:
Download a free C/C++ compiler - it should be bundeled with some development environment to make things easier
http://www.bloodshed.net/dev/devcpp.html
("http://www.bloodshed.net/dev/devcpp.html
")
Dev-C++ 5.0 beta 8 (4.9.8.0) (12 MB) with Mingw/GCC 3.2
Dev-C++ version 4.9.8.0, includes full Mingw compiler system (GCC 3.2) and GDB 5.1
Install the stuff.
Download any latest service packs or updates to the product:
Latest update : version 4.9.8.5
http://bloodshed.net/dev/devcpp4985.zip
("http://bloodshed.net/dev/devcpp4985.zip
")
Now you are ready to setup a project.
2) Make a windows DLL project
* use the IDE's wizard to create a DLL project
(project new -> DLL)
* fill in project name ... for instance "disasm"
* set preference to "C" (the supplied disasm sources are C only)
* now save your project into some subdirectory you created (e.g. "disasmlib"
The wizard created some files for you.
You can "saveall" to really save em to disk.
Of course you can already compile it. It will produce a DLL with some dummy function exported.
Now you are ready to integrate olly's disasm sources.
3) Import olly disasm sources and modify to get things working
* unpack the disasm.zip archive into your project directory
* add the necessary *.c and *.h files to the project (context menu "add to project"

In this case you need to add: asmserv.c, assembl.c, disasm.c, disasm.h
Now if you try to build the project you get errors (of course)..
Hint: always "rebuild all" to clean up any remaining object files
To fix the errors you need to modify the main header file "disasm.h":
You need to remove or comment out the following construct:
<pre>
#if (char)0xFF!=255
#error Please set default char type to unsigned
#endif
</pre>
This is not understood by most compiler preprocessors.
The pow10l function is not supplied by most compiler libs, add the following to disasm.h header file to work around it:
<pre>
#define pow10l(a) pow(10.,(a))
</pre>
add code (top of disasm.h) to export the symbols/functions correctly:
<pre>
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
</pre>
Append the "DLLIMPORT" macro to all functions that should be exported:
e.g. "int Assemble(char *cmd,ulong ip,t_asmmodel *model,int attempt,
int constsize,char *errtext);"
becomes "DLLIMPORT int Assemble(char *cmd,ulong ip,t_asmmodel *model,int attempt, int constsize,char *errtext);"
and so forth...
(you find em at bottom of disasm.h file)
In your dllmain.c file (generated by IDE) remove the include stuff and replace it with the include stuff from disasm-package "main.c":
<pre>
#define STRICT
#define MAINPROG // Place all unique variables here
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <dir.h>
#include <math.h>
#include <float.h>
#pragma hdrstop
#include "disasm.h"
</pre>
Remove the dummy function (generated) from dllmain.c too.
Now your dllmain.c source file contains only a DllMain() which is ok.
To force the compiler to "char = unsigned char" option, add the "-funsigned-char
" option to the compiler parameters (project options)
Voila ... you are able to compile the sources to a clean win32 dll.
If you dump the exports of the newly created "disasm.dll" (using some PE tool like dependency walker) you will see all exports fine.
To really verify if things work you should create a simple C console client, which consumes the dll.
It is not that hard ...
Best Regards,
A. Focht