Esempio n. 1
0
        static void LoadTaskDialog()
        {
            if (!Utility.IsAvailablePlatform())
            {
                throw new PlatformNotSupportedException();
            }

            string systemDirectory = Environment.GetEnvironmentVariable("windir");

            foreach (string dir in Directory.EnumerateDirectories(Path.Combine(systemDirectory, "WinSxS"), $"{( IntPtr.Size == 4 ? "x86" : "amd64" )}_microsoft.windows.common-controls_6595b64144ccf1df_6.*"))
            {
                hModule = LoadLibraryEx(Path.Combine(dir, "comctl32.dll"), IntPtr.Zero, 0);
                IntPtr taskDialog         = GetProcAddress(hModule, "TaskDialog");
                IntPtr taskDialogIndirect = GetProcAddress(hModule, "TaskDialogIndirect");

                if (taskDialog == null || taskDialogIndirect == null)
                {
                    throw new PlatformNotSupportedException();
                }

#pragma warning disable 0618
                taskDialogAction         = Marshal.GetDelegateForFunctionPointer(taskDialog, typeof(TaskDialogDelegate)) as TaskDialogDelegate;
                taskDialogIndirectAction = Marshal.GetDelegateForFunctionPointer(taskDialogIndirect, typeof(TaskDialogIndirectDelegate)) as TaskDialogIndirectDelegate;
#pragma warning restore 0618

                break;
            }
        }
Esempio n. 2
0
    public static int HidP_GetVersion([NativeTypeName("ULONG *")] uint *Version)
    {
        int status = (((int)(((0x0) << 28) | (0x11 << 16) | (0))));

        *       Version = 1;
        HMODULE module  = (HMODULE)NativeLibrary.Load("hid.dll");

        if (module == HMODULE.NULL)
        {
            return(((int)(((0xC) << 28) | (0x11 << 16) | (8))));
        }

        ReadOnlySpan <sbyte> HidP_GetVersionInternal = new sbyte[] { 0x48, 0x69, 0x64, 0x50, 0x5F, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x49, 0x6E, 0x74, 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x00 };

        delegate * unmanaged <uint *, int> fnVersionInternal = (delegate * unmanaged <uint *, int>)(GetProcAddress(module, (sbyte *)Unsafe.AsPointer(ref MemoryMarshal.GetReference(HidP_GetVersionInternal))));

        if (fnVersionInternal != null)
        {
            status = fnVersionInternal(Version);
        }
        else
        {
        }

        return(status);
    }
Esempio n. 3
0
 public static extern IntPtr GetProcAddress(HMODULE hModule, [NativeTypeName("LPCSTR")] sbyte *lpProcName);
Esempio n. 4
0
 public static extern uint GetModuleFileNameA(HMODULE hModule, [NativeTypeName("LPSTR")] sbyte *lpFilename, [NativeTypeName("DWORD")] uint nSize);
Esempio n. 5
0
 public static extern BOOL FreeLibrary(HMODULE hLibModule);
Esempio n. 6
0
 public static extern BOOL DisableThreadLibraryCalls(HMODULE hLibModule);
Esempio n. 7
0
 public static extern uint SizeofResource(HMODULE hModule, HRSRC hResInfo);
 public HRESULT CreateSoftwareAdapter(HMODULE Module, IDXGIAdapter **ppAdapter)
 {
     return(((delegate * unmanaged <IDXGIFactory4 *, HMODULE, IDXGIAdapter **, int>)(lpVtbl[11]))((IDXGIFactory4 *)Unsafe.AsPointer(ref this), Module, ppAdapter));
 }
    /// <summary>
    /// Runs a specified application and starts the main loop to update its state. This is the entry point for a given application,
    /// and it should be called as soon as the process is launched, excluding any other additional initialization needed.
    /// </summary>
    /// <param name="application">The input application instance to run.</param>
    /// <returns>The exit code for the application.</returns>
    public static int Run(Win32Application application)
    {
        Win32ApplicationRunner.application = application;

        HMODULE hInstance = Windows.GetModuleHandleW(null);

        fixed(char *name = Assembly.GetExecutingAssembly().FullName)
        fixed(char *windowTitle = application.GetType().ToString())
        {
            // Initialize the window class
            WNDCLASSEXW windowClassEx = new()
            {
                cbSize        = (uint)sizeof(WNDCLASSEXW),
                style         = CS.CS_HREDRAW | CS.CS_VREDRAW,
                lpfnWndProc   = &WindowProc,
                hInstance     = hInstance,
                hCursor       = Windows.LoadCursorW(HINSTANCE.NULL, IDC.IDC_ARROW),
                lpszClassName = (ushort *)name
            };

            // Register the window class
            _ = Windows.RegisterClassExW(&windowClassEx);

            Rectangle windowRect = new(0, 0, 1280, 720);

            // Set the target window size
            _ = Windows.AdjustWindowRect((RECT *)&windowRect, WS.WS_OVERLAPPEDWINDOW, Windows.FALSE);

            uint height = (uint)(windowRect.Bottom - windowRect.Top);
            uint width  = (uint)(windowRect.Right - windowRect.Left);

            // Create the window and store a handle to it
            hwnd = Windows.CreateWindowExW(
                0,
                windowClassEx.lpszClassName,
                (ushort *)windowTitle,
                WS.WS_OVERLAPPEDWINDOW,
                Windows.CW_USEDEFAULT,
                Windows.CW_USEDEFAULT,
                (int)width,
                (int)height,
                HWND.NULL,
                HMENU.NULL,
                hInstance,
                (void *)GCHandle.ToIntPtr(GCHandle.Alloc(application))
                );

            MARGINS margins = default;

            margins.cxLeftWidth    = -1;
            margins.cxRightWidth   = -1;
            margins.cyTopHeight    = -1;
            margins.cyBottomHeight = -1;

            _ = Windows.DwmExtendFrameIntoClientArea(hwnd, &margins);
        }

        // Initialize the application
        application.OnInitialize(hwnd);

        // Display the window
        _ = Windows.ShowWindow(hwnd, SW.SW_SHOWDEFAULT);

        MSG msg = default;

        // Setup the render thread that enables smooth resizing of the window
        renderThread = new Thread(static args =>
Esempio n. 10
0
 public static extern HRESULT D3D10CreateDeviceAndSwapChain1(IDXGIAdapter *pAdapter, D3D10_DRIVER_TYPE DriverType, HMODULE Software, uint Flags, D3D10_FEATURE_LEVEL1 HardwareLevel, uint SDKVersion, DXGI_SWAP_CHAIN_DESC *pSwapChainDesc, IDXGISwapChain **ppSwapChain, ID3D10Device1 **ppDevice);
Esempio n. 11
0
 public static extern HRESULT D3D10CreateDevice1(IDXGIAdapter *pAdapter, D3D10_DRIVER_TYPE DriverType, HMODULE Software, uint Flags, D3D10_FEATURE_LEVEL1 HardwareLevel, uint SDKVersion, ID3D10Device1 **ppDevice);
Esempio n. 12
0
 public static extern int SizeofResource(
     HMODULE hModule,
     IntPtr hResInfo);
Esempio n. 13
0
 public static extern IntPtr LoadResource(
     HMODULE hModule,
     IntPtr hResInfo);
Esempio n. 14
0
 public static extern IntPtr FindResourceW(
     HMODULE hModule,
     IntPtr lpName,
     IntPtr lpType);
Esempio n. 15
0
 protected static extern int GetModuleBaseName(HANDLE hProcess, HMODULE hModule, StringBuilder lpBaseName, int nSize);
Esempio n. 16
0
 public static extern uint K32GetModuleBaseNameA(HANDLE hProcess, HMODULE hModule, [NativeTypeName("LPSTR")] sbyte *lpBaseName, [NativeTypeName("DWORD")] uint nSize);
Esempio n. 17
0
 static void Main(string[] args)
 {
     HMODULE hAppHelp = LoadLibraryW(wszShAppHelpDLL);
 }
Esempio n. 18
0
 public static extern uint K32GetModuleFileNameExW(HANDLE hProcess, HMODULE hModule, [NativeTypeName("LPWSTR")] ushort *lpFilename, [NativeTypeName("DWORD")] uint nSize);
Esempio n. 19
0
 [DllImport("kernel32.dll", SetLastError = true)] public static extern IntPtr GetProcAddress(HMODULE hModule, string lpModuleName);
Esempio n. 20
0
 public static extern BOOL K32GetModuleInformation(HANDLE hProcess, HMODULE hModule, [NativeTypeName("LPMODULEINFO")] MODULEINFO *lpmodinfo, [NativeTypeName("DWORD")] uint cb);
Esempio n. 21
0
 public static extern BOOL EnumResourceLanguagesExA(HMODULE hModule, [NativeTypeName("LPCSTR")] sbyte *lpType, [NativeTypeName("LPCSTR")] sbyte *lpName, [NativeTypeName("ENUMRESLANGPROCA")] delegate *unmanaged <HMODULE, sbyte *, sbyte *, ushort, nint, BOOL> lpEnumFunc, [NativeTypeName("LONG_PTR")] nint lParam, [NativeTypeName("DWORD")] uint dwFlags, [NativeTypeName("LANGID")] ushort LangId);
 public HRESULT LoadCmdFromResource(HMODULE hModule, [NativeTypeName("LPCWSTR")] ushort *pszResourceName, [NativeTypeName("LPCWSTR")] ushort *pszResourceType, [NativeTypeName("WORD")] ushort wLanguage, SPLOADOPTIONS Options)
 {
     return(((delegate * unmanaged <ISpRecoGrammar *, HMODULE, ushort *, ushort *, ushort, SPLOADOPTIONS, int>)(lpVtbl[15]))((ISpRecoGrammar *)Unsafe.AsPointer(ref this), hModule, pszResourceName, pszResourceType, wLanguage, Options));
 }
Esempio n. 23
0
 public static extern HRSRC FindResourceExW(HMODULE hModule, [NativeTypeName("LPCWSTR")] ushort *lpType, [NativeTypeName("LPCWSTR")] ushort *lpName, [NativeTypeName("WORD")] ushort wLanguage);
Esempio n. 24
0
 public static extern HRESULT D3D11CreateDevice(IDXGIAdapter *pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, uint Flags, [NativeTypeName("const D3D_FEATURE_LEVEL *")] D3D_FEATURE_LEVEL *pFeatureLevels, uint FeatureLevels, uint SDKVersion, ID3D11Device **ppDevice, D3D_FEATURE_LEVEL *pFeatureLevel, ID3D11DeviceContext **ppImmediateContext);
Esempio n. 25
0
 public static extern void FreeLibraryAndExitThread(HMODULE hLibModule, [NativeTypeName("DWORD")] uint dwExitCode);
Esempio n. 26
0
 public static extern HRESULT D3D11CreateDeviceAndSwapChain(IDXGIAdapter *pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, uint Flags, [NativeTypeName("const D3D_FEATURE_LEVEL *")] D3D_FEATURE_LEVEL *pFeatureLevels, uint FeatureLevels, uint SDKVersion, [NativeTypeName("const DXGI_SWAP_CHAIN_DESC *")] DXGI_SWAP_CHAIN_DESC *pSwapChainDesc, IDXGISwapChain **ppSwapChain, ID3D11Device **ppDevice, D3D_FEATURE_LEVEL *pFeatureLevel, ID3D11DeviceContext **ppImmediateContext);
Esempio n. 27
0
 public static extern uint GetModuleFileNameW(HMODULE hModule, [NativeTypeName("LPWSTR")] ushort *lpFilename, [NativeTypeName("DWORD")] uint nSize);
Esempio n. 28
0
		public static extern DWORD GetModuleFileNameEx(HANDLE hProcess, HMODULE hModule, LPTSTR lpFilename, DWORD nSize);
Esempio n. 29
0
 public static extern HGLOBAL LoadResource(HMODULE hModule, HRSRC hResInfo);
Esempio n. 30
0
 public static extern HRESULT D3D10CreateDevice(IDXGIAdapter *pAdapter, D3D10_DRIVER_TYPE DriverType, HMODULE Software, uint Flags, uint SDKVersion, ID3D10Device **ppDevice);