public string OnMemoryExecuteAny(LuaFunction luaf, string name = null, string scope = null) { try { if (DebuggableCore?.MemoryCallbacksAvailable() == true && DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable) { if (!HasScope(scope)) { LogScopeNotAvailable(scope); return(Guid.Empty.ToString()); } var nlf = new NamedLuaFunction(luaf, "OnMemoryExecuteAny", LogOutputCallback, CurrentFile, name); RegisteredFunctions.Add(nlf); DebuggableCore.MemoryCallbacks.Add(new MemoryCallback( ProcessScope(scope), MemoryCallbackType.Execute, "Lua Hook", nlf.MemCallback, null, null )); return(nlf.Guid.ToString()); } // fall through } catch (NotImplementedException) { // fall through } LogMemoryExecuteCallbacksNotImplemented(); return(Guid.Empty.ToString()); }
public string OnMemoryWrite(LuaFunction luaf, uint?address = null, string name = null) { try { if (DebuggableCore != null && DebuggableCore.MemoryCallbacksAvailable()) { if (N64CoreTypeDynarec()) { return(Guid.Empty.ToString()); } var nlf = new NamedLuaFunction(luaf, "OnMemoryWrite", LogOutputCallback, CurrentThread, name); _luaFunctions.Add(nlf); DebuggableCore.MemoryCallbacks.Add( new MemoryCallback(MemoryCallbackType.Write, "Lua Hook", nlf.Callback, address, null)); return(nlf.Guid.ToString()); } } catch (NotImplementedException) { LogMemoryCallbacksNotImplemented(); return(Guid.Empty.ToString()); } LogMemoryCallbacksNotImplemented(); return(Guid.Empty.ToString()); }
public string OnMemoryWrite(LuaFunction luaf, uint?address = null, string name = null, string scope = null) { try { if (DebuggableCore?.MemoryCallbacksAvailable() == true) { if (!HasScope(scope)) { LogScopeNotAvailable(scope); return(Guid.Empty.ToString()); } var nlf = _luaLibsImpl.CreateAndRegisterNamedFunction(luaf, "OnMemoryWrite", LogOutputCallback, CurrentFile, name); DebuggableCore.MemoryCallbacks.Add( new MemoryCallback(ProcessScope(scope), MemoryCallbackType.Write, "Lua Hook", nlf.MemCallback, address, null)); return(nlf.Guid.ToString()); } } catch (NotImplementedException) { LogMemoryCallbacksNotImplemented(); return(Guid.Empty.ToString()); } LogMemoryCallbacksNotImplemented(); return(Guid.Empty.ToString()); }
public string OnMemoryWrite(LuaFunction luaf, uint?address = null, string name = null, string domain = null) { try { if (DebuggableCore != null && DebuggableCore.MemoryCallbacksAvailable()) { var nlf = new NamedLuaFunction(luaf, "OnMemoryWrite", LogOutputCallback, CurrentFile, name); RegisteredFunctions.Add(nlf); if (string.IsNullOrWhiteSpace(domain)) { if (Domains != null && Domains.HasSystemBus) { domain = Domains.SystemBus.Name; } } DebuggableCore.MemoryCallbacks.Add( new MemoryCallback(domain, MemoryCallbackType.Write, "Lua Hook", nlf.MemCallback, address, null)); return(nlf.Guid.ToString()); } } catch (NotImplementedException) { LogMemoryCallbacksNotImplemented(); return(Guid.Empty.ToString()); } LogMemoryCallbacksNotImplemented(); return(Guid.Empty.ToString()); }
private string SetMemoryEvent(MemoryCallbackType type, string callback, uint address, uint bytes, string name, uint?checkAddress = null, uint checkValue = 0, string domain = "System Bus") { domain = NormalizeDomain(domain); try { if (DebuggableCore?.MemoryCallbacksAvailable() == true && (type != MemoryCallbackType.Execute || DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable)) { name = name ?? callback; uint mask = 0; for (var i = 0; i < bytes; i++) { mask |= (uint)(0xFF << (i * 8)); } if (!HasDomain(domain)) { throw new ApiError($"{Emulator.Attributes().CoreName} does not support memory callbacks on the domain {domain}"); } HttpClient client = new HttpClient(); DebuggableCore.MemoryCallbacks.Add(new MemoryCallback( domain, type, name, (uint address, uint value, uint flags) => { if (checkAddress != null && ReadUnsignedByte((int)checkAddress, domain) == checkValue) { try { client.GetAsync(callback).Result.ToString(); } catch { } } }, address, mask )); return(name); } // fall through } catch (NotImplementedException) { } if (type == MemoryCallbackType.Execute) { throw new ApiError($"{Emulator.Attributes().CoreName} does not support memory execute callbacks."); } throw new ApiError($"{Emulator.Attributes().CoreName} does not support memory callbacks."); }
private string SetMemoryEvent(MemoryCallbackType type, string callback, uint address, uint bytes, string name, int checkAddr = -1, uint checkValue = 0) { try { if ( DebuggableCore != null && DebuggableCore.MemoryCallbacksAvailable() && (type != MemoryCallbackType.Execute || DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable) ) { name = name ?? callback; uint mask = 0; for (var i = 0; i < bytes; i++) { mask |= (uint)(0xFF << (i * 8)); } HttpClient client = new HttpClient(); DebuggableCore.MemoryCallbacks.Add(new MemoryCallback(type, name, () => { if (checkAddr < 0 || ReadUnsignedByte(checkAddr) == checkValue) { try { client.GetAsync(callback).Result.ToString(); } catch { } } }, address, mask)); return(name); } } catch (NotImplementedException) { } if (type == MemoryCallbackType.Execute) { throw new ApiError($"{Emulator.Attributes().CoreName} does not support memory execute callbacks."); } throw new ApiError($"{Emulator.Attributes().CoreName} does not support memory callbacks."); }
public string OnMemoryExecute(LuaFunction luaf, uint address, string name = null, string domain = null) { try { if (DebuggableCore != null && DebuggableCore.MemoryCallbacksAvailable() && DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable) { if (N64CoreTypeDynarec()) { return(Guid.Empty.ToString()); } var nlf = new NamedLuaFunction(luaf, "OnMemoryExecute", LogOutputCallback, CurrentThread, name); _luaFunctions.Add(nlf); if (string.IsNullOrWhiteSpace(domain)) { if (Domains != null && Domains.HasSystemBus) { domain = Domains.SystemBus.Name; } } DebuggableCore.MemoryCallbacks.Add( new MemoryCallback(domain, MemoryCallbackType.Execute, "Lua Hook", nlf.Callback, address, null)); return(nlf.Guid.ToString()); } } catch (NotImplementedException) { LogMemoryExecuteCallbacksNotImplemented(); return(Guid.Empty.ToString()); } LogMemoryExecuteCallbacksNotImplemented(); return(Guid.Empty.ToString()); }
public LuaTable AvailableScopes() { return(DebuggableCore?.MemoryCallbacksAvailable() == true ? _th.ListToTable(DebuggableCore.MemoryCallbacks.AvailableScopes, indexFrom : 0) : _th.CreateTable()); }
public LuaTable AvailableScopes() { return(DebuggableCore?.MemoryCallbacksAvailable() == true ? DebuggableCore.MemoryCallbacks.AvailableScopes.ToLuaTable(Lua) : Lua.NewTable()); }