_penter Hook Function Call ... boggle

Started by CommonTater, January 01, 2012, 01:10:35 PM

Previous topic - Next topic

CommonTater

Hi guys...

Has anyone had any luck getting the Hook Function Call (/Gh) working?

The help file is pretty cryptic on the topic, mentioning _penter only in reference to the compiler flag, but giving virtually no detail about how to use it.

If I'm reading it correctly, the call to _penter should be issued at the beginning of each function with the prototype as shown below...

This code...

#include <stdio.h>
void __cdecl _penter(void)
{
}

int main (void)
  {
   
    printf("In Main...\n");
   
    return 0; 
  }


produces these errors...

E:\C_Code\Experiments\returnaddr\main.c(3): error #3119: [asm] Redefinition of symbol '__penter'.
E:\C_Code\Experiments\returnaddr\main.c(8): error #3119: [asm] Redefinition of symbol '__penter'.
error #3119: [asm] Redefinition of symbol '__penter'.
error #3119: [asm] Redefinition of symbol '__penter'. *** Error code: 1 ***


Any suggestions how to get this to work?

TimoVJL

#1
Some test with it:
//With Gh-option
#include <stdio.h>
#pragma comment(lib, "penter.lib")
int main (void)
{
    (void)printf("In Main...\n");
    return 0; 
}
For library penter.lib compiled without -Gh option
//Without -Gh option
#include <stdio.h>
void __cdecl _penter(void)
{
printf("In _penter\n");
}
output:In _penter
In Main...

Check this link:
http://www.johnpanzer.com/aci_cuj/index.html
May the source be with you

CommonTater

Thank you Timo!  Yes that works.   And thanks for the link... a very interesting read...