2

如何从 C 头文件创建foo.spec这样的文件?

即我正在寻找一种将所有头文件的声明转换为简单的东西的自动化方法,例如:

stdcall CreateFileW(wstr long long ptr long long long)

我可以在以后轻松地使用它来执行操作。我意识到这对于某些类型可能是不可能的,但在很多情况下应该是可能的。

我该怎么做呢?

4

1 回答 1

1

好的,wine 项目中可能使用的工具: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 的规范模式下的文件输出:

  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 中转储规范。

于 2011-12-04T04:25:36.837 回答