0

For some test needs I need some third-party dll to be replaced with own stubbed version: the actual methods should return some hard-coded data with some specific delays and delays' effect on the system that uses the original dll are actually the under the test.

So, for this purpose I need some how to create a *.cpp file with the same structs and signatures from the dll. What is the best approach to do it programmatically?

1) decompilers? but actually I don't need the code itself, just class definitions and signatures only.

2) do it programmatically with c++ code

3) do it programmatically with java code through JNI, for example.

Any ideas and directions are welcome. Unfortunately, googling doesn't give the straighforward answer, at least for c++ newbies as me.

Eljah
  • 4,188
  • 4
  • 41
  • 85
  • You hopefully have the header files for the public API implemented by the 3rd-party DLL. This issue has been addressed on SO before: _[Automatically generate C++ file from header?](http://stackoverflow.com/questions/1404614/automatically-generate-c-file-from-header)_ - try [Lazy C++](http://www.lazycplusplus.com/). – Alex Cohn Dec 14 '14 at 08:45
  • actually, NO. just dll and some code that uses in via jni (may be based on header files but not the header files itself). – Eljah Dec 14 '14 at 12:09

1 Answers1

0

If this DLL is loaded from Java and called via JNI, then you can launch javah to produce the relevant headers; use -stubs option to prepare the C files with dummy implementations of all native methods.

Update: -stubs does not work correctly, see Unable to generate JNI .c file using javah -stubs

Community
  • 1
  • 1
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307