Add callconv on win32 apis

This commit is contained in:
Lightczx
2024-02-02 10:38:40 +08:00
parent 7baf125f88
commit 20277b8b79
9 changed files with 47 additions and 47 deletions

View File

@@ -14,7 +14,7 @@ namespace Snap.Hutao.Win32;
[SuppressMessage("", "SYSLIB1054")]
internal static class AdvApi32
{
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[DllImport("ADVAPI32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static unsafe extern BOOL ConvertSidToStringSidW(PSID Sid, PWSTR* StringSid);
@@ -26,7 +26,7 @@ internal static class AdvApi32
}
}
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[DllImport("ADVAPI32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static unsafe extern BOOL ConvertStringSidToSidW(PCWSTR StringSid, PSID* Sid);
@@ -41,19 +41,19 @@ internal static class AdvApi32
}
}
[DllImport("ADVAPI32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("ADVAPI32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static extern BOOL EqualSid(PSID pSid1, PSID pSid2);
[DllImport("ADVAPI32.dll", ExactSpelling = true)]
[DllImport("ADVAPI32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static extern WIN32_ERROR RegCloseKey(HKEY hKey);
[DllImport("ADVAPI32.dll", ExactSpelling = true)]
[DllImport("ADVAPI32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static extern WIN32_ERROR RegNotifyChangeKeyValue(HKEY hKey, BOOL bWatchSubtree, REG_NOTIFY_FILTER dwNotifyFilter, [AllowNull] HANDLE hEvent, BOOL fAsynchronous);
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
[DllImport("ADVAPI32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static unsafe extern WIN32_ERROR RegOpenKeyExW(HKEY hKey, [AllowNull] PCWSTR lpSubKey, [AllowNull] uint ulOptions, REG_SAM_FLAGS samDesired, HKEY* phkResult);

View File

@@ -15,7 +15,7 @@ namespace Snap.Hutao.Win32;
[SuppressMessage("", "SYSLIB1054")]
internal static class ApiMsWinNetIsolation
{
[DllImport("api-ms-win-net-isolation-l1-1-0.dll", ExactSpelling = true)]
[DllImport("api-ms-win-net-isolation-l1-1-0.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows8.0")]
public static unsafe extern uint NetworkIsolationEnumAppContainers(uint Flags, uint* pdwNumPublicAppCs, INET_FIREWALL_APP_CONTAINER** ppPublicAppCs);
@@ -32,7 +32,7 @@ internal static class ApiMsWinNetIsolation
}
}
[DllImport("api-ms-win-net-isolation-l1-1-0.dll", ExactSpelling = true)]
[DllImport("api-ms-win-net-isolation-l1-1-0.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows8.0")]
public static unsafe extern uint NetworkIsolationFreeAppContainers(INET_FIREWALL_APP_CONTAINER* pPublicAppCs);
@@ -46,7 +46,7 @@ internal static class ApiMsWinNetIsolation
}
}
[DllImport("api-ms-win-net-isolation-l1-1-0.dll", ExactSpelling = true)]
[DllImport("api-ms-win-net-isolation-l1-1-0.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows8.0")]
public static unsafe extern uint NetworkIsolationGetAppContainerConfig(uint* pdwNumPublicAppCs, SID_AND_ATTRIBUTES** appContainerSids);
@@ -63,7 +63,7 @@ internal static class ApiMsWinNetIsolation
}
}
[DllImport("api-ms-win-net-isolation-l1-1-0.dll", ExactSpelling = true)]
[DllImport("api-ms-win-net-isolation-l1-1-0.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows8.0")]
public static unsafe extern uint NetworkIsolationSetAppContainerConfig(uint dwNumPublicAppCs, SID_AND_ATTRIBUTES* appContainerSids);

View File

@@ -12,15 +12,15 @@ namespace Snap.Hutao.Win32;
[SuppressMessage("", "SYSLIB1054")]
internal static class ComCtl32
{
[DllImport("COMCTL32.dll", ExactSpelling = true)]
[DllImport("COMCTL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static extern LRESULT DefSubclassProc(HWND hWnd, uint uMsg, WPARAM wParam, LPARAM lParam);
[DllImport("COMCTL32.dll", ExactSpelling = true)]
[DllImport("COMCTL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static extern BOOL RemoveWindowSubclass(HWND hWnd, [MarshalAs(UnmanagedType.FunctionPtr)] SUBCLASSPROC pfnSubclass, nuint uIdSubclass);
[DllImport("COMCTL32.dll", ExactSpelling = true)]
[DllImport("COMCTL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static unsafe extern BOOL SetWindowSubclass(HWND hWnd, [MarshalAs(UnmanagedType.FunctionPtr)] SUBCLASSPROC pfnSubclass, nuint uIdSubclass, nuint dwRefData);
}

View File

@@ -13,7 +13,7 @@ namespace Snap.Hutao.Win32;
[SuppressMessage("", "SYSLIB1054")]
internal static class DwmApi
{
[DllImport("dwmapi.dll", ExactSpelling = true)]
[DllImport("dwmapi.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows6.0.6000")]
public static unsafe extern HRESULT DwmSetWindowAttribute(HWND hwnd, uint dwAttribute, void* pvAttribute, uint cbAttribute);

View File

@@ -12,7 +12,7 @@ namespace Snap.Hutao.Win32;
[SuppressMessage("", "SYSLIB1054")]
internal static class Gdi32
{
[DllImport("GDI32.dll", ExactSpelling = true)]
[DllImport("GDI32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static extern int GetDeviceCaps([AllowNull] HDC hdc, int index);

View File

@@ -15,14 +15,14 @@ namespace Snap.Hutao.Win32;
[SuppressMessage("", "SYSLIB1054")]
internal static class Kernel32
{
[DllImport("KERNEL32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
public static extern BOOL AllocConsole();
[DllImport("KERNEL32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static extern BOOL CloseHandle(HANDLE hObject);
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static unsafe extern HANDLE CreateEventW([AllowNull] SECURITY_ATTRIBUTES* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, [AllowNull] PCWSTR lpName);
@@ -38,10 +38,10 @@ internal static class Kernel32
}
}
[DllImport("KERNEL32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
public static extern BOOL FreeConsole();
[DllImport("KERNEL32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
public static unsafe extern BOOL GetConsoleMode(HANDLE hConsoleHandle, CONSOLE_MODE* lpMode);
[SuppressMessage("", "SH002")]
@@ -54,10 +54,10 @@ internal static class Kernel32
}
}
[DllImport("KERNEL32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
public static extern HANDLE GetStdHandle(STD_HANDLE nStdHandle);
[DllImport("KERNEL32.dll", ExactSpelling = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
public static unsafe extern BOOL K32EnumProcessModules(HANDLE hProcess, HMODULE* lphModule, uint cb, uint* lpcbNeeded);
[DebuggerStepThrough]
@@ -72,7 +72,7 @@ internal static class Kernel32
}
}
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true)]
public static extern uint K32GetModuleBaseNameW(HANDLE hProcess, [AllowNull] HMODULE hModule, PWSTR lpBaseName, uint nSize);
[DebuggerStepThrough]
@@ -84,7 +84,7 @@ internal static class Kernel32
}
}
[DllImport("KERNEL32.dll", ExactSpelling = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
public static unsafe extern BOOL K32GetModuleInformation(HANDLE hProcess, HMODULE hModule, MODULEINFO* lpmodinfo, uint cb);
[DebuggerStepThrough]
@@ -96,7 +96,7 @@ internal static class Kernel32
}
}
[DllImport("KERNEL32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static unsafe extern BOOL ReadProcessMemory(HANDLE hProcess, void* lpBaseAddress, void* lpBuffer, nuint nSize, [MaybeNull] nuint* lpNumberOfBytesRead);
@@ -125,10 +125,10 @@ internal static class Kernel32
}
}
[DllImport("KERNEL32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
public static extern BOOL SetConsoleMode(HANDLE hConsoleHandle, CONSOLE_MODE dwMode);
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
public static extern BOOL SetConsoleTitleW(PCWSTR lpConsoleTitle);
[DebuggerStepThrough]
@@ -140,11 +140,11 @@ internal static class Kernel32
}
}
[DllImport("KERNEL32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static extern BOOL SetEvent(HANDLE hEvent);
[DllImport("KERNEL32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("KERNEL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static unsafe extern BOOL WriteProcessMemory(HANDLE hProcess, void* lpBaseAddress, void* lpBuffer, nuint nSize, nuint* lpNumberOfBytesWritten);

View File

@@ -13,7 +13,7 @@ namespace Snap.Hutao.Win32;
[SuppressMessage("", "SYSLIB1054")]
internal static class Ole32
{
[DllImport("OLE32.dll", ExactSpelling = true)]
[DllImport("OLE32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static unsafe extern HRESULT CoCreateInstance(Guid* rclsid, [AllowNull] IUnknown pUnkOuter, CLSCTX dwClsContext, Guid* riid, void** ppv);
@@ -33,11 +33,11 @@ internal static class Ole32
}
}
[DllImport("OLE32.dll", ExactSpelling = true)]
[DllImport("OLE32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static unsafe extern void CoTaskMemFree([AllowNull] void* pv);
[DllImport("OLE32.dll", ExactSpelling = true)]
[DllImport("OLE32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
public static unsafe extern HRESULT CoWaitForMultipleObjects(uint dwFlags, uint dwTimeout, uint cHandles, HANDLE* pHandles, uint* lpdwindex);
[SuppressMessage("", "SH002")]

View File

@@ -13,7 +13,7 @@ namespace Snap.Hutao.Win32;
[SuppressMessage("", "SYSLIB1054")]
internal static class Shell32
{
[DllImport("SHELL32.dll", ExactSpelling = true)]
[DllImport("SHELL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows6.0.6000")]
public static unsafe extern HRESULT SHCreateItemFromParsingName(PCWSTR pszPath, [AllowNull] IBindCtx pbc, Guid* riid, void** ppv);

View File

@@ -15,11 +15,11 @@ namespace Snap.Hutao.Win32;
[SuppressMessage("", "SYSLIB1054")]
internal static class User32
{
[DllImport("USER32.dll", ExactSpelling = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.1.2600")]
public static extern BOOL AttachThreadInput(uint idAttach, uint idAttachTo, BOOL fAttach);
[DllImport("USER32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.0")]
public static extern HWND FindWindowExW([AllowNull] HWND hWndParent, [AllowNull] HWND hWndChildAfter, [AllowNull] PCWSTR lpszClass, [AllowNull] PCWSTR lpszWindow);
@@ -35,23 +35,23 @@ internal static class User32
}
}
[DllImport("USER32.dll", ExactSpelling = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static extern HDC GetDC([AllowNull] HWND hWnd);
[DllImport("USER32.dll", ExactSpelling = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows10.0.14393")]
public static extern uint GetDpiForWindow(HWND hwnd);
[DllImport("USER32.dll", ExactSpelling = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static extern HWND GetForegroundWindow();
[DllImport("USER32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.0")]
public static extern nint GetWindowLongPtrW(HWND hWnd, WINDOW_LONG_PTR_INDEX nIndex);
[DllImport("USER32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static unsafe extern BOOL GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT* lpwndpl);
@@ -64,7 +64,7 @@ internal static class User32
}
}
[DllImport("USER32.dll", ExactSpelling = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static unsafe extern uint GetWindowThreadProcessId(HWND hWnd, [MaybeNull] uint* lpdwProcessId);
@@ -77,15 +77,15 @@ internal static class User32
}
}
[DllImport("USER32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows6.0.6000")]
public static extern BOOL RegisterHotKey([AllowNull] HWND hWnd, int id, HOT_KEY_MODIFIERS fsModifiers, uint vk);
[DllImport("USER32.dll", ExactSpelling = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static extern int ReleaseDC([AllowNull] HWND hWnd, HDC hDC);
[DllImport("USER32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.0")]
public static unsafe extern uint SendInput(uint cInputs, INPUT* pInputs, int cbSize);
@@ -98,15 +98,15 @@ internal static class User32
}
}
[DllImport("USER32.dll", ExactSpelling = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static extern BOOL SetForegroundWindow(HWND hWnd);
[DllImport("USER32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.0")]
public static extern nint SetWindowLongPtrW(HWND hWnd, WINDOW_LONG_PTR_INDEX nIndex, nint dwNewLong);
[DllImport("USER32.dll", ExactSpelling = true, SetLastError = true)]
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static extern BOOL UnregisterHotKey([AllowNull] HWND hWnd, int id);
}