MCPcopy Create free account
hub / github.com/0x7c13/UnityEditor-DarkMode / DllMain

Function DllMain

UnityEditorDarkMode.cpp:612–643  ·  view source on GitHub ↗

DLL entry

Source from the content-addressed store, hash-verified

610
611// DLL entry
612bool APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpRes) {
613 switch (reason)
614 {
615 case DLL_PROCESS_ATTACH: {
616 // enable dark mode for the current process window
617 EnableDarkMode(nullptr);
618
619 // catch windows that have been created before we set up the CBTProc hook
620 std::vector<HWND> windowHandles;
621 GetAllWindowsByProcessID(GetCurrentProcessId(), windowHandles);
622
623 for (const HWND& hWnd : windowHandles) {
624 SetWindowSubclass(hWnd, CallWndSubClassProc, 0, 0);
625 EnableDarkMode(hWnd);
626 }
627
628 // set up the CBTProc hook to catch new windows
629 g_hook = SetWindowsHookEx(WH_CBT, CBTProc, nullptr, GetCurrentThreadId());
630 break;
631 }
632 case DLL_PROCESS_DETACH: {
633 if (g_hook) {
634 UnhookWindowsHookEx(g_hook);
635 g_hook = nullptr;
636 }
637 break;
638 }
639 default: break;
640 }
641
642 return true;
643}

Callers

nothing calls this directly

Calls 2

EnableDarkModeFunction · 0.85
GetAllWindowsByProcessIDFunction · 0.85

Tested by

no test coverage detected