Skip to content

Commit

Permalink
add callback for when the structure list changes (including the struc…
Browse files Browse the repository at this point in the history
…tname)
  • Loading branch information
cheat-engine committed Jun 9, 2022
1 parent 2837ad4 commit 69123a9
Show file tree
Hide file tree
Showing 4 changed files with 258 additions and 674 deletions.
48 changes: 48 additions & 0 deletions Cheat Engine/LuaHandler.pas
Original file line number Diff line number Diff line change
Expand Up @@ -9840,6 +9840,48 @@ function lua_unregisterStructureNameLookup(L: PLua_State): integer; cdecl;
unregisterStructureNameLookup(lua_tointeger(L, 1));
end;

//
function lua_registerGlobalStructureListUpdateNotification(L: PLua_State): integer; cdecl;
var
f: integer;
routine: string;
lc: tluacaller;
begin
result:=0;

if lua_gettop(L)=1 then
begin
if lua_isfunction(L, 1) then
begin
lua_pushvalue(L, 1);
f:=luaL_ref(L,LUA_REGISTRYINDEX);

lc:=TLuaCaller.create;
lc.luaroutineIndex:=f;
end
else
if lua_isstring(L,1) then
begin
routine:=lua_tostring(L,1);
lc:=TLuaCaller.create;
lc.luaroutine:=routine;
end
else exit;

lua_pushinteger(L, registerGlobalStructureListUpdateNotification(lc.NotifyEvent));
result:=1;
end;
end;

function lua_unregisterGlobalStructureListUpdateNotification(L: PLua_State): integer; cdecl;
begin
result:=0;
if lua_gettop(L)>0 then
unregisterGlobalStructureListUpdateNotification(lua_tointeger(L, 1));
end;

//

function lua_registerAssembler(L: PLua_State): integer; cdecl;
var
f: integer;
Expand Down Expand Up @@ -15988,6 +16030,12 @@ procedure InitializeLua;
lua_register(L, 'registerGlobalDisassembleOverride', lua_registerGlobalDisassembleOverride);
lua_register(L, 'unregisterGlobalDisassembleOverride', lua_unregisterGlobalDisassembleOverride);



lua_register(L, 'registerGlobalStructureListUpdateNotification', lua_registerGlobalStructureListUpdateNotification);
lua_register(L, 'unregisterGlobalStructureListUpdateNotification', lua_unregisterGlobalStructureListUpdateNotification);


lua_register(L, 'registerStructureDissectOverride', lua_registerStructureDissectOverride);
lua_register(L, 'unregisterStructureDissectOverride', lua_unregisterStructureDissectOverride);

Expand Down
Loading

0 comments on commit 69123a9

Please sign in to comment.