剑侠情缘3(剑网3)安全函数ShieldFunctions

今天偶然间在CWDG上看到有人发了 我一看ui.pak里还真的有
虽然没有明确说哪些函数可以用 怎么用 不过倒是知道了被屏蔽的有多少
而且 这次可以看出 邮件、物品使用也进入了这个SF的范围内 常规的IO 方向控制 GM指令就不说了

下面是官方写的代码 具体有多少用 不知道 没时间研究
程序代码 程序代码

_ShieldWeak =
{
}
setmetatable(_ShieldWeak, {__mode = "v"})

_g_CurrentExcuteMacro = nil

_ShieldList =
{
    ["_G"] = true,
    ["_ShieldWeak"] = true,
    ["_ShieldList"] = true,
    ["setfenv"] = true,
    ["getfenv"] = true,
    ["io"] = true,
    ["os"] = true,
    ["Ini"] = true,
    ["Tab"] = true,
    ["dofile"] = true,
    ["loadfile"] = true,
    ["loadstring"] = true,
    ["dostring"] = true,
    ["load"] = true,
    ["require"] = true
    ["package"] = true,
    ["Camera_EnableControl"] = true,
    ["MoveForwardStart"] = true,
    ["MoveForwardStop"] = true,
    ["MoveBackwardStart"] = true,
    ["MoveBackwardStop"] = true,
    ["TurnLeftStart"] = true,
    ["TurnLeftStop"] = true,
    ["TurnRightStart"] = true,
    ["TurnRightStop"] = true,
    ["StrafeLeftStart"] = true,
    ["StrafeLeftStop"] = true,
    ["StrafeRightStart"] = true,
    ["StrafeRightStop"] = true,
    ["MoveUpStart"] = true,
    ["MoveUpStop"] = true,
    ["MoveDownStart"] = true,
    ["MoveDownStop"] = true,
    ["ShieldValue"] = true,
    ["ShieldTable"] = true,
    ["ShieldFunction"] = true,
    ["AutoMoveToTarget"] = true,
    ["AutoMoveToPoint"] = true,
    ["LoadScriptLib"] = true,
    ["LoadLoginScriptLib"] = true,
    ["LoadDefaultScriptLib"] = true,
    ["RemoteCallToServer"] = true,
    ["ActionBar_ButtonDown"] = true,
    ["ActionBar_ButtonUp"] = true,
    ["_g_CurrentExcuteMacro"] = true,
    ["GMMessage"] = true,
    ["GMCheck"] = true,
}

function ShieldValue(t, szKey)
    t[szKey] = true
end

function ShieldTable(t, szTable, tShield)
    t[szTable] = function(tOwner)
        local result = tOwner[szTable]
        if not result then
            return nil
        end
        
        if _ShieldWeak[result] then
            return _ShieldWeak[result]
        end
        
        local proxy = {}
        local mt =
        {
            __index = function(t, k)
                if tShield[k] then
                    if type(tShield[k]) == "function" then
                        return tShield[k](result)
                    end
                    return nil
                end
                return result[k]
            end;
            __newindex = function(t, k, v)
                if tShield[k] then
                    return
                end
                result[k] = v
            end;
        }
        
        setmetatable(proxy, mt);
        
        _ShieldWeak[result] = proxy
        return proxy
    end
end

function ShieldFunction(t, szFunc, tResult, tParam, bInUserAction, szOnceKey)
    t[szFunc] = function(tOwner)
        return function(...)
            if _g_CurrentExcuteMacro then
                if szOnceKey then
                    if _g_CurrentExcuteMacro.aOnce[szOnceKey] then
                        return nil
                    end
                    _g_CurrentExcuteMacro.aOnce[szOnceKey] = true
                end
            else
                if bInUserAction and not Station.IsInUserAction() then
                    return nil
                end            
            end
            
            if tParam then
                for k, v in pairs(tParam) do
                    local a = select(k, ...)
                    if v[a] then
                        if type(v[a]) == "function" then
                            return v[a](...)
                        end
                        return nil
                    end
                end
            end
                        
            if not tResult then
                return tOwner[szFunc](...)
            end
            
            local r = tOwner[szFunc](...)
            if not r then
                return nil
            end
            
            if _ShieldWeak[r] then
                return _ShieldWeak[r]
            end
            
            local proxy = {}
            local mt =
            {
                __index = function(t, k)
                    if tResult[k] then
                        if type(tResult[k]) == "function" then
                            return tResult[k](r)
                        end
                        return nil
                    end
                    return r[k]
                end;
                __newindex = function(t, k, v)
                    if tResult[k] then
                        return
                    end
                    r[k] = v
                end;
            }
            setmetatable(proxy, mt);
            
            _ShieldWeak[r] = proxy
            
            return proxy
        end
    end
end

local _WindowShild =
{
}

ShieldFunction(_WindowShild, "Lookup", _WindowShild)
ShieldFunction(_WindowShild, "GetParent", _WindowShild)
ShieldFunction(_WindowShild, "GetFirstChild", _WindowShild)
ShieldFunction(_WindowShild, "GetNext", _WindowShild)
ShieldFunction(_WindowShild, "GetPrev", _WindowShild)
ShieldFunction(_WindowShild, "AppendItemFromIni", _WindowShild)
ShieldFunction(_WindowShild, "RegisterEvent", nil, {[2] = {["ON_REMOTE_COMMAND"] = true}})

ShieldTable(_ShieldList, "this", _WindowShild)

local _StationShild =
{
    ["IsInUserAction"] = true,
}
ShieldFunction(_StationShild, "Lookup", _WindowShild)

ShieldTable(_ShieldList, "Station", _StationShild)

local _WndShild =
{
}

ShieldFunction(_WndShild, "OpenWindow", _WindowShild)

ShieldTable(_ShieldList, "Wnd", _WndShild)

ShieldFunction(_ShieldList, "RegisterEvent", nil, {[2] = {["ON_REMOTE_COMMAND"] = true}})

local _PlayerShild =
{
    ["CastSkill"] = true,
    ["UseItem"] = true,
}

ShieldFunction(_PlayerShild, "TradingConfirm", nil, nil, true, "Trading")

ShieldFunction(_ShieldList, "GetPlayer", _PlayerShild)
ShieldFunction(_ShieldList, "GetClientPlayer", _PlayerShild)

ShieldFunction(_ShieldList, "OnUseSkill", nil, nil, true, "UseSkillOrItem")
ShieldFunction(_ShieldList, "OnUseItem", nil, nil, true, "UseSkillOrItem")
ShieldFunction(_ShieldList, "ActionButtonDown", nil, nil, true, "UseSkillOrItem")
ShieldFunction(_ShieldList, "ActionButtonUp", nil, nil, true, "UseSkillOrItem")

ShieldFunction(_ShieldList, "BuyItem", nil, nil, true, "BuyItem")
ShieldFunction(_ShieldList, "SendMail", nil, nil, true, "SendMail")

local _ActionBarShild =
{
    ["OnUseActionBarObject"] = true,
    ["OnItemLButtonClick"] = true,
}

ShieldTable(_ShieldList, "ActionBar", _ActionBarShild)



文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: 剑网3 插件 安全函数 shieldfunctions
相关日志:
评论: 0 | 引用: 0 | 查看次数: 1143
发表评论
你没有权限发表评论!