如何创建这样的C“spec”文件?

时间:2011-12-03 22:36:45

标签: c dll wine

如何从C头文件中创建this onefoo.spec文件?

即。我正在寻找一种自动方式将所有头文件的声明转换为简单的:

stdcall CreateFileW(wstr long long ptr long long long)

我可以轻松地使用它来执行操作。 我意识到某些类型可能无法实现,但在很多情况下应该是可能的。

我该怎么做?

1 个答案:

答案 0 :(得分:1)

好的,有可能在葡萄酒项目中使用的工具:http://www.winehq.org/docs/winedump

说明:

  

winedump 是一款旨在提供帮助的Wine工具:

   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

规格生成模式:

  

规格模式:

  <dll>  Use dll for input file and generate implementation code.
     

...

     

在foo.dll的spec模式下输出文件:

  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.

因此,winedump会将DLL接口转储到SPEC文件。可以手动编辑Spec文件。

规范描述了真正的DLL接口,而不是高级语言接口(就像它在.h标头中编码一样)。因此,您可以像往常一样将win32上的代码(.h和.c以及类似.def来修复DLL函数编号)编译到DLL中,然后从DLL中转储规范。