I need to unhook event receiver as result of native C++ event.
It unhooks successfully, but __raise does not return and throws access
violation.
Visual Studio 2003
How to reproduce:
Consol Win32 exe project
#include "stdafx.h"
[event_source(native)]
class Publisher
{
public:
__event void Signal(Publisher* sender);
void RaiseSignal()
{
// throws access violation
__raise Signal(this);
}
};
[event_receiver(native)]
class Subscriber
{
public:
void Handler(Publisher* sender)
{
// unhooks successfully
Unhook(sender);
return;
}
void Hook(Publisher* sender)
{
__hook(&Publisher::Signal, sender, &Subscriber::Handler, this);
return;
}
void Unhook(Publisher* sender)
{
__unhook(&Publisher::Signal, sender, &Subscriber::Handler, this);
return;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Publisher pub;
Subscriber sub;
sub.Hook(&pub);
pub.RaiseSignal();
return 0;
}
Debug output window
'Hook.exe': Loaded 'C:\Projects\Hook\Debug\Hook.exe', Symbols loaded.
'Hook.exe': Loaded 'C:\WINDOWS\SYSTEM32\ntdll.dll', Symbols loaded.
'Hook.exe': Loaded 'C:\WINDOWS\SYSTEM32\kernel32.dll', Symbols loaded.
First-chance exception at 0x00411e51 in Hook.exe: 0xC0000005: Access
violation reading location 0xfeeefeee.
Unhandled exception at 0x00411e51 in Hook.exe: 0xC0000005: Access
violation reading location 0xfeeefeee. 2 2816
"Boris Fortes" <fb****@yahoo.com> wrote in message
news:10**************************@posting.google.c om... I need to unhook event receiver as result of native C++ event. It unhooks successfully, but __raise does not return and throws access violation.
See if this helps: KB Article KB811193 "BUG: Access Violation Exception
When a Native Event is Fired or Unhooked"
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
Hi,
Calling __unhook in a handler should cause a race condition, but because the
injected critical section code does nothing (???), so your code get pass but
a GPF happened because the call was between walking functor node.
You can check this with /Fx switch.
"Boris Fortes" wrote: I need to unhook event receiver as result of native C++ event. It unhooks successfully, but __raise does not return and throws access violation.
Visual Studio 2003
How to reproduce:
Consol Win32 exe project
#include "stdafx.h"
[event_source(native)] class Publisher { public: __event void Signal(Publisher* sender); void RaiseSignal() { // throws access violation __raise Signal(this); }
};
[event_receiver(native)] class Subscriber { public:
void Handler(Publisher* sender) { // unhooks successfully Unhook(sender); return; }
void Hook(Publisher* sender) { __hook(&Publisher::Signal, sender, &Subscriber::Handler, this); return; }
void Unhook(Publisher* sender) { __unhook(&Publisher::Signal, sender, &Subscriber::Handler, this); return; }
};
int _tmain(int argc, _TCHAR* argv[]) { Publisher pub; Subscriber sub;
sub.Hook(&pub); pub.RaiseSignal(); return 0; }
Debug output window
'Hook.exe': Loaded 'C:\Projects\Hook\Debug\Hook.exe', Symbols loaded. 'Hook.exe': Loaded 'C:\WINDOWS\SYSTEM32\ntdll.dll', Symbols loaded. 'Hook.exe': Loaded 'C:\WINDOWS\SYSTEM32\kernel32.dll', Symbols loaded. First-chance exception at 0x00411e51 in Hook.exe: 0xC0000005: Access violation reading location 0xfeeefeee. Unhandled exception at 0x00411e51 in Hook.exe: 0xC0000005: Access violation reading location 0xfeeefeee. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jim P. |
last post by:
I'm having trouble returning an object from an AsyncCallback called inside a
threaded infinite loop.
I'm working on a Peer2Peer app that uses an AsyncCallback to rerieve the
data from the remote...
|
by: Rhy Mednick |
last post by:
I have a class (let's call it ClassA) that I've written which has events.
In another class (let's call it ClassB) I create a collection of ClassA
objects. In a third class (ClassC) I create a...
|
by: |
last post by:
Serious bug discovered in VC .NET (2002) compiler.
Example below should work if I understand the Microsoft documentation
correctly.
Hopfelly there is some compiler upgrade that fixes this bug?...
|
by: Anders K. Jacobsen [DK] |
last post by:
Hi
I have this that adds some usercontrol (UCTodays.ascx) to a placeholder
foreach(A a in B){
UCTodays ucline = (UCTodays )LoadControl("UCTodays.ascx");...
|
by: Andy |
last post by:
Hi to All,
I found the following issue, is this a bug?
Create a new project and, in the main form, add a listbox with a few sample
items. In the DoubleClick event of the listbox, add:
...
|
by: sam.m.gardiner |
last post by:
I'm working with VB.NET events and I want a way to disconnect all the
handlers of an event. I want to do this in the object that is the
source of the event. This is slightly tricky in VB.Net as the...
|
by: =?Utf-8?B?VmFubmk=?= |
last post by:
Hi,
I have a component where I need to have thread-safe access to a list.
Operations on the list are done in critical sections (lock (lockObject) { ...
} ) in the usual way, to make sure that no...
|
by: Frinavale |
last post by:
Background
An Event is a message sent out by an object to notify other objects that an action/trigger/state-change (ie. an event) has taken place. Therefore, you should use an event when an object's...
|
by: Andy B |
last post by:
I am trying to figure out how to make an object instance available for all
methods of a class. I tried to do something like this:
public class test {
TheObject Instance = new TheObject();...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |