BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { _NXLogError( "DllMain got called!\n" ); switch( ul_reason_for_call ) { case DLL_PROCESS_ATTACH: __do_global_ctors(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: break; } return TRUE; }
static void trickyRemoveHandler (NXHandler *handler, int removingAlt) { AltHandler *altNode; NXHandler *node; NXHandler **nodePtr; ExceptionHandlerStack *me = findme (); /* try to find the node anywhere on the stack */ node = me->handlerStack; while (node != handler && node) { /* Watch for attempts to remove handlers which are outside the active portion of the stack. This happens when you return from an NX_DURING context without removing the handler. This code assumes the stack grows downward. */ #if hppa /* stack grows upward */ if (IS_ALT (node) || (void *) node < (void *) &altNode) node = NEXT_HANDLER (node); else #else if (IS_ALT (node) || (void *) node > (void *) &altNode) node = NEXT_HANDLER (node); else #endif { _NXLogError ("Exception handlers were not properly removed."); #if defined(WIN32) (void)RaiseException(0xdead, EXCEPTION_NONCONTINUABLE, 0, NULL); #else (void)abort (); #endif } } if (node) { /* * Clean off the stack up to the out of place node. If we are trying * to remove an non-alt handler, we pop eveything off the stack * including that handler, calling any alt procs along the way. If * we are removing an alt handler, we leave all the non-alt handlers * alone as we clean off the stack, but pop off all the alt handlers * we find, including the node we were asked to remove. */ if (!removingAlt) _NXLogError ("Exception handlers were not properly removed."); nodePtr = &me->handlerStack; do { node = *nodePtr; if (IS_ALT(node)) { altNode = ALT_CODE_TO_PTR(node); if (removingAlt) { if (node == handler) *nodePtr = altNode->next; /* del matching node */ else nodePtr = &altNode->next; /* skip node */ } else { if (node != handler) (*altNode->proc)(altNode->context, 1, 0, 0); me->altHandlersUsed = altNode - me->altHandlers; *nodePtr = altNode->next; /* del any alt node */ } } else { if (removingAlt) nodePtr = &node->next; /* skip node */ else *nodePtr = node->next; /* nuke non-alt node */ } } while (node != handler); } else { #ifdef KERNEL ; #else /* KERNEL */ _NXLogError ("Attempt to remove unrecognized exception handler."); #endif /* KERNEL */ } }