Exemplo n.º 1
0
        private static bool GetProcs()
        {
            // Check if this is a 32 bit application
            if (IntPtr.Size != 4)
            {
#if DEBUG
                Console.WriteLine("Only 32 bit applications are supported.");
#endif

                return(false);
            }

            // Check if the nvapi.dll is available
            if (LoadLibrary("nvapi.dll") == IntPtr.Zero)
            {
#if DEBUG
                Console.WriteLine("The nvapi.dll could not be found.");
#endif

                return(false);
            }

            try
            {
                CreateApplication = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x4347A9DE), typeof(CreateApplicationDelegate)) as CreateApplicationDelegate;
                CreateProfile     = Marshal.GetDelegateForFunctionPointer(QueryInterface(0xCC176068), typeof(CreateProfileDelegate)) as CreateProfileDelegate;
                CreateSession     = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x0694D52E), typeof(CreateSessionDelegate)) as CreateSessionDelegate;
                DeleteProfile     = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x17093206), typeof(DeleteProfileDelegate)) as DeleteProfileDelegate;
                DestroySession    = Marshal.GetDelegateForFunctionPointer(QueryInterface(0xDAD9CFF8), typeof(DestroySessionDelegate)) as DestroySessionDelegate;
                EnumApplications  = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x7FA2173A), typeof(EnumApplicationsDelegate)) as EnumApplicationsDelegate;
                FindProfileByName = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x7E4A9A0B), typeof(FindProfileByNameDelegate)) as FindProfileByNameDelegate;
                GetProfileInfo    = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x61CD6FD6), typeof(GetProfileInfoDelegate)) as GetProfileInfoDelegate;
                Initialize        = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x0150E828), typeof(InitializeDelegate)) as InitializeDelegate;
                LoadSettings      = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x375DBD6B), typeof(LoadSettingsDelegate)) as LoadSettingsDelegate;
                SaveSettings      = Marshal.GetDelegateForFunctionPointer(QueryInterface(0xFCBC7E14), typeof(SaveSettingsDelegate)) as SaveSettingsDelegate;
                SetSetting        = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x577DD202), typeof(SetSettingDelegate)) as SetSettingDelegate;
            }
            catch (Exception)
            {
#if DEBUG
                Console.WriteLine("The procs of nvapi.dll could not be retrieved.");
#endif

                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
Arquivo: SOP.cs Projeto: callym/drip3d
        private static bool GetProcs()
        {
            // Check if this is a 32 bit application
            if (IntPtr.Size != 4)
            {
            #if DEBUG
                Console.WriteLine("Only 32 bit applications are supported.");
            #endif

                return false;
            }

            // Check if the nvapi.dll is available
            if (LoadLibrary("nvapi.dll") == IntPtr.Zero)
            {
            #if DEBUG
                Console.WriteLine("The nvapi.dll could not be found.");
            #endif

                return false;
            }

            try
            {
                CreateApplication = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x4347A9DE), typeof(CreateApplicationDelegate)) as CreateApplicationDelegate;
                CreateProfile = Marshal.GetDelegateForFunctionPointer(QueryInterface(0xCC176068), typeof(CreateProfileDelegate)) as CreateProfileDelegate;
                CreateSession = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x0694D52E), typeof(CreateSessionDelegate)) as CreateSessionDelegate;
                DeleteProfile = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x17093206), typeof(DeleteProfileDelegate)) as DeleteProfileDelegate;
                DestroySession = Marshal.GetDelegateForFunctionPointer(QueryInterface(0xDAD9CFF8), typeof(DestroySessionDelegate)) as DestroySessionDelegate;
                EnumApplications = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x7FA2173A), typeof(EnumApplicationsDelegate)) as EnumApplicationsDelegate;
                FindProfileByName = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x7E4A9A0B), typeof(FindProfileByNameDelegate)) as FindProfileByNameDelegate;
                GetProfileInfo = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x61CD6FD6), typeof(GetProfileInfoDelegate)) as GetProfileInfoDelegate;
                Initialize = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x0150E828), typeof(InitializeDelegate)) as InitializeDelegate;
                LoadSettings = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x375DBD6B), typeof(LoadSettingsDelegate)) as LoadSettingsDelegate;
                SaveSettings = Marshal.GetDelegateForFunctionPointer(QueryInterface(0xFCBC7E14), typeof(SaveSettingsDelegate)) as SaveSettingsDelegate;
                SetSetting = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x577DD202), typeof(SetSettingDelegate)) as SetSettingDelegate;
            }
            catch (Exception)
            {
            #if DEBUG
                Console.WriteLine("The procs of nvapi.dll could not be retrieved.");
            #endif

                return false;
            }

            return true;
        }