I have an problem, anytimes a pure virtual functionis called. I want to
install an own function to find out the context of this event.
How can I do this?

Re: How to ... replace the "void __cdecl _purecall(void)" from purevirt.c? by Carl

Carl
Wed Mar 03 09:26:49 CST 2004

Klaus Drechsel wrote:
> I have an problem, anytimes a pure virtual functionis called. I want
> to install an own function to find out the context of this event.
> How can I do this?

Define your own function with the appropriate signature. In the function,
you can use GetThreadContext (or inline assembly) to discover the base of
the stack, and then use StackWalk and the DBGHLP/PSAPI functions to map
stack frames to functions. If you do some searching on Google of this
newgroup, you should find several stack-walking implementations. There's
also an implementation in MFC that you can take a look at to see how the
APIs are used. Be warned that in a release build the stack walk that you
get will, in many cases, be not terribly helpful since the compiler doesn't
always generate a "standard" stack frame in release builds.

-cd



Re: How to ... replace the "void __cdecl _purecall(void)" from purevirt.c? by Klaus

Klaus
Wed Mar 03 12:04:25 CST 2004

This was my first idea also. But it dosn't help.

I can find the function void __cdecl _purecall(void) in "purevirt.c".

My source "purecall.cpp" contains following:
"
void __cdecl _purecall(void) {
throw "_purecall";
return 0;
}
"
No includes.
result:
error C2556: 'void __cdecl _purecall(void)' : overloaded functions only
differ by return type from 'int __cdecl _purecall(void)'
error C2371: '_purecall' : redefinition; different basic types
(MSVC 6.0, SP5)
A function 'int __cdecl _purecall(void)' was not called. purecall.cpp is
linked to the executable.
Now I made new tests. With incremental link the symbol from purecall.cpp was
not called. After deleting the exe an complete link was forced, the own
function was called.

stack-walking is an god tip for different problems.

"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam>
schrieb im Newsbeitrag news:uv1yzPTAEHA.2212@TK2MSFTNGP10.phx.gbl...
> Klaus Drechsel wrote:
> > I have an problem, anytimes a pure virtual functionis called. I want
> > to install an own function to find out the context of this event.
> > How can I do this?
>
> Define your own function with the appropriate signature. In the function,
> you can use GetThreadContext (or inline assembly) to discover the base of
> the stack, and then use StackWalk and the DBGHLP/PSAPI functions to map
> stack frames to functions. If you do some searching on Google of this
> newgroup, you should find several stack-walking implementations. There's
> also an implementation in MFC that you can take a look at to see how the
> APIs are used. Be warned that in a release build the stack walk that you
> get will, in many cases, be not terribly helpful since the compiler
doesn't
> always generate a "standard" stack frame in release builds.
>
> -cd
>
>









Re: How to ... replace the "void __cdecl _purecall(void)" from purevirt.c? by Alexander

Alexander
Wed Mar 03 16:03:01 CST 2004

Write a definition for your own pure function, not for purecall().

"Klaus Drechsel" <klaus.drechsel@prosytec.com> wrote in message
news:eJeq5nUAEHA.2212@TK2MSFTNGP10.phx.gbl...
> This was my first idea also. But it dosn't help.
>
> I can find the function void __cdecl _purecall(void) in "purevirt.c".
>
> My source "purecall.cpp" contains following:
> "
> void __cdecl _purecall(void) {
> throw "_purecall";
> return 0;
> }
> "
> No includes.
> result:
> error C2556: 'void __cdecl _purecall(void)' : overloaded functions only
> differ by return type from 'int __cdecl _purecall(void)'
> error C2371: '_purecall' : redefinition; different basic types
> (MSVC 6.0, SP5)
> A function 'int __cdecl _purecall(void)' was not called. purecall.cpp is
> linked to the executable.
> Now I made new tests. With incremental link the symbol from purecall.cpp
was
> not called. After deleting the exe an complete link was forced, the own
> function was called.
>
> stack-walking is an god tip for different problems.
>
> "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam>
> schrieb im Newsbeitrag news:uv1yzPTAEHA.2212@TK2MSFTNGP10.phx.gbl...
> > Klaus Drechsel wrote:
> > > I have an problem, anytimes a pure virtual functionis called. I want
> > > to install an own function to find out the context of this event.
> > > How can I do this?
> >
> > Define your own function with the appropriate signature. In the
function,
> > you can use GetThreadContext (or inline assembly) to discover the base
of
> > the stack, and then use StackWalk and the DBGHLP/PSAPI functions to map
> > stack frames to functions. If you do some searching on Google of this
> > newgroup, you should find several stack-walking implementations.
There's
> > also an implementation in MFC that you can take a look at to see how the
> > APIs are used. Be warned that in a release build the stack walk that
you
> > get will, in many cases, be not terribly helpful since the compiler
> doesn't
> > always generate a "standard" stack frame in release builds.
> >
> > -cd
> >
> >
>
>
>
>
>
>
>
>