c++ - How to read variables values from Lua running process ( obtain process variable value )? -


I tried some efforts to run the Lua code, and its running code C / C ++ < / Code> is similar, but my app crashes with partitioning error.

e.g. Reaching the memory which I do not think:

So far I have found this. Simple process with Lua with the interpreter:

  a = {5} local Cnt1 = 0 local Cnt2 = 0 while correct Cnt2 = Cnt2 + 1 if (Cnt2 == 100000000) then Cnt2 = 0 Print ("ser .:" .. cnt1 .. "address:" ..tosting (a) .. "value:" ..a [1]) cnt1 = cnt1 + 1 end and  

Unlimited Loop is actually the process to wake up and keep the table address constant.

As you see, I print the address of "a", which I paste from the console to the C (code block) myself. After this I wrote another program, where I have hard-coded the pointer as a memory map:

  unsigned char * p = (unsigned char *) 0x78C070; Printf ("value:% u", * p); Return 0; Possible ways are 1) The way I can try is a file, but it is really slow (HDD)  

2) File on RAM disk - fast, but everyone has RAM- no disk.

Create a C-wrapper program and use the Lua C API to get the value Here's an example Given that your "A" should be retrieved. No error is handled, but hopefully you will get the idea.

  lua_state * l = sys_lua_L (); LuaL_loadfile (L, "your_lua_script.lua"); Lua_pikol (L, 0, 0, 0); Lua_getglobal (L, "A"); / / Lua variable retrieve a lua_rawgeti (L, -1, 1); // is assumed "A" is a table in the vine = lua_tointegerL, -1); Printf ("% d \ n", wal);  

Comments