日期:2014-05-17  浏览次数:21476 次

读取内存中的值,怎么读取float?
C# code



       //读取内存中的整数 
        public int ReadMemoryValue(int address, int processId)
        {
            try
            {
                byte[] buffer = new byte[4];

                IntPtr byteAddress = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0); //获取缓冲区地址
                IntPtr hProcess = OpenProcess(0x1F0FFF, false, processId);
                ReadProcessMemory(hProcess, (IntPtr)address, byteAddress, 4, IntPtr.Zero); //将制定内存中的值读入缓冲区
                CloseHandle(hProcess);
                Console.WriteLine(Marshal.ReadIntPtr(byteAddress));
                return Marshal.ReadInt32(byteAddress);  

            }
            catch
            {
                return 0;
            }
        }


 这个是整数的,怎么读取浮点类型的值?如果有 Marshal.ReadFloat() 就好了...






------解决方案--------------------
http://topic.csdn.net/u/20071015/16/20e927fe-01ee-43bc-919f-edcb9bed6a09.html
------解决方案--------------------
使用BitConverter类。