tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

dllmain.cpp (1253B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #include <windows.h>
      6 #include <wrl.h>
      7 
      8 using namespace Microsoft::WRL;
      9 
     10 BOOL WINAPI DllMain(_In_opt_ HINSTANCE aInstance, _In_ DWORD aReason,
     11                    _In_opt_ LPVOID aReserved) {
     12  if (DLL_PROCESS_ATTACH == aReason) {
     13    DisableThreadLibraryCalls(aInstance);
     14    Module<InProc>::GetModule().Create();
     15  } else if (DLL_PROCESS_DETACH == aReason) {
     16    Module<InProc>::GetModule().Terminate();
     17  }
     18  return TRUE;
     19 }
     20 
     21 HRESULT WINAPI
     22 DllGetActivationFactory(_In_ HSTRING aActivatibleClassId,
     23                        _COM_Outptr_ IActivationFactory** aFactory) {
     24  auto& module = Module<InProc>::GetModule();
     25  return module.GetActivationFactory(aActivatibleClassId, aFactory);
     26 }
     27 
     28 HRESULT WINAPI DllCanUnloadNow() {
     29  auto& module = Module<InProc>::GetModule();
     30  return (module.Terminate()) ? S_OK : S_FALSE;
     31 }
     32 
     33 STDAPI DllGetClassObject(_In_ REFCLSID aRclsid, _In_ REFIID aRiid,
     34                         _COM_Outptr_ LPVOID FAR* aPpv) {
     35  auto& module = Module<InProc>::GetModule();
     36  return module.GetClassObject(aRclsid, aRiid, aPpv);
     37 }