Exemplo n.º 1
0
        static User32()
        {
            IntPtr library = DynamicImport.ImportLibrary("user32.dll");

            CreateWindowEx             = DynamicImport.Import <CreateWindowExDelegate>(library, "CreateWindowExW");
            DefWindowProc              = DynamicImport.Import <DefWindowProcDelegate>(library, "DefWindowProcW");
            DestroyWindow              = DynamicImport.Import <DestroyWindowDelegate>(library, "DestroyWindow");
            DispatchMessage            = DynamicImport.Import <DispatchMessageDelegate>(library, "DispatchMessageW");
            GetClientRect              = DynamicImport.Import <GetClientRectDelegate>(library, "GetClientRect");
            GetWindow                  = DynamicImport.Import <GetWindowDelegate>(library, "GetWindow");
            GetWindowRect              = DynamicImport.Import <GetWindowRectDelegate>(library, "GetWindowRect");
            IsWindow                   = DynamicImport.Import <IsWindowDelegate>(library, "IsWindow");
            IsWindowVisible            = DynamicImport.Import <IsWindowVisibleDelegate>(library, "IsWindowVisible");
            MoveWindow                 = DynamicImport.Import <MoveWindowDelegate>(library, "MoveWindow");
            PeekMessage                = DynamicImport.Import <PeekMessageWDelegate>(library, "PeekMessageW");
            RegisterClassEx            = DynamicImport.Import <RegisterClassExDelegate>(library, "RegisterClassExW");
            SendMessage                = DynamicImport.Import <SendMessageDelegate>(library, "SendMessageW");
            SetLayeredWindowAttributes = DynamicImport.Import <SetLayeredWindowAttributesDelegate>(library, "SetLayeredWindowAttributes");
            SetWindowPos               = DynamicImport.Import <SetWindowPosDelegate>(library, "SetWindowPos");
            ShowWindow                 = DynamicImport.Import <ShowWindowDelegate>(library, "ShowWindow");
            TranslateMessage           = DynamicImport.Import <TranslateMessageDelegate>(library, "TranslateMessage");
            UnregisterClass            = DynamicImport.Import <UnregisterClassDelegate>(library, "UnregisterClassW");
            UpdateWindow               = DynamicImport.Import <UpdateWindowDelegate>(library, "UpdateWindow");
            WaitMessage                = DynamicImport.Import <WaitMessageDelegate>(library, "WaitMessage");
            PostMessage                = DynamicImport.Import <PostMessageWDelegate>(library, "PostMessageW");
            GetForegroundWindow        = DynamicImport.Import <GetForegroundWindowDelegate>(library, "GetForegroundWindow");

            try
            {
                _setThreadDpiAwarenessContext = DynamicImport.Import <SetThreadDpiAwarenessContextDelegate>(library, "SetThreadDpiAwarenessContext");
            }
            catch { } // ignored
        }
