-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/lindexi/lindexi_gd into dev
- Loading branch information
Showing
11 changed files
with
191 additions
and
32 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
CucherelahiBewilargalkalbea/CucherelahiBewilargalkalbea.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.6.33829.357 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CucherelahiBewilargalkalbea", "CucherelahiBewilargalkalbea\CucherelahiBewilargalkalbea.csproj", "{47BA7634-768D-4156-97C6-DE7E7B05265C}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{47BA7634-768D-4156-97C6-DE7E7B05265C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{47BA7634-768D-4156-97C6-DE7E7B05265C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{47BA7634-768D-4156-97C6-DE7E7B05265C}.Debug|x86.ActiveCfg = Debug|x86 | ||
{47BA7634-768D-4156-97C6-DE7E7B05265C}.Debug|x86.Build.0 = Debug|x86 | ||
{47BA7634-768D-4156-97C6-DE7E7B05265C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{47BA7634-768D-4156-97C6-DE7E7B05265C}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{47BA7634-768D-4156-97C6-DE7E7B05265C}.Release|x86.ActiveCfg = Release|x86 | ||
{47BA7634-768D-4156-97C6-DE7E7B05265C}.Release|x86.Build.0 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {EF4B5758-122F-458F-9AAF-DC9969C7F73D} | ||
EndGlobalSection | ||
EndGlobal |
9 changes: 9 additions & 0 deletions
9
CucherelahiBewilargalkalbea/CucherelahiBewilargalkalbea/App.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Application x:Class="CucherelahiBewilargalkalbea.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:CucherelahiBewilargalkalbea" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
15 changes: 15 additions & 0 deletions
15
CucherelahiBewilargalkalbea/CucherelahiBewilargalkalbea/App.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace CucherelahiBewilargalkalbea; | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} |
10 changes: 10 additions & 0 deletions
10
CucherelahiBewilargalkalbea/CucherelahiBewilargalkalbea/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
14 changes: 14 additions & 0 deletions
14
CucherelahiBewilargalkalbea/CucherelahiBewilargalkalbea/CucherelahiBewilargalkalbea.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<UseWPF>true</UseWPF> | ||
<LangVersion>latest</LangVersion> | ||
<Platforms>AnyCPU;x86</Platforms> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Windows.CsWin32" PrivateAssets="all" Version="0.2.63-beta" /> | ||
</ItemGroup> | ||
</Project> |
12 changes: 12 additions & 0 deletions
12
CucherelahiBewilargalkalbea/CucherelahiBewilargalkalbea/MainWindow.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Window x:Class="CucherelahiBewilargalkalbea.MainWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:CucherelahiBewilargalkalbea" | ||
mc:Ignorable="d" | ||
Title="MainWindow" Height="450" Width="800"> | ||
<Grid> | ||
<Button Click="Button_OnClick"></Button> | ||
</Grid> | ||
</Window> |
86 changes: 86 additions & 0 deletions
86
CucherelahiBewilargalkalbea/CucherelahiBewilargalkalbea/MainWindow.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Interop; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
using Windows.Win32.Foundation; | ||
using Windows.Win32.UI.WindowsAndMessaging; | ||
|
||
namespace CucherelahiBewilargalkalbea; | ||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class MainWindow : Window | ||
{ | ||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
|
||
SourceInitialized += MainWindow_SourceInitialized; | ||
} | ||
|
||
private void MainWindow_SourceInitialized(object? sender, EventArgs e) | ||
{ | ||
var windowInteropHelper = new WindowInteropHelper(this); | ||
var hwnd = windowInteropHelper.Handle; | ||
HookUIAutomationMessage(hwnd); | ||
} | ||
|
||
private void HookUIAutomationMessage(IntPtr windowPtr) | ||
{ | ||
// 获取原本的消息处理 | ||
var hWnd = new HWND(windowPtr); | ||
_oldWndProc = (IntPtr) Windows.Win32.PInvoke.GetWindowLong(hWnd, WINDOW_LONG_PTR_INDEX.GWL_WNDPROC); | ||
|
||
// 加入新的过滤处理 | ||
WindowProc? hookUIAutomationMessageWndProc = HookUIAutomationMessageWndProc; | ||
_hookUIAutomationMessageWndProcPointer = Marshal.GetFunctionPointerForDelegate(hookUIAutomationMessageWndProc); | ||
Windows.Win32.PInvoke.SetWindowLong(hWnd, WINDOW_LONG_PTR_INDEX.GWL_WNDPROC, | ||
// 这里强转 int 只有 x86 下才可用 | ||
(int) _hookUIAutomationMessageWndProcPointer); | ||
} | ||
|
||
private IntPtr HookUIAutomationMessageWndProc(IntPtr hwnd, uint msg, IntPtr wparam, IntPtr lparam) | ||
{ | ||
const uint WM_GETOBJECT = 0x003D; | ||
if (msg == WM_GETOBJECT) | ||
{ | ||
return IntPtr.Zero; | ||
} | ||
|
||
// 以下是调试代码 | ||
if (msg is 0x0201 or 0x0202) | ||
{ | ||
return IntPtr.Zero; | ||
} | ||
|
||
// 过滤通过之后,再调用原先的消息循环 | ||
return CallWindowProc(_oldWndProc, hwnd, msg, wparam, lparam); | ||
} | ||
|
||
public delegate IntPtr WindowProc(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam); | ||
|
||
private IntPtr _oldWndProc; | ||
private IntPtr _hookUIAutomationMessageWndProcPointer; | ||
|
||
[DllImport("user32", CharSet = CharSet.Unicode)] | ||
public static extern IntPtr CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, uint uMsg, IntPtr wParam, | ||
IntPtr lParam); | ||
|
||
private void Button_OnClick(object sender, RoutedEventArgs e) | ||
{ | ||
throw new NotSupportedException($"不应该进来,因为鼠标被 Hook 了"); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
CucherelahiBewilargalkalbea/CucherelahiBewilargalkalbea/NativeMethods.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
GetWindowLong | ||
SetWindowLong | ||
CallWindowProc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters