100 |
|
private Process m_ReadProcess = null; |
101 |
|
|
102 |
|
//SafeWaitHandle handle; |
103 |
< |
private static IntPtr handle = IntPtr.Zero; |
103 |
> |
//private IntPtr handle = IntPtr.Zero; |
104 |
|
//SafeWaitHandle m_hProcess; /* unused */ |
105 |
< |
public void OpenProcess() |
106 |
< |
{ |
107 |
< |
try |
108 |
< |
{ |
109 |
< |
// m_hProcess = ProcessMemoryReaderApi.OpenProcess(ProcessMemoryReaderApi.PROCESS_VM_READ, 1, (uint)m_ReadProcess.Id); |
110 |
< |
//if (!TokenAdjuster.AdjustProcessTokenPrivileges("SeDebugPrivilege")) |
111 |
< |
//{ |
112 |
< |
// logger.Warn.WriteLine("Failed to set SeDebugPrivilege on current process"); |
113 |
< |
//} |
114 |
< |
ProcessAccessFlags access; |
115 |
< |
access = ProcessAccessFlags.VMRead |
116 |
< |
| ProcessAccessFlags.VMWrite |
117 |
< |
| ProcessAccessFlags.VMOperation; |
118 |
< |
//m_hProcess = ProcessMemoryReaderApi.OpenProcess((uint)access, 1, (uint)m_ReadProcess.Id); |
119 |
< |
handle = ProcessMemoryReaderApi.OpenProcess(access, true, m_ReadProcess.Id); |
120 |
< |
//m_hProcess = new SafeWaitHandle(handle, false); |
121 |
< |
} |
122 |
< |
catch (SEHException ex) |
123 |
< |
{ |
124 |
< |
logger.Error.WriteLine("WriteProcessMemoryToFile() SEHException was thrown: (0x{0:x8}) - {1}", ex.ErrorCode, ex.Message); |
125 |
< |
logger.Error.WriteLine(ex.ToString()); |
126 |
< |
throw ex; |
127 |
< |
} |
128 |
< |
catch (Exception ex) |
129 |
< |
{ |
130 |
< |
logger.Error.WriteLine(ex.ToString()); |
131 |
< |
throw ex; |
132 |
< |
} |
133 |
< |
} |
134 |
< |
|
135 |
< |
public void CloseHandle() |
136 |
< |
{ |
137 |
< |
try |
138 |
< |
{ |
139 |
< |
////if (handle.IsInvalid) { return; } |
140 |
< |
////if (handle.IsClosed) { return; } |
141 |
< |
//m_hProcess.Close(); |
142 |
< |
//m_hProcess.Dispose(); |
143 |
< |
//m_hProcess = null; |
144 |
< |
//handle = IntPtr.Zero; |
145 |
< |
//m_ReadProcess = null; |
146 |
< |
//string stack_trace = System.Environment.StackTrace; |
147 |
< |
int iRetValue; |
148 |
< |
iRetValue = ProcessMemoryReaderApi.CloseHandle(handle); |
149 |
< |
handle = IntPtr.Zero; |
150 |
< |
ReadProcess = null; |
151 |
< |
if (iRetValue == 0) |
152 |
< |
{ |
153 |
< |
throw new Exception("CloseHandle failed"); |
154 |
< |
} |
155 |
< |
} |
156 |
< |
catch (SEHException ex) |
157 |
< |
{ |
158 |
< |
logger.Error.WriteLine("WriteProcessMemoryToFile() SEHException was thrown: (0x{0:x8}) - {1}", ex.ErrorCode, ex.Message); |
159 |
< |
logger.Error.WriteLine(ex.ToString()); |
160 |
< |
throw ex; |
161 |
< |
} |
162 |
< |
catch (Exception ex) |
163 |
< |
{ |
164 |
< |
logger.Error.WriteLine(ex.ToString()); |
165 |
< |
throw ex; |
166 |
< |
} |
167 |
< |
} |
105 |
> |
//public void OpenProcess() |
106 |
> |
//{ |
107 |
> |
// try |
108 |
> |
// { |
109 |
> |
// // m_hProcess = ProcessMemoryReaderApi.OpenProcess(ProcessMemoryReaderApi.PROCESS_VM_READ, 1, (uint)m_ReadProcess.Id); |
110 |
> |
// //if (!TokenAdjuster.AdjustProcessTokenPrivileges("SeDebugPrivilege")) |
111 |
> |
// //{ |
112 |
> |
// // logger.Warn.WriteLine("Failed to set SeDebugPrivilege on current process"); |
113 |
> |
// //} |
114 |
> |
// ProcessAccessFlags access; |
115 |
> |
// access = ProcessAccessFlags.VMRead |
116 |
> |
// | ProcessAccessFlags.VMWrite |
117 |
> |
// | ProcessAccessFlags.VMOperation; |
118 |
> |
// //m_hProcess = ProcessMemoryReaderApi.OpenProcess((uint)access, 1, (uint)m_ReadProcess.Id); |
119 |
> |
// handle = ProcessMemoryReaderApi.OpenProcess(access, true, m_ReadProcess.Id); |
120 |
> |
// //m_hProcess = new SafeWaitHandle(handle, false); |
121 |
> |
// } |
122 |
> |
// catch (SEHException ex) |
123 |
> |
// { |
124 |
> |
// logger.Error.WriteLine("WriteProcessMemoryToFile() SEHException was thrown: (0x{0:x8}) - {1}", ex.ErrorCode, ex.Message); |
125 |
> |
// logger.Error.WriteLine(ex.ToString()); |
126 |
> |
// throw ex; |
127 |
> |
// } |
128 |
> |
// catch (Exception ex) |
129 |
> |
// { |
130 |
> |
// logger.Error.WriteLine(ex.ToString()); |
131 |
> |
// throw ex; |
132 |
> |
// } |
133 |
> |
//} |
134 |
> |
|
135 |
> |
//public void CloseHandle() |
136 |
> |
//{ |
137 |
> |
// try |
138 |
> |
// { |
139 |
> |
// ////if (handle.IsInvalid) { return; } |
140 |
> |
// ////if (handle.IsClosed) { return; } |
141 |
> |
// //m_hProcess.Close(); |
142 |
> |
// //m_hProcess.Dispose(); |
143 |
> |
// //m_hProcess = null; |
144 |
> |
// //handle = IntPtr.Zero; |
145 |
> |
// //m_ReadProcess = null; |
146 |
> |
// //string stack_trace = System.Environment.StackTrace; |
147 |
> |
// int iRetValue; |
148 |
> |
// iRetValue = ProcessMemoryReaderApi.CloseHandle(handle); |
149 |
> |
// handle = IntPtr.Zero; |
150 |
> |
// ReadProcess = null; |
151 |
> |
// if (iRetValue == 0) |
152 |
> |
// { |
153 |
> |
// throw new Exception("CloseHandle failed"); |
154 |
> |
// } |
155 |
> |
// } |
156 |
> |
// catch (SEHException ex) |
157 |
> |
// { |
158 |
> |
// logger.Error.WriteLine("WriteProcessMemoryToFile() SEHException was thrown: (0x{0:x8}) - {1}", ex.ErrorCode, ex.Message); |
159 |
> |
// logger.Error.WriteLine(ex.ToString()); |
160 |
> |
// throw ex; |
161 |
> |
// } |
162 |
> |
// catch (Exception ex) |
163 |
> |
// { |
164 |
> |
// logger.Error.WriteLine(ex.ToString()); |
165 |
> |
// throw ex; |
166 |
> |
// } |
167 |
> |
//} |
168 |
|
/// <summary> |
169 |
|
/// ProcessMemoryReader is a class that enables direct reading a process memory |
170 |
|
/// </summary> |
435 |
|
{ |
436 |
|
try |
437 |
|
{ |
438 |
< |
uint _bytesWritten = 0; |
438 |
> |
//uint _bytesWritten = 0; |
439 |
|
uint _MemoryAddress = MemoryAddress; |
440 |
< |
for (int i = 0; i < bytesToWrite.Length; i++) |
440 |
> |
|
441 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)MemoryAddress, bytesToWrite.Length)) |
442 |
|
{ |
443 |
< |
UIntPtr _ptrBytesWritten = UIntPtr.Zero; |
443 |
< |
byte[] buffer = new byte[] { bytesToWrite[i] }; |
444 |
< |
ProcessMemoryReaderApi.WriteProcessMemory(handle, (IntPtr)_MemoryAddress, buffer, (uint)buffer.Length, out _ptrBytesWritten); |
445 |
< |
_MemoryAddress++; |
446 |
< |
_bytesWritten++; |
443 |
> |
mem.Write(0, bytesToWrite); |
444 |
|
} |
445 |
< |
bytesWritten = _bytesWritten; |
445 |
> |
|
446 |
> |
//for (int i = 0; i < bytesToWrite.Length; i++) |
447 |
> |
//{ |
448 |
> |
// UIntPtr _ptrBytesWritten = UIntPtr.Zero; |
449 |
> |
// byte[] buffer = new byte[] { bytesToWrite[i] }; |
450 |
> |
// ProcessMemoryReaderApi.WriteProcessMemory(handle, (IntPtr)_MemoryAddress, buffer, (uint)buffer.Length, out _ptrBytesWritten); |
451 |
> |
// _MemoryAddress++; |
452 |
> |
// _bytesWritten++; |
453 |
> |
//} |
454 |
> |
//bytesWritten = _bytesWritten; |
455 |
> |
bytesWritten = (uint)bytesToWrite.Length; |
456 |
|
} |
457 |
|
catch (SEHException ex) |
458 |
|
{ |
553 |
|
public virtual bool PatchMemory(uint address, byte value) |
554 |
|
{ |
555 |
|
byte[] bitData = BitConverter.GetBytes(value); |
556 |
< |
UIntPtr ptrBytesWritten; |
557 |
< |
ProcessMemoryReaderApi.WriteProcessMemory(handle, (IntPtr)address, bitData, (uint)bitData.Length, out ptrBytesWritten); |
558 |
< |
if (ptrBytesWritten.ToUInt32() == 0) |
559 |
< |
return false; |
556 |
> |
//UIntPtr ptrBytesWritten; |
557 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, bitData.Length)) |
558 |
> |
{ |
559 |
> |
mem.Write(0, bitData); |
560 |
> |
} |
561 |
> |
//ProcessMemoryReaderApi.WriteProcessMemory(handle, (IntPtr)address, bitData, (uint)bitData.Length, out ptrBytesWritten); |
562 |
> |
//if (ptrBytesWritten.ToUInt32() == 0) |
563 |
> |
// return false; |
564 |
|
byte check = 0; |
565 |
|
ReadMemory(address, out check); |
566 |
|
if (check == value) return true; |
571 |
|
public virtual bool PatchMemory(uint address, sbyte value) |
572 |
|
{ |
573 |
|
byte[] bitData = BitConverter.GetBytes(value); |
574 |
< |
UIntPtr ptrBytesWritten; |
575 |
< |
ProcessMemoryReaderApi.WriteProcessMemory(handle, (IntPtr)address, bitData, (uint)bitData.Length, out ptrBytesWritten); |
576 |
< |
if (ptrBytesWritten.ToUInt32() == 0) |
577 |
< |
return false; |
574 |
> |
//UIntPtr ptrBytesWritten; |
575 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, bitData.Length)) |
576 |
> |
{ |
577 |
> |
mem.Write(0, bitData); |
578 |
> |
} |
579 |
> |
//ProcessMemoryReaderApi.WriteProcessMemory(handle, (IntPtr)address, bitData, (uint)bitData.Length, out ptrBytesWritten); |
580 |
> |
//if (ptrBytesWritten.ToUInt32() == 0) |
581 |
> |
// return false; |
582 |
|
sbyte check = 0; |
583 |
|
ReadMemory(address, out check); |
584 |
|
if (check == value) return true; |
589 |
|
public virtual bool PatchMemory(uint address, ushort value) |
590 |
|
{ |
591 |
|
byte[] bitData = BitConverter.GetBytes(value); |
592 |
< |
UIntPtr ptrBytesWritten; |
593 |
< |
ProcessMemoryReaderApi.WriteProcessMemory(handle, (IntPtr)address, bitData, (uint)bitData.Length, out ptrBytesWritten); |
594 |
< |
if (ptrBytesWritten.ToUInt32() == 0) |
595 |
< |
return false; |
592 |
> |
//UIntPtr ptrBytesWritten; |
593 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, bitData.Length)) |
594 |
> |
{ |
595 |
> |
mem.Write(0, bitData); |
596 |
> |
} |
597 |
> |
//if (ptrBytesWritten.ToUInt32() == 0) |
598 |
> |
// return false; |
599 |
|
ushort check = 0; |
600 |
|
ReadMemory(address, out check); |
601 |
|
if (check == value) return true; |
606 |
|
public virtual bool PatchMemory(uint address, short value) |
607 |
|
{ |
608 |
|
byte[] bitData = BitConverter.GetBytes(value); |
609 |
< |
UIntPtr ptrBytesWritten; |
610 |
< |
ProcessMemoryReaderApi.WriteProcessMemory(handle, (IntPtr)address, bitData, (uint)bitData.Length, out ptrBytesWritten); |
611 |
< |
if (ptrBytesWritten.ToUInt32() == 0) |
612 |
< |
return false; |
609 |
> |
//UIntPtr ptrBytesWritten; |
610 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, bitData.Length)) |
611 |
> |
{ |
612 |
> |
mem.Write(0, bitData); |
613 |
> |
} |
614 |
> |
//if (ptrBytesWritten.ToUInt32() == 0) |
615 |
> |
// return false; |
616 |
|
short check = 0; |
617 |
|
ReadMemory(address, out check); |
618 |
|
if (check == value) return true; |
623 |
|
public virtual bool PatchMemory(uint address, uint value) |
624 |
|
{ |
625 |
|
byte[] bitData = BitConverter.GetBytes(value); |
626 |
< |
UIntPtr ptrBytesWritten; |
627 |
< |
ProcessMemoryReaderApi.WriteProcessMemory(handle, (IntPtr)address, bitData, (uint)bitData.Length, out ptrBytesWritten); |
628 |
< |
if (ptrBytesWritten.ToUInt32() == 0) |
629 |
< |
return false; |
626 |
> |
//UIntPtr ptrBytesWritten; |
627 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, bitData.Length)) |
628 |
> |
{ |
629 |
> |
mem.Write(0, bitData); |
630 |
> |
} |
631 |
> |
//if (ptrBytesWritten.ToUInt32() == 0) |
632 |
> |
// return false; |
633 |
|
uint check = 0; |
634 |
|
ReadMemory(address, out check); |
635 |
|
if (check == value) return true; |
640 |
|
public virtual bool PatchMemory(uint address, int value) |
641 |
|
{ |
642 |
|
byte[] bitData = BitConverter.GetBytes(value); |
643 |
< |
UIntPtr ptrBytesWritten; |
644 |
< |
ProcessMemoryReaderApi.WriteProcessMemory(handle, (IntPtr)address, bitData, (uint)bitData.Length, out ptrBytesWritten); |
645 |
< |
if (ptrBytesWritten.ToUInt32() == 0) |
646 |
< |
return false; |
643 |
> |
//UIntPtr ptrBytesWritten; |
644 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, bitData.Length)) |
645 |
> |
{ |
646 |
> |
mem.Write(0, bitData); |
647 |
> |
} |
648 |
> |
//if (ptrBytesWritten.ToUInt32() == 0) |
649 |
> |
// return false; |
650 |
|
int check = 0; |
651 |
|
ReadMemory(address, out check); |
652 |
|
if (check == value) return true; |
657 |
|
public virtual bool PatchMemory(uint address, ulong value) |
658 |
|
{ |
659 |
|
byte[] bitData = BitConverter.GetBytes(value); |
660 |
< |
UIntPtr ptrBytesWritten; |
661 |
< |
ProcessMemoryReaderApi.WriteProcessMemory(handle, (IntPtr)address, bitData, (uint)bitData.Length, out ptrBytesWritten); |
662 |
< |
if (ptrBytesWritten.ToUInt32() == 0) |
663 |
< |
return false; |
660 |
> |
//UIntPtr ptrBytesWritten; |
661 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, bitData.Length)) |
662 |
> |
{ |
663 |
> |
mem.Write(0, bitData); |
664 |
> |
} |
665 |
> |
//if (ptrBytesWritten.ToUInt32() == 0) |
666 |
> |
// return false; |
667 |
|
ulong check = 0; |
668 |
|
ReadMemory(address, out check); |
669 |
|
if (check == value) return true; |
674 |
|
public virtual bool PatchMemory(uint address, long value) |
675 |
|
{ |
676 |
|
byte[] bitData = BitConverter.GetBytes(value); |
677 |
< |
UIntPtr ptrBytesWritten; |
678 |
< |
ProcessMemoryReaderApi.WriteProcessMemory(handle, (IntPtr)address, bitData, (uint)bitData.Length, out ptrBytesWritten); |
679 |
< |
if (ptrBytesWritten.ToUInt32() == 0) |
680 |
< |
return false; |
677 |
> |
//UIntPtr ptrBytesWritten; |
678 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, bitData.Length)) |
679 |
> |
{ |
680 |
> |
mem.Write(0, bitData); |
681 |
> |
} |
682 |
> |
//if (ptrBytesWritten.ToUInt32() == 0) |
683 |
> |
// return false; |
684 |
|
long check = 0; |
685 |
|
ReadMemory(address, out check); |
686 |
|
if (check == value) return true; |
696 |
|
value = 0; |
697 |
|
try |
698 |
|
{ |
699 |
< |
int bytesRead; |
699 |
> |
//int bytesRead; |
700 |
|
uint size = sizeof(byte); |
701 |
|
byte[] bitData = new byte[size]; |
702 |
< |
ProcessMemoryReader.ProcessMemoryReaderApi.ReadProcessMemory(handle, (IntPtr)address, bitData, size, out bytesRead); |
703 |
< |
if (bytesRead == 0) |
704 |
< |
return false; |
702 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, (int)size)) |
703 |
> |
{ |
704 |
> |
mem.Read(0, (int)size); |
705 |
> |
} |
706 |
> |
//if (bytesRead == 0) |
707 |
> |
// return false; |
708 |
|
value = bitData[0]; |
709 |
|
return true; |
710 |
|
} |
721 |
|
value = 0; |
722 |
|
try |
723 |
|
{ |
724 |
< |
int bytesRead; |
724 |
> |
//int bytesRead; |
725 |
|
uint size = sizeof(sbyte); |
726 |
|
byte[] bitData = new byte[size]; |
727 |
< |
ProcessMemoryReader.ProcessMemoryReaderApi.ReadProcessMemory(handle, (IntPtr)address, bitData, size, out bytesRead); |
728 |
< |
if (bytesRead == 0) |
729 |
< |
return false; |
727 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, (int)size)) |
728 |
> |
{ |
729 |
> |
mem.Read(0, (int)size); |
730 |
> |
} |
731 |
> |
//if (bytesRead == 0) |
732 |
> |
// return false; |
733 |
|
value = Convert.ToSByte(bitData[0]); |
734 |
|
return true; |
735 |
|
} |
746 |
|
value = 0; |
747 |
|
try |
748 |
|
{ |
749 |
< |
int bytesRead; |
749 |
> |
//int bytesRead; |
750 |
|
uint size = sizeof(ushort); |
751 |
|
byte[] bitData = new byte[size]; |
752 |
< |
ProcessMemoryReader.ProcessMemoryReaderApi.ReadProcessMemory(handle, (IntPtr)address, bitData, size, out bytesRead); |
753 |
< |
if (bytesRead == 0) |
754 |
< |
return false; |
752 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, (int)size)) |
753 |
> |
{ |
754 |
> |
mem.Read(0, (int)size); |
755 |
> |
} |
756 |
> |
//if (bytesRead == 0) |
757 |
> |
// return false; |
758 |
|
value = BitConverter.ToUInt16(bitData, 0); |
759 |
|
return true; |
760 |
|
} |
771 |
|
value = 0; |
772 |
|
try |
773 |
|
{ |
774 |
< |
int bytesRead; |
774 |
> |
//int bytesRead; |
775 |
|
uint size = sizeof(short); |
776 |
|
byte[] bitData = new byte[size]; |
777 |
< |
ProcessMemoryReader.ProcessMemoryReaderApi.ReadProcessMemory(handle, (IntPtr)address, bitData, size, out bytesRead); |
778 |
< |
if (bytesRead == 0) |
779 |
< |
return false; |
777 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, (int)size)) |
778 |
> |
{ |
779 |
> |
mem.Read(0, (int)size); |
780 |
> |
} |
781 |
> |
//if (bytesRead == 0) |
782 |
> |
// return false; |
783 |
|
value = BitConverter.ToInt16(bitData, 0); |
784 |
|
return true; |
785 |
|
} |
796 |
|
value = 0; |
797 |
|
try |
798 |
|
{ |
799 |
< |
int bytesRead; |
799 |
> |
//int bytesRead; |
800 |
|
uint size = sizeof(uint); |
801 |
|
byte[] bitData = new byte[size]; |
802 |
< |
ProcessMemoryReader.ProcessMemoryReaderApi.ReadProcessMemory(handle, (IntPtr)address, bitData, size, out bytesRead); |
803 |
< |
if (bytesRead == 0) |
804 |
< |
return false; |
802 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, (int)size)) |
803 |
> |
{ |
804 |
> |
mem.Read(0, (int)size); |
805 |
> |
} |
806 |
> |
//if (bytesRead == 0) |
807 |
> |
// return false; |
808 |
|
value = BitConverter.ToUInt32(bitData, 0); |
809 |
|
return true; |
810 |
|
} |
821 |
|
value = 0; |
822 |
|
try |
823 |
|
{ |
824 |
< |
int bytesRead; |
824 |
> |
//int bytesRead; |
825 |
|
uint size = sizeof(int); |
826 |
|
byte[] bitData = new byte[size]; |
827 |
< |
ProcessMemoryReader.ProcessMemoryReaderApi.ReadProcessMemory(handle, (IntPtr)address, bitData, size, out bytesRead); |
828 |
< |
if (bytesRead == 0) |
829 |
< |
return false; |
827 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, (int)size)) |
828 |
> |
{ |
829 |
> |
mem.Read(0, (int)size); |
830 |
> |
} |
831 |
> |
//if (bytesRead == 0) |
832 |
> |
// return false; |
833 |
|
value = BitConverter.ToInt32(bitData, 0); |
834 |
|
return true; |
835 |
|
} |
846 |
|
value = 0; |
847 |
|
try |
848 |
|
{ |
849 |
< |
int bytesRead; |
849 |
> |
//int bytesRead; |
850 |
|
uint size = sizeof(ulong); |
851 |
|
byte[] bitData = new byte[size]; |
852 |
< |
ProcessMemoryReader.ProcessMemoryReaderApi.ReadProcessMemory(handle, (IntPtr)address, bitData, size, out bytesRead); |
853 |
< |
if (bytesRead == 0) |
854 |
< |
return false; |
852 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, (int)size)) |
853 |
> |
{ |
854 |
> |
mem.Read(0, (int)size); |
855 |
> |
} |
856 |
> |
//if (bytesRead == 0) |
857 |
> |
// return false; |
858 |
|
value = BitConverter.ToUInt64(bitData, 0); |
859 |
|
return true; |
860 |
|
} |
871 |
|
value = 0; |
872 |
|
try |
873 |
|
{ |
874 |
< |
int bytesRead; |
874 |
> |
// int bytesRead; |
875 |
|
uint size = sizeof(long); |
876 |
|
byte[] bitData = new byte[size]; |
877 |
< |
ProcessMemoryReader.ProcessMemoryReaderApi.ReadProcessMemory(handle, (IntPtr)address, bitData, size, out bytesRead); |
878 |
< |
if (bytesRead == 0) |
879 |
< |
return false; |
877 |
> |
using (ProcessMemoryChunk mem = new ProcessMemoryChunk(m_ReadProcess, (IntPtr)address, (int)size)) |
878 |
> |
{ |
879 |
> |
mem.Read(0, (int)size); |
880 |
> |
} |
881 |
> |
//if (bytesRead == 0) |
882 |
> |
// return false; |
883 |
|
value = BitConverter.ToInt64(bitData, 0); |
884 |
|
return true; |
885 |
|
} |