数据区保持使用Hook,灯光亮度需要使用
This commit is contained in:
parent
59c5e07789
commit
0a6518311a
|
@ -17,6 +17,7 @@ public:
|
|||
uint Offset;
|
||||
uint Size;
|
||||
|
||||
DataStore::Handler Hook;
|
||||
IDataPort* Port;
|
||||
|
||||
Area();
|
||||
|
@ -77,10 +78,12 @@ bool DataStore::OnHook(uint offset, uint size, bool write)
|
|||
for(int i=0; i<Areas.Count(); i++)
|
||||
{
|
||||
auto ar = *(Area*)Areas[i];
|
||||
if(ar.Size == 0) break;
|
||||
if(ar.Size == 0) continue;
|
||||
|
||||
if(!ar.Contain(offset, size)) continue;
|
||||
|
||||
// 数据操作口只认可完整的当前区域
|
||||
if(ar.Port && ar.Contain(offset, size))
|
||||
if(ar.Port)
|
||||
{
|
||||
if(write)
|
||||
{
|
||||
|
@ -91,12 +94,26 @@ bool DataStore::OnHook(uint offset, uint size, bool write)
|
|||
if(ar.Port->Read(&Data[ar.Offset]) <= 0) return false;
|
||||
}
|
||||
}
|
||||
if(ar.Hook)
|
||||
{
|
||||
if(!ar.Hook(ar.Offset, ar.Size, write)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 注册某一块区域的读写钩子函数
|
||||
void DataStore::Register(uint offset, uint size, Handler hook)
|
||||
{
|
||||
auto ar = new Area();
|
||||
ar->Offset = offset;
|
||||
ar->Size = size;
|
||||
ar->Hook = hook;
|
||||
|
||||
Areas.Add(ar);
|
||||
}
|
||||
|
||||
void DataStore::Register(uint offset, IDataPort& port)
|
||||
{
|
||||
auto ar = new Area();
|
||||
|
@ -111,6 +128,7 @@ Area::Area()
|
|||
{
|
||||
Offset = 0;
|
||||
Size = 0;
|
||||
Hook = nullptr;
|
||||
}
|
||||
|
||||
bool Area::Contain(uint offset, uint size)
|
||||
|
|
|
@ -19,7 +19,9 @@ public:
|
|||
// 读取数据 offset 为虚拟地址
|
||||
int Read(uint offset, Buffer& bs);
|
||||
|
||||
typedef bool (*Handler)(uint offset, uint size, bool write);
|
||||
// 注册某一块区域的读写钩子函数
|
||||
void Register(uint offset, uint size, Handler hook);
|
||||
void Register(uint offset, IDataPort& port);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue