How do I create foo.spec
files like this one from a C header file?
i.e. I'm looking for an automated way to convert all of a header file's declarations into something simple like:
stdcall CreateFileW(wstr long long ptr long long long)
which I can easily use to perform operations later. I realize it might not be possible for some types, but it should be possible in a large number of cases.
How do I do this?
Ok, there is the tool likely used in wine project: http://www.winehq.org/docs/winedump
Intro:
winedump is a Wine tool which aims to help:
A: Reimplementing a Win32 DLL for use within Wine, or
B: Compiling a Win32 application with Winelib that uses x86 DLLs
For both tasks in order to be able to link to the Win functions some glue code is needed. This 'glue' comes in the form of a .spec file. The .spec file, along with some dummy code, is used to create a Wine .so corresponding to the Windows DLL. The winebuild program can then resolve calls made to DLL functions. Creating a .spec file is a labour intensive task during which it is easy to make a mistake. The idea of winedump is to automate this task and create the majority of the support code needed for your DLL. In addition you can have winedump create code to help you re-implement a DLL
Spec generation mode:
Spec mode:
<dll> Use dll for input file and generate implementation code.
....
Files output in spec mode for foo.dll:
foo.spec This is the .spec file. foo_dll.h foo_main.c These are the source code files containing the minimum set of code to build a stub DLL. The C file contains one function, FOO_Init, which does nothing (but must be present). Makefile.in This is a template for 'configure' to produce a makefile. It is designed for a DLL that will be inserted into the Wine source tree.
So, winedump will dump DLL interface to SPEC file. The Spec file can be additionaly edited by hand.
And the spec describes real DLL interface, not a high-level language interface (like it is encoded in .h
headers). So, you can compile your code (.h and .c and maybe something like .def to fix DLL function numbers) on win32 to DLL as usual and then dump the spec from DLL.