Exemplo n.º 2
0
        static User32()
        {
            IntPtr library = DynamicImport.ImportLibrary("user32.dll");

            CreateWindowEx             = DynamicImport.Import <CreateWindowExDelegate>(library, "CreateWindowExW");
            DefWindowProc              = DynamicImport.Import <DefWindowProcDelegate>(library, "DefWindowProcW");
            DestroyWindow              = DynamicImport.Import <DestroyWindowDelegate>(library, "DestroyWindow");
            DispatchMessage            = DynamicImport.Import <DispatchMessageDelegate>(library, "DispatchMessageW");
            GetClientRect              = DynamicImport.Import <GetClientRectDelegate>(library, "GetClientRect");
            GetWindow                  = DynamicImport.Import <GetWindowDelegate>(library, "GetWindow");
            GetWindowRect              = DynamicImport.Import <GetWindowRectDelegate>(library, "GetWindowRect");
            IsWindow                   = DynamicImport.Import <IsWindowDelegate>(library, "IsWindow");
            IsWindowVisible            = DynamicImport.Import <IsWindowVisibleDelegate>(library, "IsWindowVisible");
            MoveWindow                 = DynamicImport.Import <MoveWindowDelegate>(library, "MoveWindow");
            PeekMessage                = DynamicImport.Import <PeekMessageWDelegate>(library, "PeekMessageW");
            RegisterClassEx            = DynamicImport.Import <RegisterClassExDelegate>(library, "RegisterClassExW");
            SendMessage                = DynamicImport.Import <SendMessageDelegate>(library, "SendMessageW");
            SetLayeredWindowAttributes = DynamicImport.Import <SetLayeredWindowAttributesDelegate>(library, "SetLayeredWindowAttributes");
            SetWindowPos               = DynamicImport.Import <SetWindowPosDelegate>(library, "SetWindowPos");
            ShowWindow                 = DynamicImport.Import <ShowWindowDelegate>(library, "ShowWindow");
            TranslateMessage           = DynamicImport.Import <TranslateMessageDelegate>(library, "TranslateMessage");
            UnregisterClass            = DynamicImport.Import <UnregisterClassDelegate>(library, "UnregisterClassW");
            UpdateWindow               = DynamicImport.Import <UpdateWindowDelegate>(library, "UpdateWindow");
            WaitMessage                = DynamicImport.Import <WaitMessageDelegate>(library, "WaitMessage");
            PostMessage                = DynamicImport.Import <PostMessageWDelegate>(library, "PostMessageW");
            PostQuitMessage            = DynamicImport.Import <PostQuitMessageDelegate>(library, "PostQuitMessage");

            GetForegroundWindow = DynamicImport.Import <GetForegroundWindowDelegate>(library, "GetForegroundWindow");

            GetDesktopWindow         = DynamicImport.Import <GenericGetWindowDelegate>(library, "GetDesktopWindow");
            GetShellWindow           = DynamicImport.Import <GenericGetWindowDelegate>(library, "GetShellWindow");
            GetActiveWindow          = DynamicImport.Import <GenericGetWindowDelegate>(library, "GetActiveWindow");
            FindWindowEx             = DynamicImport.Import <FindWindowExWDelegate>(library, "FindWindowExW");
            GetWindowInfo            = DynamicImport.Import <GetWindowInfoDelegate>(library, "GetWindowInfo");
            GetWindowThreadProcessId = DynamicImport.Import <GetWindowThreadProcessIdDelegate>(library, "GetWindowThreadProcessId");

            SetForegroundWindow = DynamicImport.Import <SetForegroundWindowDelegate>(library, "SetForegroundWindow");

            if (IntPtr.Size == 4)
            {
                GetClassLongPtr  = DynamicImport.Import <GenericGetWindowLongDelegate>(library, "GetClassLongW");
                GetWindowLongPtr = DynamicImport.Import <GenericGetWindowLongDelegate>(library, "GetWindowLongW");
            }
            else
            {
                GetClassLongPtr  = DynamicImport.Import <GenericGetWindowLongDelegate>(library, "GetClassLongPtrW");
                GetWindowLongPtr = DynamicImport.Import <GenericGetWindowLongDelegate>(library, "GetWindowLongPtrW");
            }

            try
            {
                _setThreadDpiAwarenessContext = DynamicImport.Import <SetThreadDpiAwarenessContextDelegate>(library, "SetThreadDpiAwarenessContext");
            }
            catch { } // ignored
        }
        static void InstallIntroInjector()
        {
            if (ShowWindowHook != null || Managed)
            {
                return;
            }
#if !DEBUG
            CreateWindowExADel  = new CreateWindowExADelegate(hCreateWindowEx);
            CreateWindowExWDel  = new CreateWindowExWDelegate(hCreateWindowEx);
            CreateWindowExAHook = AutoHookCreator("user32.dll", "CreateWindowExA", CreateWindowExADel);
            CreateWindowExWHook = AutoHookCreator("user32.dll", "CreateWindowExW", CreateWindowExWDel);
            if (HookCreateWindowEx)
            {
                CreateWindowExADel = new CreateWindowExADelegate(hCreateWindowEx);
            }
#endif

            ShowWindowDel  = new ShowWindowDelegate(hShowWindow);
            ShowWindowHook = AutoHookCreator("user32.dll", "ShowWindow", ShowWindowDel);
            if (HookShowWindow)
            {
                ShowWindowHook.Install();
            }

            SetWindowPosDel  = new SetWindowPosDelegate(hSetWindowPos);
            SetWindowPosHook = AutoHookCreator("user32.dll", "SetWindowPos", SetWindowPosDel);
            if (HookSetWindowPos)
            {
                SetWindowPosHook.Install();
            }

            MoveWindowDel  = new MoveWindowDelegate(hMoveWindow);
            MoveWindowHook = AutoHookCreator("user32.dll", "MoveWindow", MoveWindowDel);
            if (HookMoveWindow)
            {
                MoveWindowHook.Install();
            }

            Log("Intro Injector Initialized...", true);
        }