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>
<PackageId>Yae.Lib</PackageId>
<Version>5.4.0</Version>
<Version>5.4.1</Version>
<Authors>HoloHat</Authors>
<DevelopmentDependency>true</DevelopmentDependency>
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>

View File

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

View File

@@ -43,6 +43,9 @@ internal static unsafe partial class Kernel32 {
[return:MarshalAs(UnmanagedType.I4)]
[LibraryImport("KERNEL32.dll", SetLastError = true)]
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);
}