Parent Directory
|
Revision Log
|
Patch
--- trunk/RomCheater/Docking/MemorySearch/ResultItemState.cs 2012/06/19 07:56:36 378 +++ trunk/RomCheater/Docking/MemorySearch/ResultItemState.cs 2012/06/20 12:16:34 398 @@ -74,12 +74,9 @@ : this(AVPIconKeys.NOTFROZEN, address, "", false.ToString(), bitsize, IsUnsigned, pconfig) { int Address = 0; - Address = Convert.ToInt32(this.Address, 16); - GenericMemoryProvider provider = new GenericMemoryProvider(pconfig); - provider.OpenProvider(); + Address = Convert.ToInt32(this.Address, 16); int bytesReadSize; - byte[] data; - uint bytesToRead=0; + uint bytesToRead = 0; switch (bitsize) { case SearchDataTypes._8bits: @@ -95,33 +92,41 @@ bytesToRead = 8; break; } - - provider.ReadProcessMemory(Address, bytesToRead, out bytesReadSize, out data); - MemoryStream ms = new MemoryStream(data); - BinaryReader r_ms = new BinaryReader(ms); - - //r_ms.BaseStream.Seek(Address, SeekOrigin.Begin); - //int val = 0; - switch (bitsize) + byte[] data = new byte[bytesToRead]; + using (GenericMemoryProvider provider = new GenericMemoryProvider(pconfig)) { - case SearchDataTypes._8bits: - if (IsUnsigned) { this.Value = string.Format("0x{0:x2}", r_ms.ReadByte()); } - else { this.Value = string.Format("0x{0:x2}", r_ms.ReadSByte()); } - break; - case SearchDataTypes._16bits: - if (IsUnsigned) { this.Value = string.Format("0x{0:x4}", r_ms.ReadUInt16()); } - else { this.Value = string.Format("0x{0:x4}", r_ms.ReadInt16()); } - break; - case SearchDataTypes._32bits: - if (IsUnsigned) { this.Value = string.Format("0x{0:x8}", r_ms.ReadUInt32()); } - else { this.Value = string.Format("0x{0:x8}", r_ms.ReadInt32()); } - break; - case SearchDataTypes._64bits: - if (IsUnsigned) { this.Value = string.Format("0x{0:x16}", r_ms.ReadUInt64()); } - else { this.Value = string.Format("0x{0:x16}", r_ms.ReadInt64()); } - break; + provider.OpenProvider(); + provider.ReadProcessMemory(Address, bytesToRead, out bytesReadSize, out data); + provider.CloseProvider(); + } + using (MemoryStream ms = new MemoryStream(data)) + { + using (BinaryReader r_ms = new BinaryReader(ms)) + { + + //r_ms.BaseStream.Seek(Address, SeekOrigin.Begin); + //int val = 0; + switch (bitsize) + { + case SearchDataTypes._8bits: + if (IsUnsigned) { this.Value = string.Format("0x{0:x2}", r_ms.ReadByte()); } + else { this.Value = string.Format("0x{0:x2}", r_ms.ReadSByte()); } + break; + case SearchDataTypes._16bits: + if (IsUnsigned) { this.Value = string.Format("0x{0:x4}", r_ms.ReadUInt16()); } + else { this.Value = string.Format("0x{0:x4}", r_ms.ReadInt16()); } + break; + case SearchDataTypes._32bits: + if (IsUnsigned) { this.Value = string.Format("0x{0:x8}", r_ms.ReadUInt32()); } + else { this.Value = string.Format("0x{0:x8}", r_ms.ReadInt32()); } + break; + case SearchDataTypes._64bits: + if (IsUnsigned) { this.Value = string.Format("0x{0:x16}", r_ms.ReadUInt64()); } + else { this.Value = string.Format("0x{0:x16}", r_ms.ReadInt64()); } + break; + } + } } - provider.CloseProvider(); } public ResultItemState(string IconKey, string address, string value, string frozen, SearchDataTypes bitsize, bool IsUnsigned, IAcceptsProcessAndConfig pconfig) : this(pconfig)
ViewVC Help | |
Powered by ViewVC 1.1.22 |