本博客注有“转”字样的为转载文章,其余为本人原创文章,转载请务必注明出处或保存此段。c++/lua/windows逆向交流群:69148232
每一个lua api 函数结尾都给出了这样的说明例如:
[-0, +1, –]
这是什么意思呢。
方括号里面有三个字段我们称为[-o, +p, x]
第一个字段o表示调用函数后会从栈中弹出多少个元素
第二个字段p表示调用函数后会压入多少元素到栈中
如果o或p这两个字段的格式是x|y类型表示这调用这个函数会压入(弹出)栈的个数x或者y个。他是根据不同情况的。
如果o或p中带有?表示我不知道将会压入(弹出)多少个元素,要视具体参数而定。
第三个字段x表示这个函数是否会抛出异常。“-”代表些函数从来不会抛出异常。“m”表示这个函数会抛出内存溢出异常或错误执行__gc函数。'e'代表这个函数有可能抛出异常。‘v’表示这个函数会抛出一个错误。
例如:
void lua_settable (lua_State *L, int index); [-2, +0, e]
[-2, +0, e] 有球settable会弹出2个元素压入0个元素,这个函数会抛出错误。
Here we list all functions and types from the C API in alphabetical order. Each function has an indicator like this:[-o, +p, x]
The first field, o
, is how many elements the function pops from the stack. The second field, p
, is how many elements the function pushes onto the stack. (Any function always pushes its results after popping its arguments.) A field in the form x|y
means the function can push (or pop) x
or y
elements, depending on the situation; an interrogation mark '?
' means that we cannot know how many elements the function pops/pushes by looking only at its arguments (e.g., they may depend on what is on the stack). The third field, x
, tells whether the function may raise errors: '-
' means the function never raises any error; 'm
' means the function may raise out-of-memory errors and errors running a __gc
metamethod; 'e
' means the function may raise any errors (it can run arbitrary Lua code, either directly or through metamethods); 'v
' means the function may raise an error on purpose.