Beispiel #1
0
BOOL
WINAPI
DllMain ( HINSTANCE hInstance
        , DWORD reason
	, LPVOID reserved
	)
{
  /*
   * Note: the DllMain() doesn't call startupHaskell() for you,
   *       that is the task of users of the RTS. The reason is
   *       that *you* want to be able to control the arguments
   *       you pass to the RTS.
   */
  switch (reason) {
  case DLL_PROCESS_DETACH: shutdownHaskell();
  }
  return TRUE;
}
Beispiel #2
0
BOOL
STDCALL
DllMain
   ( HANDLE hModule
   , DWORD reason
   , void* reserved
   )
{
  if (reason == DLL_PROCESS_ATTACH) {
      /* By now, the RTS DLL should have been hoisted in, but we need to start
         it up.
	 
	 Note: for ghc-4.08 and later, you need to give the main / 'root module'
	 of the Haskell module you want to start running. So, if this is something 
	 other than 'ComDllMain', you'll need to tweak the invocation below.
      */
#if __GLASGOW_HASKELL__ >= 408
      startupHaskell( sizeof(args) / sizeof(char*)
		    , args
		    , &__stginit_ComDllMain
		    );
#else
      startupHaskell(sizeof(args) / sizeof(char*), args);
#endif
      comDll = newComDll(hModule);
      return TRUE;
  } else {
    if (comDll && reason == DLL_PROCESS_DETACH) {
        (comDll)->dllUnload();
	shutdownHaskell();
	/* Not properly letting go of memory here is rude, but we're shutting down.. */
	comDll=NULL;
    }
    return TRUE;
  }
}