当前位置: 首页>>代码示例>>C#>>正文


C# SYSTEM_INFO类代码示例

本文整理汇总了C#中SYSTEM_INFO的典型用法代码示例。如果您正苦于以下问题:C# SYSTEM_INFO类的具体用法?C# SYSTEM_INFO怎么用?C# SYSTEM_INFO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SYSTEM_INFO类属于命名空间,在下文中一共展示了SYSTEM_INFO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GainMemoryAccess

        public static void GainMemoryAccess(IntPtr address, ulong len)
        {
            SYSTEM_INFO si = new SYSTEM_INFO();
            GetSystemInfo(out si);
            MEMORY_BASIC_INFORMATION mbi;
            ulong currentAddress = RoundUpToPageBoundary((ulong)address, si.pageSize);
            ulong endAddress = currentAddress + len;
            uint ret;
            uint oldProtect = 0;

            while (currentAddress < endAddress)
            {
                mbi = new MEMORY_BASIC_INFORMATION();
                ret = (uint)VirtualQuery((IntPtr)currentAddress, out mbi, (IntPtr)Marshal.SizeOf(mbi));
                if (ret != 0)
                {
                    if (mbi.state == MEM_COMMIT)
                    {
                        VirtualProtect(mbi.baseAddress, mbi.regionSize, PAGE_EXECUTE_READWRITE, out oldProtect);
                    }
                    if ((ulong)mbi.regionSize > 0) currentAddress += (ulong)mbi.regionSize;
                    else currentAddress += si.pageSize;
                }
                else currentAddress += si.pageSize;
            }
        }
开发者ID:nazariitashak,项目名称:UOMachine,代码行数:26,代码来源:GainMemoryAccess.cs

示例2: GetOperationSystemPlatform

        public static Platform GetOperationSystemPlatform()
        {
            var sysInfo = new SYSTEM_INFO();

            // WinXP and older - use GetNativeSystemInfo
            if (Environment.OSVersion.Version.Major > 5 ||
                (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1))
            {
                GetNativeSystemInfo(ref sysInfo);
            }
            // else use GetSystemInfo
            else
            {
                GetSystemInfo(ref sysInfo);
            }

            switch (sysInfo.wProcessorArchitecture)
            {
                case PROCESSOR_ARCHITECTURE_IA64:
                case PROCESSOR_ARCHITECTURE_AMD64:
                    return Platform.X64;

                case PROCESSOR_ARCHITECTURE_INTEL:
                    return Platform.X86;

                default:
                    return Platform.Unknown;
            }
        }
开发者ID:xieguigang,项目名称:Reference_SharedLib,代码行数:29,代码来源:PlatformType.cs

示例3: GetProcessorArchitecture

            public static string GetProcessorArchitecture()
            {
                try
                {
                    SYSTEM_INFO systemInfo = new SYSTEM_INFO();
                    GetNativeSystemInfo(ref systemInfo);
                    switch (systemInfo.wProcessorArchitecture)
                    {
                        case PROCESSOR_ARCHITECTURE_AMD64:
                        case PROCESSOR_ARCHITECTURE_IA64:
                            return "x64";

                        case PROCESSOR_ARCHITECTURE_ARM:
                            return "ARM";

                        case PROCESSOR_ARCHITECTURE_INTEL:
                            return "x86";

                        default:
                            return "Unknown";
                    }
                }
                catch
                {
                    return "Unknown";
                }
            }
开发者ID:ankurchoubeymsft,项目名称:azure-activedirectory-library-for-dotnet,代码行数:27,代码来源:AdalIdHelper.cs

示例4: Core

 public Core()
 {
     SYSTEM_INFO info = new SYSTEM_INFO();
     GetSystemInfo(ref info);
     PAGE_SIZE = info.pageSize;
     //dbg //mbd
     //CreateDataTypesXml();
 }
开发者ID:koinas,项目名称:VSPlot,代码行数:8,代码来源:core.cs

示例5: Main

        // finally...
        public static void Main()
        {
            // getting minimum & maximum address

            SYSTEM_INFO sys_info = new SYSTEM_INFO();
            GetSystemInfo(out sys_info);

            IntPtr proc_min_address = sys_info.minimumApplicationAddress;
            IntPtr proc_max_address = sys_info.maximumApplicationAddress;

            // saving the values as long ints so I won't have to do a lot of casts later
            long proc_min_address_l = (long)proc_min_address;
            long proc_max_address_l = (long)proc_max_address;

            // notepad better be runnin'
            Process process = Process.GetProcessesByName("tibia")[0];

            // opening the process with desired access level
            IntPtr processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_WM_READ, false, process.Id);

            StreamWriter sw = new StreamWriter("dump.txt");

            // this will store any information we get from VirtualQueryEx()
            MEMORY_BASIC_INFORMATION mem_basic_info = new MEMORY_BASIC_INFORMATION();

            int bytesRead = 0;  // number of bytes read with ReadProcessMemory

            while (proc_min_address_l < proc_max_address_l)
            {
                // 28 = sizeof(MEMORY_BASIC_INFORMATION)
                VirtualQueryEx(processHandle, proc_min_address, out mem_basic_info, 28);

                // if this memory chunk is accessible
                if (mem_basic_info.Protect == PAGE_READWRITE && mem_basic_info.State == MEM_COMMIT)
                {
                    byte[] buffer = new byte[mem_basic_info.RegionSize];

                    // read everything in the buffer above
                    ReadProcessMemory((int)processHandle, mem_basic_info.BaseAddress, buffer, mem_basic_info.RegionSize, ref bytesRead);

                    // then output this in the file
                    for (int i = 0; i < mem_basic_info.RegionSize; i++)
                        sw.WriteLine("0x{0} : {1}", (mem_basic_info.BaseAddress + i).ToString("X"), (char)buffer[i]);
                }

                // move to the next memory chunk
                proc_min_address_l += mem_basic_info.RegionSize;
                proc_min_address = new IntPtr(proc_min_address_l);
            }

            sw.Flush();
            sw.Close();

            Console.ReadLine();
        }
开发者ID:Nimelo,项目名称:AdvencedMemory,代码行数:56,代码来源:Program.cs

示例6: GetSystemInfo

 internal static new void GetSystemInfo(ref SYSTEM_INFO lpSystemInfo)
 {
     if (MonoUtility.IsLinux)
     {
         throw new ApplicationException("This method is not supported in mono");
     }
     else
     {
         NativeMethods.GetSystemInfo(ref lpSystemInfo);
     }
 }
开发者ID:andrei-markeev,项目名称:FastColoredTextBox,代码行数:11,代码来源:NativeMethodsWrapper.cs

示例7: VerifyProcessorCount

 bool VerifyProcessorCount()
 {
     SYSTEM_INFO sysInfo = new SYSTEM_INFO();
     SYSTEM_INFO.GetSystemInfo(ref sysInfo);
     if (Environment.ProcessorCount != sysInfo.dwNumberOfProcessors)
     {
         TestFramework.LogError("001", @"ProcessorCount not as expected. Expected (from Win32): " + sysInfo.dwNumberOfProcessors.ToString() + ", Actual (from CLR): " + Environment.ProcessorCount.ToString());
         return false;
     }
     return true;
 }
开发者ID:rdterner,项目名称:coreclr,代码行数:11,代码来源:environmentprocessorcount.cs

示例8: GetSystemInfoAbstracted

 /// <summary>
 /// Abstracts the retrieval of a SYSTEM_INFO structure.
 /// </summary>
 /// <param name="lpSystemInfo">A reference to a SYSTEM_INFO structure that receives the information.</param>
 public static void GetSystemInfoAbstracted(ref SYSTEM_INFO lpSystemInfo)
 {
     if (System.Environment.OSVersion.Version.Major > 5 || 
         (System.Environment.OSVersion.Version.Major == 5 && System.Environment.OSVersion.Version.Minor >= 1))
     {
         GetNativeSystemInfo(ref lpSystemInfo);
     }
     else
     {
         GetSystemInfo(ref lpSystemInfo);
     }
 }
开发者ID:bt-browser,项目名称:SparkleDotNET,代码行数:16,代码来源:NativeMethods.cs

示例9: Windows_ProcessorCountTest

        public void Windows_ProcessorCountTest()
        {
            //arrange
            SYSTEM_INFO sysInfo = new SYSTEM_INFO();
            GetSystemInfo(ref sysInfo);
            int expected = sysInfo.dwNumberOfProcessors;

            //act
            int actual = Environment.ProcessorCount;

            //assert
            Assert.True(actual > 0);
            Assert.Equal(expected, actual);
        }
开发者ID:shmao,项目名称:corefx,代码行数:14,代码来源:Environment.ProcessorCount.cs

示例10: GetProcessorType

        public static ProcessorType GetProcessorType()
        {
            SYSTEM_INFO sysInfo = new SYSTEM_INFO();
            GetNativeSystemInfo(ref sysInfo);

            switch (sysInfo.wProcessorArchitecture)
            {
                case PROCESSOR_TYPE_INTEL_AMD64:
                    return ProcessorType.X64;

                case PROCESSOR_TYPE_INTEL:
                    return ProcessorType.X86;

                default:
                    return ProcessorType.Unknown;
            }
        }
