After Patrik's quick work on writing function_grep.pl, things get a lot more 
interesting :-)

Heres the current version of specmaker. It currently works in two basic modes:

1. Generate a stub-only dll suitable for winebuild to link to, so that a
   Winelib app can call functions from a native DLL.

2. Generate a compilable dll code base with code for function stubs,
   TRACEing arguments and correct return values (compiles 'out of the box').
   This is for reimplementing a dll for Wine or a Winelib app.

I am be adding the final mode now, which is to TRACE arguments, then call the
native DLL through GetProcAddress and return the results. This is like 
building a 'snooping' wrapper around the native DLL so the functions can be 
implemented piecemeal, even if multiple functions depend on DLL internal 
states to work.

For mode 2, specbuilder takes an argument specifying a file or list of files 
to search for prototypes (the fewer files to search, the faster, by an order 
of magnitude). Using Patrik's script, any matched exports from the DLL are 
converted into prototypes and stub code is generated. Before you can compile 
the generated code, you'll either need to #include the dll headers you used 
to generate the dll, or add the definitions of any DLL specific types used to 
<outputname>_dll.h. If your DLL uses standard types you won't have to do 
anything, except maybe add some windows includes. Generated code
should build with -Wall,-W without any warnings.

As an example, running
./specmaker -d imagehlp -t -I ~/develop/wine-new/include/imagehlp.h

Generates a compilable imagehlp with every function but one implemented 
(because it has no prototype). I deleted dlls/imagehelp/* and copied the 
generated files in. Then I added "#include imagehlp.h" to imagehlp_dll.h (to 
get the definitions of imagehlp types), and could build it with a top level
./configure, make. Total time, about 5 minutes :-)


The code should handle all variations of functions such as void and varargs. 
If you come across a crash or case where compilation breaks, let me know.

In some cases prototypes cannot be found when they are present, but the 
average seems to be very high (Patrik, I'll be sending some examples soon).
running it on CRTDLL, for example, leaves only 107 out of 521 functions as 
stubs, and a lot of those just dont have definitions in the headers...

Other DLLs I tested with:

I'm also beginning to think this should be called dllmaker, since thats what 
it does...

Cheers,
Jon


-- 
"May their negative actions ripen upon me. And may all my virtues ripen upon 
them."
"If it could be talked about, everybody would have told their brother."
[EMAIL PROTECTED] , [EMAIL PROTECTED]



Reply via email to