Пример #1
0
LuaModule::LuaModule():
  lua_interp_(NULL),
  lua_ok_(true),
  lua_restart_requested_(false)
{
  setLuaPath();
}
Пример #2
0
int set_pm3_libraries(lua_State *L)
{

    static const luaL_Reg libs[] = {
        {"SendCommand",                 l_SendCommand},
        {"WaitForResponseTimeout",      l_WaitForResponseTimeout},
        {"nonce2key",                   l_nonce2key},
        //{"PrintAndLog",                 l_PrintAndLog},
        {"foobar",                      l_foobar},
        {"ukbhit",                      l_ukbhit},
        {"clearCommandBuffer",          l_clearCommandBuffer},
        {"console",                     l_CmdConsole},
        {"iso15693_crc",                l_iso15693_crc},
        {"iso14443b_crc",				l_iso14443b_crc},
        {"aes128_decrypt",              l_aes128decrypt_cbc},
        {"aes128_decrypt_ecb",          l_aes128decrypt_ecb},
        {"aes128_encrypt",              l_aes128encrypt_cbc},
        {"aes128_encrypt_ecb",          l_aes128encrypt_ecb},
        {"crc16",                       l_crc16},
        {"crc64",                       l_crc64},
        {"sha1",						l_sha1},
        {"reveng_models",				l_reveng_models},
        {"reveng_runmodel",				l_reveng_RunModel},
        {NULL, NULL}
    };

    lua_pushglobaltable(L);
    // Core library is in this table. Contains '
    //this is 'pm3' table
    lua_newtable(L);

    //Put the function into the hash table.
    for (int i = 0; libs[i].name; i++) {
        lua_pushcfunction(L, libs[i].func);
        lua_setfield(L, -2, libs[i].name);//set the name, pop stack
    }
    //Name of 'core'
    lua_setfield(L, -2, "core");

    //-- remove the global environment table from the stack
    lua_pop(L, 1);

    //-- Last but not least, add to the LUA_PATH (package.path in lua)
    // so we can load libraries from the ./lualib/ - directory
    setLuaPath(L,"./lualibs/?.lua");

    return 1;
}