call awake in wndhook

This commit is contained in:
HolographicHat
2025-08-04 22:27:48 +08:00
parent 3f42156b20
commit c96395e1a2
3 changed files with 10 additions and 1 deletions

View File

@@ -43,7 +43,7 @@
<PropertyGroup> <PropertyGroup>
<PackageId>Yae.Lib</PackageId> <PackageId>Yae.Lib</PackageId>
<Version>5.4.0</Version> <Version>5.4.1</Version>
<Authors>HoloHat</Authors> <Authors>HoloHat</Authors>
<DevelopmentDependency>true</DevelopmentDependency> <DevelopmentDependency>true</DevelopmentDependency>
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression> <PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>

View File

@@ -7,8 +7,13 @@ namespace Yae;
internal static unsafe class Application { internal static unsafe class Application {
private static bool _initialized;
[UnmanagedCallersOnly(EntryPoint = "YaeMain")] [UnmanagedCallersOnly(EntryPoint = "YaeMain")]
private static uint Awake(nint hModule) { private static uint Awake(nint hModule) {
if (Interlocked.Exchange(ref _initialized, true)) {
return 1;
}
Native.RegisterUnhandledExceptionHandler(); Native.RegisterUnhandledExceptionHandler();
Log.UseConsoleOutput(); Log.UseConsoleOutput();
Log.Trace("~"); Log.Trace("~");
@@ -29,6 +34,7 @@ internal static unsafe class Application {
[UnmanagedCallersOnly(EntryPoint = "YaeWndHook")] [UnmanagedCallersOnly(EntryPoint = "YaeWndHook")]
private static nint WndHook(int nCode, nint wParam, nint lParam) { private static nint WndHook(int nCode, nint wParam, nint lParam) {
((delegate*unmanaged<nint, uint>) &Awake)(0);
return User32.CallNextHookEx(0, nCode, wParam, lParam); return User32.CallNextHookEx(0, nCode, wParam, lParam);
} }

View File

@@ -43,6 +43,9 @@ internal static unsafe partial class Kernel32 {
[return:MarshalAs(UnmanagedType.I4)] [return:MarshalAs(UnmanagedType.I4)]
[LibraryImport("KERNEL32.dll", SetLastError = true)] [LibraryImport("KERNEL32.dll", SetLastError = true)]
internal static partial bool SetConsoleMode(nint hConsoleHandle, uint dwMode); internal static partial bool SetConsoleMode(nint hConsoleHandle, uint dwMode);
[LibraryImport("KERNEL32.dll", SetLastError = true)]
internal static partial nint CreateThread(nint lpThreadAttributes, nint dwStackSize, delegate*unmanaged<nint, uint> lpStartAddress, nint lpParameter, uint dwCreationFlags, uint* lpThreadId);
} }