I wanted to do a out-of-process exception handler and i had created a watch-dog process which does dedicated exception handling when child process raises exception. I had successfully invoked the watchdog process through events . The problem i am facing is while trying to pass the exception information pointers to the other process .
I landed here Passing a pointer to process spawned with exec() and came to know that passing pointers in shared memory has this issue :
"If you use shared memory, you can't pass the pointer. The pointer will contain the virtual address, which is different from one process to another. You have to exchange offset values, based on the start of the shared memory area.
If you don't use shared memory, you can't exchange pointers of any kind: The other process won't be able to access the memory of your process."
Now how can i overcome this ?
Process 1 :
struct mytest
{
_EXCEPTION_POINTERS * except ;
DWORD ThreadId ;
DWORD ProcessId ;
}
OpenFileMapping ( ) ;
void * pBuf = MapViewOfFile ( ) ;
mytest passdata ;
CopyMemory ( pBuf , &passdata , sizeof ( passdata ) ) ;
UnMapView ( ) ;
CloseHandle ( ) ;
(For ex)Process 2 :
cout << passdata->except->ExceptionRecord->ExceptionCode << endl ;
would crash . I understand this is because virtual address is process specific . But in this case how to pass exception information to different process and write a minidump ??
P.S : I even tried passing PEXCEPTION_RECORD structures seperately but does not work .