frida-gum icon indicating copy to clipboard operation
frida-gum copied to clipboard

Missing headers for CModule code

Open sherrellbc opened this issue 4 years ago • 1 comments

I was writing a CModule native function for onEnter and was met with the following:

Error: Compilation failed: module.c:41: error: ',' expected (got "*")

This error from TinyCC is mysterious, though after playing around with it for a bit I realized the got "*" part was referring to the asterisk in of the ic pointer argument.

This was expected, since I was unsure of the header where GumInvocationContext was defined at first. I found gum/guminvocationcontext.h. But after updating the CModule code to include this header I'm met with a much more informative error:

Error: Compilation failed: In file included from module.c:5: module.c:5: error: include file 'gum/guminvocationcontext.h' not found

The CModule source is pretty simple to reproduce this:

#include <gum/guminvocationcontext.h>
void stalker_on_enter(GumInvocationContext *ic)
{
}

Most other headers of note also produce similar 'not found' errors, including gum/gum.h. This header includes most others, so I was not expecting it to be missing. It should be noted that gum/stalker.h, however, is found fine.

The Interceptor section of the Javascript documentation explicitly gives this concept as a compelling use-case for CModule.

In case the hooked function is very hot, onEnter and onLeave may be NativePointer values pointing at native C functions compiled using CModule. Their signatures are:
void onEnter (GumInvocationContext * ic)
void onLeave (GumInvocationContext * ic)

Is this a recent regression or am I doing something incorrectly? This was done using a devkit built from the 12.9.4 release tag. 68a1ba5

A similar bug was reported late last year.

sherrellbc avatar Jun 02 '20 18:06 sherrellbc

You can only use the what's declared here. There's no header file gum/guminvocationcontext.h.

For your purpose you should include gum/guminterceptor.h.

You can find more information about CModule here.

vfsfitvnm avatar Jul 02 '20 23:07 vfsfitvnm