Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

__penter and /Gh on VC++ 6.0

Posted on 2000-05-12
5
Medium Priority
?
768 Views
Last Modified: 2008-03-10
I'm wondering if anyone has had any experience with the function hook system on VC++ that uses the /Gh compiler option to bung __penter calls at the beginning of each native function in an application. I'm having real trouble getting it to work.

Anyone out there that could give me a hand (and possibly a working example!) would be most appreciated..

-hd
0
Comment
Question by:Ishani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2806754
You should be able to do something like.

void cdecl _penter(void)
{
   __asm
   {
      PUSHA ; Save all the general purpose registers.

     ; your code here.

      POPA   ; Restore all the general purpose registers.
   }
}

What is it that you want to do?  What sort of problems are you having?
0
 

Author Comment

by:Ishani
ID: 2810395
i'm not getting the linker to recognize the declaration of penter at all.

it complains of an unresolved external symbol, no matter how I declare penter or even if I write it in an external library and link it in (as the MS CAP example does)

0
 
LVL 22

Accepted Solution

by:
nietod earned 600 total points
ID: 2810914
The problem may be name decoration.  Try declarinig it as extern "C" like

extern "C" void cdecl _penter(void) ....
0
 

Author Comment

by:Ishani
ID: 2811403
spot on. although i'm still a bit puzzled:

why _penter and not __penter? even the MSDN docs show a sample implimentation as

void __cdecl __penter(void)...


what does declaring it as a C style name actually do? has this got something to do with name scambling?


thanks muchly for your help.

-hd
0
 
LVL 22

Expert Comment

by:nietod
ID: 2811612
the C compiler will add a "_" to the start of the name as part of its name decoration.  So while the linker looks for a function with two "_"'s you only specify one.

>> what does declaring it as a C style name actually do
It removes the C++ name decoration used for overloading.  this is a "code" that is appended to the end of the function name to express the parameters passed to the function.  This code is used to insure that different overloads of a particular function have unique names.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question