NO

Author Topic: _penter Hook Function Call ... boggle  (Read 7172 times)

CommonTater

  • Guest
_penter Hook Function Call ... boggle
« on: January 01, 2012, 01:10:35 PM »
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...
Code: [Select]

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

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

produces these errors...
Code: [Select]

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?
 

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: _penter Hook Function Call ... boggle
« Reply #1 on: January 01, 2012, 05:39:59 PM »
Some test with it:
Code: [Select]
//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
Code: [Select]
//Without -Gh option
#include <stdio.h>
void __cdecl _penter(void)
{
printf("In _penter\n");
}
output:
Code: [Select]
In _penter
In Main...
Check this link:
http://www.johnpanzer.com/aci_cuj/index.html
« Last Edit: January 01, 2012, 05:56:39 PM by timovjl »
May the source be with you

CommonTater

  • Guest
Re: _penter Hook Function Call ... boggle
« Reply #2 on: January 01, 2012, 10:06:02 PM »
Thank you Timo!  Yes that works.   And thanks for the link... a very interesting read...