-
Notifications
You must be signed in to change notification settings - Fork 4
/
MemoryViewByteProvider.cs
70 lines (49 loc) · 1.94 KB
/
MemoryViewByteProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using Be.Windows.Forms;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace PS4_Cheat_Engine {
public class MemoryViewByteProvider : IByteProvider {
private ByteCollection _bytes;
private bool _hasChanges;
public MemoryViewByteProvider(byte[] data) : this(new ByteCollection(data))
=> change_list = new List<int>();
public MemoryViewByteProvider(ByteCollection bytes)
=> this._bytes = bytes;
[field: CompilerGenerated, DebuggerBrowsable(0)]
public event EventHandler Changed;
[field: CompilerGenerated, DebuggerBrowsable(0)]
public event EventHandler LengthChanged;
public ByteCollection Bytes => this._bytes;
public List<int> change_list { get; set; }
public long Length => (long)this._bytes.Count;
public long Offset => 0L;
public void ApplyChanges() => this._hasChanges = false;
public void DeleteBytes(long index, long length) {
}
public bool HasChanges() => this._hasChanges;
public void InsertBytes(long index, byte[] bs) {
}
public byte ReadByte(long index) => this._bytes[(int)index];
public bool SupportsDeleteBytes() => false;
public bool SupportsInsertBytes() => false;
public bool SupportsWriteByte() => true;
public void WriteByte(long index, byte value) {
this._bytes[(int)index] = value;
this.change_list.Add((int)index);
this.OnChanged(EventArgs.Empty);
}
private void OnChanged(EventArgs e) {
this._hasChanges = true;
if (this.Changed != null) {
this.Changed(this, e);
}
}
private void OnLengthChanged(EventArgs e) {
if (this.LengthChanged != null) {
this.LengthChanged(this, e);
}
}
}
}