开发者ID:ymai,项目名称:DotNet_UtilityCodeAsset,代码行数:17,代码来源:CPU.cs

示例11: PreloadLibrary

        /// <summary>
        /// Try to preload the library.
        /// This is useful when we want to have AnyCPU .NET and CPU-specific native code.
        /// Only available on Windows for now.
        /// </summary>
        /// <param name="libraryName">Name of the library.</param>
        /// <exception cref="System.InvalidOperationException"></exception>
        public static void PreloadLibrary(string libraryName)
        {
#if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP
            var systemInfo = new SYSTEM_INFO();
            GetNativeSystemInfo(out systemInfo);

            string cpu;
            if (systemInfo.processorArchitecture == PROCESSOR_ARCHITECTURE.PROCESSOR_ARCHITECTURE_ARM)
                cpu = "ARM";
            else
                cpu = IntPtr.Size == 8 ? "x64" : "x86";
            var libraryFilename = Path.Combine(Path.GetDirectoryName(typeof(NativeLibrary).Assembly.Location), cpu, libraryName);
            var result = LoadLibrary(libraryFilename);

            if (result == IntPtr.Zero)
                throw new InvalidOperationException(string.Format("Could not load native library {0} using CPU architecture {1}.", libraryName, cpu));
#endif
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:25,代码来源:NativeLibrary.cs

示例12: GetProcessorArchitecture

        public static ProcessorArchitecture GetProcessorArchitecture()
        {
            SYSTEM_INFO si = new SYSTEM_INFO();
            GetNativeSystemInfo(ref si);
            switch (si.wProcessorArchitecture)
            {
                case PROCESSOR_ARCHITECTURE_AMD64:
                    return ProcessorArchitecture.Amd64;

                case PROCESSOR_ARCHITECTURE_IA64:
                    return ProcessorArchitecture.IA64;

                case PROCESSOR_ARCHITECTURE_INTEL:
                    return ProcessorArchitecture.X86;

                default:
                    return ProcessorArchitecture.None; // that's weird :-)
            }
        }
开发者ID:jackieit,项目名称:SdUpdater,代码行数:19,代码来源:Utils.cs

示例13: PreloadLibrary

        /// <summary>
        /// Try to preload the library.
        /// This is useful when we want to have AnyCPU .NET and CPU-specific native code.
        /// Only available on Windows for now.
        /// </summary>
        /// <param name="libraryName">Name of the library.</param>
        /// <exception cref="System.InvalidOperationException"></exception>
        public static void PreloadLibrary(string libraryName)
        {
#if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP
            lock (LoadedLibraries)
            {
                // If already loaded, just exit as we want to load it just once
                var libraryNameNormalized = libraryName.ToLowerInvariant();
                if (LoadedLibraries.ContainsKey(libraryNameNormalized))
                {
                    return;
                }

                var systemInfo = new SYSTEM_INFO();
                GetNativeSystemInfo(out systemInfo);

                string cpu;
                if (systemInfo.processorArchitecture == PROCESSOR_ARCHITECTURE.PROCESSOR_ARCHITECTURE_ARM)
                    cpu = "ARM";
                else
                    cpu = IntPtr.Size == 8 ? "x64" : "x86";

                // We are trying to load the dll from a shadow path if it is already registered, otherwise we use it directly from the folder
                var dllFolder = NativeLibraryInternal.GetShadowPathForNativeDll(libraryName) ?? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, cpu);
                var libraryFilename = Path.Combine(dllFolder, libraryName);
                var result = LoadLibrary(libraryFilename);

                if (result == IntPtr.Zero)
                {
                    throw new InvalidOperationException(string.Format("Could not load native library {0} from path [{1}] using CPU architecture {2}.", libraryName, libraryFilename, cpu));
                }
                else
                {
                    LoadedLibraries.Add(libraryName.ToLowerInvariant(), result);
                }
            }
#endif
        }
开发者ID:rock6tsai,项目名称:paradox,代码行数:44,代码来源:NativeLibrary.cs

示例14: GetSystemInfo

 private static extern void GetSystemInfo(out SYSTEM_INFO input);
开发者ID:er0dr1guez,项目名称:corefx,代码行数:1,代码来源:MemoryMappedFilesTestsBase.cs

示例15: GetNativeSystemInfo

 internal static extern void GetNativeSystemInfo(out SYSTEM_INFO info);
开发者ID:modulexcite,项目名称:nasmjit,代码行数:1,代码来源:VirtualMemory.cs


注:本文中的SYSTEM_INFO类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。