283 lines
9.4 KiB
C#
283 lines
9.4 KiB
C#
#if USE_UNI_LUA
|
|
using LuaAPI = UniLua.Lua;
|
|
using RealStatePtr = UniLua.ILuaState;
|
|
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
|
|
#else
|
|
using LuaAPI = XLua.LuaDLL.Lua;
|
|
using RealStatePtr = System.IntPtr;
|
|
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
|
|
#endif
|
|
|
|
using XLua;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace XLua.CSObjectWrap
|
|
{
|
|
using Utils = XLua.Utils;
|
|
public class BFResourcesProtectWrap
|
|
{
|
|
public static void __Register(RealStatePtr L)
|
|
{
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
System.Type type = typeof(BF.ResourcesProtect);
|
|
Utils.BeginObjectRegister(type, L, translator, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Utils.EndObjectRegister(type, L, translator, null, null,
|
|
null, null, null);
|
|
|
|
Utils.BeginClassRegister(type, L, __CreateInstance, 7, 0, 0);
|
|
Utils.RegisterFunc(L, Utils.CLS_IDX, "DoEncrypt", _m_DoEncrypt_xlua_st_);
|
|
Utils.RegisterFunc(L, Utils.CLS_IDX, "DoDecrypt", _m_DoDecrypt_xlua_st_);
|
|
Utils.RegisterFunc(L, Utils.CLS_IDX, "Read", _m_Read_xlua_st_);
|
|
Utils.RegisterFunc(L, Utils.CLS_IDX, "Write", _m_Write_xlua_st_);
|
|
Utils.RegisterFunc(L, Utils.CLS_IDX, "ExecuteEncrypt", _m_ExecuteEncrypt_xlua_st_);
|
|
Utils.RegisterFunc(L, Utils.CLS_IDX, "ExecuteDecrypt", _m_ExecuteDecrypt_xlua_st_);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Utils.EndClassRegister(type, L, translator);
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int __CreateInstance(RealStatePtr L)
|
|
{
|
|
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
if(LuaAPI.lua_gettop(L) == 1)
|
|
{
|
|
|
|
var gen_ret = new BF.ResourcesProtect();
|
|
translator.Push(L, gen_ret);
|
|
|
|
return 1;
|
|
}
|
|
|
|
}
|
|
catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return LuaAPI.luaL_error(L, "invalid arguments to BF.ResourcesProtect constructor!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_DoEncrypt_xlua_st_(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
|
|
int gen_param_count = LuaAPI.lua_gettop(L);
|
|
|
|
if(gen_param_count == 4&& (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)&& (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING)&& translator.Assignable<System.Func<string, bool>>(L, 4))
|
|
{
|
|
string _resPath = LuaAPI.lua_tostring(L, 1);
|
|
string _key = LuaAPI.lua_tostring(L, 2);
|
|
string _desPath = LuaAPI.lua_tostring(L, 3);
|
|
System.Func<string, bool> _filter = translator.GetDelegate<System.Func<string, bool>>(L, 4);
|
|
|
|
BF.ResourcesProtect.DoEncrypt( _resPath, _key, _desPath, _filter );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
if(gen_param_count == 3&& (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)&& (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING))
|
|
{
|
|
string _resPath = LuaAPI.lua_tostring(L, 1);
|
|
string _key = LuaAPI.lua_tostring(L, 2);
|
|
string _desPath = LuaAPI.lua_tostring(L, 3);
|
|
|
|
BF.ResourcesProtect.DoEncrypt( _resPath, _key, _desPath );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
return LuaAPI.luaL_error(L, "invalid arguments to BF.ResourcesProtect.DoEncrypt!");
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_DoDecrypt_xlua_st_(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
|
|
int gen_param_count = LuaAPI.lua_gettop(L);
|
|
|
|
if(gen_param_count == 4&& (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)&& (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING)&& translator.Assignable<System.Func<string, bool>>(L, 4))
|
|
{
|
|
string _resPath = LuaAPI.lua_tostring(L, 1);
|
|
string _key = LuaAPI.lua_tostring(L, 2);
|
|
string _desPath = LuaAPI.lua_tostring(L, 3);
|
|
System.Func<string, bool> _filter = translator.GetDelegate<System.Func<string, bool>>(L, 4);
|
|
|
|
BF.ResourcesProtect.DoDecrypt( _resPath, _key, _desPath, _filter );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
if(gen_param_count == 3&& (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)&& (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING))
|
|
{
|
|
string _resPath = LuaAPI.lua_tostring(L, 1);
|
|
string _key = LuaAPI.lua_tostring(L, 2);
|
|
string _desPath = LuaAPI.lua_tostring(L, 3);
|
|
|
|
BF.ResourcesProtect.DoDecrypt( _resPath, _key, _desPath );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
return LuaAPI.luaL_error(L, "invalid arguments to BF.ResourcesProtect.DoDecrypt!");
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_Read_xlua_st_(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
|
|
|
|
|
|
{
|
|
string _resPath = LuaAPI.lua_tostring(L, 1);
|
|
|
|
var gen_ret = BF.ResourcesProtect.Read( _resPath );
|
|
LuaAPI.lua_pushstring(L, gen_ret);
|
|
|
|
|
|
|
|
return 1;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_Write_xlua_st_(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
|
|
|
|
|
|
{
|
|
byte[] _buffer = LuaAPI.lua_tobytes(L, 1);
|
|
string _resPath = LuaAPI.lua_tostring(L, 2);
|
|
|
|
BF.ResourcesProtect.Write( _buffer, _resPath );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_ExecuteEncrypt_xlua_st_(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
|
|
|
|
|
|
{
|
|
byte[] _buffer = LuaAPI.lua_tobytes(L, 1);
|
|
string _key = LuaAPI.lua_tostring(L, 2);
|
|
|
|
var gen_ret = BF.ResourcesProtect.ExecuteEncrypt( _buffer, _key );
|
|
LuaAPI.lua_pushstring(L, gen_ret);
|
|
|
|
|
|
|
|
return 1;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_ExecuteDecrypt_xlua_st_(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
|
|
|
|
|
|
{
|
|
byte[] _buffer = LuaAPI.lua_tobytes(L, 1);
|
|
string _key = LuaAPI.lua_tostring(L, 2);
|
|
|
|
var gen_ret = BF.ResourcesProtect.ExecuteDecrypt( _buffer, _key );
|
|
LuaAPI.lua_pushstring(L, gen_ret);
|
|
|
|
|
|
|
|
return 1;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|