debug.getinfo returns nil

I’m trying to create an anti cheat using hooks and debug.getinfo.

Right now, with normal hooks, it the debug info returns fine, but when I tested it with cheats that have their own way of creating hooks without debug info, it errors out to this:



[ERROR] addons/anticheat/lua/autorun/client/cl_anticheat.lua:155: attempt to index field 'info' (a nil value)
  1. Hook - addons/anticheat/lua/autorun/client/cl_anticheat.lua:155
   2. func - addons/anticheat/lua/autorun/client/cl_anticheat.lua:338
    3. unknown - lua/includes/extensions/net.lua:32



I tried making it so if info is nil, it just makes it say N/A and continues to list other hooks, but my issue is when it does that, it replaces every hook’s info, not just the one hook’s.

Here is the code that I tried:



if (v.info != nil) then
    dview:AddLine(v.name, v.bhook, v.info.short_src, v.info.source, v.info.func, v.info.namewhat, v.info.what, v.info.linedefined, v.info.nparams)
else
    dview:AddLine(v.name, v.bhook, "N/A")
end


Is there something im doing incorrect? If so, please explain how I should fix it.

Sorry if im posting too many of these threads, it just seems that my other one’s don’t get attention even after I bump them.

Info isn’t a key in the table returned by debug.getinfo- it only returns these keys so v.info always equals nil

[editline]27th February 2016[/editline]

Unless I misunderstood what V was in your example

oh, my mistake.

I forgot to include this part in the OP:



	for k, v in pairs(hooks) do
		if (allhooks == false) then
                    if (v.info != nil) then
                          dview:AddLine(v.name, v.bhook, v.info.short_src, v.info.source, v.info.func, v.info.namewhat, v.info.what, v.info.linedefined, v.info.nparams)
                    else
                          dview:AddLine(v.name, v.bhook, "N/A")
                    end
		else
		     dview:AddLine(v.name, v.bhook, v.info.short_src, v.info.source, v.info.func, v.info.namewhat, v.info.what, v.info.linedefined, v.info.nparams)
		end
	end


hooks is basically just hook.GetTable() with a few added elements

the script works completely fine when it is just normal hook.Add() hooks, but when a cheat has it’s own way of creating hooks, it doesn’t give debug info, thus breaking my code

Alright, on the serverside file i tried this:



							local hooks = {}
							for k, v in pairs(hook.GetTable()) do
								for l, m in pairs(v) do	
									if (IsValid(debug.getinfo(m))) then
										table.insert(hooks, {name = l, info = debug.getinfo(m), bhook = k})
									else
										table.insert(hooks, {name = l, info = {}, bhook = k})
									end
								end
							end


but still, even for hooks that use to have debug info, it removes it.

Here is an example:



Hook Name: NotificationThink
Base Hook: Think
Source: 
Function: Not Available
Function Name: Not Available
Type: 
Line Defined: 
Number of Arguments: 


It use to say all the hook info, but now it says nothing.

I also changed the clientside code back to:



	for k, v in pairs(hooks) do
		if (allhooks == false) then
                          dview:AddLine(v.name, v.bhook, v.info.short_src, v.info.source, v.info.func, v.info.namewhat, v.info.what, v.info.linedefined, v.info.nparams)
		else
		     dview:AddLine(v.name, v.bhook, v.info.short_src, v.info.source, v.info.func, v.info.namewhat, v.info.what, v.info.linedefined, v.info.nparams)
		end
	end


bump, this is still happening. please help.