immunio 1.1.2 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immunio/version.rb +1 -1
- data/lua-hooks/Makefile +56 -109
- data/lua-hooks/ext/all.c +3 -14
- data/lua-hooks/ext/libinjection/module.mk +5 -0
- data/lua-hooks/ext/lpeg/module.mk +6 -0
- data/lua-hooks/ext/lua-cmsgpack/module.mk +2 -0
- data/lua-hooks/ext/lua-snapshot/module.mk +2 -0
- data/lua-hooks/ext/luajit/COPYRIGHT +1 -1
- data/lua-hooks/ext/luajit/Makefile +2 -2
- data/lua-hooks/ext/luajit/README +2 -2
- data/lua-hooks/ext/luajit/doc/bluequad-print.css +1 -1
- data/lua-hooks/ext/luajit/doc/bluequad.css +1 -1
- data/lua-hooks/ext/luajit/doc/changes.html +15 -2
- data/lua-hooks/ext/luajit/doc/contact.html +3 -3
- data/lua-hooks/ext/luajit/doc/ext_c_api.html +2 -2
- data/lua-hooks/ext/luajit/doc/ext_ffi.html +2 -2
- data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +2 -2
- data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +4 -2
- data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +2 -2
- data/lua-hooks/ext/luajit/doc/ext_jit.html +2 -2
- data/lua-hooks/ext/luajit/doc/ext_profiler.html +2 -2
- data/lua-hooks/ext/luajit/doc/extensions.html +9 -2
- data/lua-hooks/ext/luajit/doc/faq.html +2 -2
- data/lua-hooks/ext/luajit/doc/install.html +22 -18
- data/lua-hooks/ext/luajit/doc/luajit.html +3 -3
- data/lua-hooks/ext/luajit/doc/running.html +2 -2
- data/lua-hooks/ext/luajit/doc/status.html +2 -2
- data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +4 -4
- data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +4 -4
- data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +4 -4
- data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +4 -4
- data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +3 -3
- data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +1 -1
- data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +34 -7
- data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +427 -102
- data/lua-hooks/ext/luajit/dynasm/dynasm.lua +5 -5
- data/lua-hooks/ext/luajit/etc/luajit.1 +1 -1
- data/lua-hooks/ext/luajit/etc/luajit.pc +1 -1
- data/lua-hooks/ext/luajit/src/Makefile +36 -21
- data/lua-hooks/ext/luajit/src/Makefile.dep +3 -1
- data/lua-hooks/ext/luajit/src/host/buildvm.c +1 -1
- data/lua-hooks/ext/luajit/src/host/buildvm.h +1 -1
- data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +10 -1
- data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +1 -1
- data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +1 -1
- data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +1 -1
- data/lua-hooks/ext/luajit/src/host/genlibbc.lua +1 -1
- data/lua-hooks/ext/luajit/src/host/genminilua.lua +1 -1
- data/lua-hooks/ext/luajit/src/jit/bc.lua +1 -1
- data/lua-hooks/ext/luajit/src/jit/bcsave.lua +2 -2
- data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +1 -1
- data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +1 -1
- data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +1 -1
- data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +1 -1
- data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +1 -1
- data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +163 -73
- data/lua-hooks/ext/luajit/src/jit/dump.lua +2 -1
- data/lua-hooks/ext/luajit/src/jit/p.lua +1 -1
- data/lua-hooks/ext/luajit/src/jit/v.lua +1 -1
- data/lua-hooks/ext/luajit/src/jit/zone.lua +1 -1
- data/lua-hooks/ext/luajit/src/lib_aux.c +1 -1
- data/lua-hooks/ext/luajit/src/lib_base.c +4 -5
- data/lua-hooks/ext/luajit/src/lib_bit.c +1 -1
- data/lua-hooks/ext/luajit/src/lib_debug.c +1 -1
- data/lua-hooks/ext/luajit/src/lib_ffi.c +2 -5
- data/lua-hooks/ext/luajit/src/lib_init.c +1 -1
- data/lua-hooks/ext/luajit/src/lib_io.c +2 -3
- data/lua-hooks/ext/luajit/src/lib_jit.c +1 -1
- data/lua-hooks/ext/luajit/src/lib_math.c +1 -1
- data/lua-hooks/ext/luajit/src/lib_os.c +2 -2
- data/lua-hooks/ext/luajit/src/lib_package.c +1 -1
- data/lua-hooks/ext/luajit/src/lib_string.c +1 -1
- data/lua-hooks/ext/luajit/src/lib_table.c +1 -1
- data/lua-hooks/ext/luajit/src/lj.supp +15 -0
- data/lua-hooks/ext/luajit/src/lj_alloc.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_api.c +4 -1
- data/lua-hooks/ext/luajit/src/lj_arch.h +33 -7
- data/lua-hooks/ext/luajit/src/lj_asm.c +12 -5
- data/lua-hooks/ext/luajit/src/lj_asm.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_asm_arm.h +3 -13
- data/lua-hooks/ext/luajit/src/lj_asm_mips.h +337 -71
- data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +2 -2
- data/lua-hooks/ext/luajit/src/lj_asm_x86.h +2 -2
- data/lua-hooks/ext/luajit/src/lj_bc.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_bc.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_bcdump.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_bcread.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_bcwrite.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_buf.c +2 -4
- data/lua-hooks/ext/luajit/src/lj_buf.h +1 -3
- data/lua-hooks/ext/luajit/src/lj_carith.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_carith.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_ccall.c +37 -14
- data/lua-hooks/ext/luajit/src/lj_ccall.h +3 -3
- data/lua-hooks/ext/luajit/src/lj_ccallback.c +16 -7
- data/lua-hooks/ext/luajit/src/lj_ccallback.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_cconv.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_cconv.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_cdata.c +10 -1
- data/lua-hooks/ext/luajit/src/lj_cdata.h +3 -1
- data/lua-hooks/ext/luajit/src/lj_clib.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_clib.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_cparse.c +27 -6
- data/lua-hooks/ext/luajit/src/lj_cparse.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_crecord.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_crecord.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_ctype.c +10 -8
- data/lua-hooks/ext/luajit/src/lj_ctype.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_debug.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_debug.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_def.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_dispatch.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_dispatch.h +21 -4
- data/lua-hooks/ext/luajit/src/lj_emit_arm.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_emit_mips.h +7 -5
- data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_emit_x86.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_err.c +69 -31
- data/lua-hooks/ext/luajit/src/lj_err.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_errmsg.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_ff.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_ffrecord.c +10 -40
- data/lua-hooks/ext/luajit/src/lj_ffrecord.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_frame.h +12 -1
- data/lua-hooks/ext/luajit/src/lj_func.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_func.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_gc.c +2 -2
- data/lua-hooks/ext/luajit/src/lj_gc.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_gdbjit.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_gdbjit.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_ir.c +31 -15
- data/lua-hooks/ext/luajit/src/lj_ir.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_ircall.h +29 -1
- data/lua-hooks/ext/luajit/src/lj_iropt.h +2 -1
- data/lua-hooks/ext/luajit/src/lj_jit.h +2 -1
- data/lua-hooks/ext/luajit/src/lj_lex.c +28 -1
- data/lua-hooks/ext/luajit/src/lj_lex.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_lib.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_lib.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_load.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_mcode.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_mcode.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_meta.c +8 -8
- data/lua-hooks/ext/luajit/src/lj_meta.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_obj.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_obj.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_opt_dce.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_opt_fold.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_opt_loop.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_opt_mem.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_opt_sink.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_opt_split.c +10 -5
- data/lua-hooks/ext/luajit/src/lj_parse.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_parse.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_profile.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_profile.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_record.c +13 -5
- data/lua-hooks/ext/luajit/src/lj_record.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_snap.c +20 -23
- data/lua-hooks/ext/luajit/src/lj_snap.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_state.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_state.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_str.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_str.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_strfmt.c +12 -98
- data/lua-hooks/ext/luajit/src/lj_strfmt.h +4 -4
- data/lua-hooks/ext/luajit/src/lj_strfmt_num.c +591 -0
- data/lua-hooks/ext/luajit/src/lj_strscan.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_strscan.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_tab.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_tab.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_target.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_target_arm.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_target_arm64.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_target_mips.h +30 -2
- data/lua-hooks/ext/luajit/src/lj_target_ppc.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_target_x86.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_trace.c +7 -2
- data/lua-hooks/ext/luajit/src/lj_trace.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_traceerr.h +1 -3
- data/lua-hooks/ext/luajit/src/lj_udata.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_udata.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_vm.h +5 -3
- data/lua-hooks/ext/luajit/src/lj_vmevent.c +1 -1
- data/lua-hooks/ext/luajit/src/lj_vmevent.h +1 -1
- data/lua-hooks/ext/luajit/src/lj_vmmath.c +15 -15
- data/lua-hooks/ext/luajit/src/ljamalg.c +2 -1
- data/lua-hooks/ext/luajit/src/lua.h +1 -0
- data/lua-hooks/ext/luajit/src/luaconf.h +2 -2
- data/lua-hooks/ext/luajit/src/luajit.c +1 -1
- data/lua-hooks/ext/luajit/src/luajit.h +4 -4
- data/lua-hooks/ext/luajit/src/lualib.h +1 -1
- data/lua-hooks/ext/luajit/src/msvcbuild.bat +1 -1
- data/lua-hooks/ext/luajit/src/ps4build.bat +26 -6
- data/lua-hooks/ext/luajit/src/vm_arm.dasc +17 -9
- data/lua-hooks/ext/luajit/src/vm_arm64.dasc +1 -1
- data/lua-hooks/ext/luajit/src/vm_mips.dasc +1562 -656
- data/lua-hooks/ext/luajit/src/vm_ppc.dasc +3 -7
- data/lua-hooks/ext/luajit/src/vm_x64.dasc +10 -2
- data/lua-hooks/ext/luajit/src/vm_x86.dasc +5 -8
- data/lua-hooks/ext/luautf8/module.mk +2 -0
- data/lua-hooks/ext/module.mk +15 -0
- data/lua-hooks/ext/modules.h +17 -0
- data/lua-hooks/ext/perf/luacpu.c +1 -1
- data/lua-hooks/ext/perf/lualoadavg.c +1 -1
- data/lua-hooks/ext/perf/luameminfo.c +1 -1
- data/lua-hooks/ext/perf/luaoslib.c +124 -2
- data/lua-hooks/ext/perf/module.mk +5 -0
- data/lua-hooks/ext/sha1/luasha1.c +4 -2
- data/lua-hooks/ext/sha1/module.mk +5 -0
- data/lua-hooks/ext/sha2/luasha256.c +4 -2
- data/lua-hooks/ext/sha2/module.mk +5 -0
- data/lua-hooks/ext/sysutils/lua_utils.c +56 -0
- data/lua-hooks/ext/sysutils/module.mk +2 -0
- data/lua-hooks/lib/boot.lua +2 -1
- data/lua-hooks/lib/hooks/module.mk +31 -0
- data/lua-hooks/lib/hooks/xss/module.mk +4 -0
- data/lua-hooks/lib/lexers/module.mk +10 -0
- data/lua-hooks/lib/module.mk +38 -0
- data/lua-hooks/lib/schema/module.mk +3 -0
- data/lua-hooks/options.mk +59 -0
- metadata +21 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
|// Low-level VM code for PowerPC 32 bit or 32on64 bit mode.
|
2
2
|
|// Bytecode interpreter, fast functions and helper functions.
|
3
|
-
|// Copyright (C) 2005-
|
3
|
+
|// Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
|
4
4
|
|
|
5
5
|
|.arch ppc
|
6
6
|
|.section code_op, code_sub
|
@@ -2525,7 +2525,7 @@ static void build_subroutines(BuildCtx *ctx)
|
|
2525
2525
|
|.if JIT
|
2526
2526
|
| // RA = resultptr, RB = meta base
|
2527
2527
|
| lwz INS, -4(PC)
|
2528
|
-
| lwz
|
2528
|
+
| lwz TRACE:TMP2, -20(RB) // Save previous trace.
|
2529
2529
|
| addic. TMP1, MULTRES, -8
|
2530
2530
|
| decode_RA8 RC, INS // Call base.
|
2531
2531
|
| beq >2
|
@@ -2540,15 +2540,11 @@ static void build_subroutines(BuildCtx *ctx)
|
|
2540
2540
|
| decode_RA8 RA, INS
|
2541
2541
|
| decode_RB8 RB, INS
|
2542
2542
|
| add RA, RA, RB
|
2543
|
-
| lwz TMP1, DISPATCH_J(trace)(DISPATCH)
|
2544
2543
|
|3:
|
2545
2544
|
| cmplw RA, RC
|
2546
2545
|
| bgt >9 // More results wanted?
|
2547
2546
|
|
|
2548
|
-
|
|
2549
|
-
| lwzx TRACE:TMP2, TMP1, TMP2
|
2550
|
-
| cmpwi TRACE:TMP2, 0
|
2551
|
-
| beq ->cont_nop
|
2547
|
+
| lhz TMP3, TRACE:TMP2->traceno
|
2552
2548
|
| lhz RD, TRACE:TMP2->link
|
2553
2549
|
| cmpw RD, TMP3
|
2554
2550
|
| cmpwi cr1, RD, 0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|// Low-level VM code for x64 CPUs in LJ_GC64 mode.
|
2
2
|
|// Bytecode interpreter, fast functions and helper functions.
|
3
|
-
|// Copyright (C) 2005-
|
3
|
+
|// Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
|
4
4
|
|
|
5
5
|
|.arch x64
|
6
6
|
|.section code_op, code_sub
|
@@ -531,7 +531,7 @@ static void build_subroutines(BuildCtx *ctx)
|
|
531
531
|
| jmp >2
|
532
532
|
|
|
533
533
|
|->vm_growstack_v: // Grow stack for vararg Lua function.
|
534
|
-
| sub RD,
|
534
|
+
| sub RD, 16 // LJ_FR2
|
535
535
|
| jmp >1
|
536
536
|
|
|
537
537
|
|->vm_growstack_f: // Grow stack for fixarg Lua function.
|
@@ -1804,7 +1804,11 @@ static void build_subroutines(BuildCtx *ctx)
|
|
1804
1804
|
| jmp ->fff_res1
|
1805
1805
|
|
|
1806
1806
|
|.ffunc_n math_frexp
|
1807
|
+
|.if X64WIN
|
1808
|
+
| lea CARG2, TMP1
|
1809
|
+
|.else
|
1807
1810
|
| lea CARG1, TMP1
|
1811
|
+
|.endif
|
1808
1812
|
| mov RB, BASE
|
1809
1813
|
| call extern frexp
|
1810
1814
|
| mov BASE, RB
|
@@ -1822,7 +1826,11 @@ static void build_subroutines(BuildCtx *ctx)
|
|
1822
1826
|
| jmp ->fff_res
|
1823
1827
|
|
|
1824
1828
|
|.ffunc_n math_modf
|
1829
|
+
|.if X64WIN
|
1830
|
+
| lea CARG2, [BASE-16]
|
1831
|
+
|.else
|
1825
1832
|
| lea CARG1, [BASE-16]
|
1833
|
+
|.endif
|
1826
1834
|
| mov PC, [BASE-8]
|
1827
1835
|
| mov RB, BASE
|
1828
1836
|
| call extern modf
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|// Low-level VM code for x86 CPUs.
|
2
2
|
|// Bytecode interpreter, fast functions and helper functions.
|
3
|
-
|// Copyright (C) 2005-
|
3
|
+
|// Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
|
4
4
|
|
|
5
5
|
|.if P64
|
6
6
|
|.arch x64
|
@@ -2667,8 +2667,8 @@ static void build_subroutines(BuildCtx *ctx)
|
|
2667
2667
|
|->cont_stitch: // Trace stitching.
|
2668
2668
|
|.if JIT
|
2669
2669
|
| // BASE = base, RC = result, RB = mbase
|
2670
|
-
| mov RA, [RB-24]
|
2671
|
-
| mov TMP1, RA
|
2670
|
+
| mov TRACE:RA, [RB-24] // Save previous trace.
|
2671
|
+
| mov TMP1, TRACE:RA
|
2672
2672
|
| mov TMP3, DISPATCH // Need one more register.
|
2673
2673
|
| mov DISPATCH, MULTRES
|
2674
2674
|
| movzx RA, PC_RA
|
@@ -2699,11 +2699,8 @@ static void build_subroutines(BuildCtx *ctx)
|
|
2699
2699
|
| ja >9 // More results wanted?
|
2700
2700
|
|
|
2701
2701
|
| mov DISPATCH, TMP3
|
2702
|
-
| mov
|
2703
|
-
|
|
2704
|
-
| mov TRACE:RD, [RA+RB*4]
|
2705
|
-
| test TRACE:RD, TRACE:RD
|
2706
|
-
| jz ->cont_nop
|
2702
|
+
| mov TRACE:RD, TMP1 // Get previous trace.
|
2703
|
+
| movzx RB, word TRACE:RD->traceno
|
2707
2704
|
| movzx RD, word TRACE:RD->link
|
2708
2705
|
| cmp RD, RB
|
2709
2706
|
| je ->cont_nop // Blacklisted.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
// Lists the registration functions for all the modules
|
2
|
+
|
3
|
+
#include "lua.h"
|
4
|
+
|
5
|
+
LUALIB_API int luaopen_libinjection(lua_State *L);
|
6
|
+
LUALIB_API int luaopen_utf8(lua_State *L);
|
7
|
+
LUALIB_API int luaopen_lpeg (lua_State *L);
|
8
|
+
LUALIB_API int luaopen_cmsgpack(lua_State *L);
|
9
|
+
LUALIB_API int luaopen_snapshot(lua_State *L);
|
10
|
+
LUALIB_API int luaopen_sha1(lua_State *L);
|
11
|
+
LUALIB_API int luaopen_sha256(lua_State *L);
|
12
|
+
LUALIB_API int luaopen_cpuload(lua_State *L);
|
13
|
+
LUALIB_API int luaopen_loadavg(lua_State* L);
|
14
|
+
LUALIB_API int luaopen_meminfo(lua_State *L);
|
15
|
+
LUALIB_API int luaopen_luaos(lua_State *L);
|
16
|
+
LUALIB_API int luaopen_sysutils(lua_State *L);
|
17
|
+
|
data/lua-hooks/ext/perf/luacpu.c
CHANGED
@@ -1,8 +1,41 @@
|
|
1
1
|
#include <time.h>
|
2
|
+
#include <string.h>
|
2
3
|
|
3
4
|
#define lib_os_c
|
4
5
|
#define LUA_LIB
|
5
6
|
|
7
|
+
/*
|
8
|
+
** list of valid conversion specifiers for the 'strftime' function
|
9
|
+
*/
|
10
|
+
#if !defined(LUA_STRFTIMEOPTIONS)
|
11
|
+
|
12
|
+
#if !defined(LUA_USE_POSIX)
|
13
|
+
#define LUA_STRFTIMEOPTIONS { "aAbBcdHIjmMpSUwWxXyYz%", "" }
|
14
|
+
#else
|
15
|
+
#define LUA_STRFTIMEOPTIONS \
|
16
|
+
{ "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%", "" \
|
17
|
+
"", "E", "cCxXyY", \
|
18
|
+
"O", "deHImMSuUVwWy" }
|
19
|
+
#endif
|
20
|
+
|
21
|
+
#endif
|
22
|
+
|
23
|
+
/*
|
24
|
+
** By default, Lua uses gmtime/localtime, except when POSIX is available,
|
25
|
+
** where it uses gmtime_r/localtime_r
|
26
|
+
*/
|
27
|
+
#if defined(LUA_USE_GMTIME_R)
|
28
|
+
|
29
|
+
#define l_gmtime(t,r) gmtime_r(t,r)
|
30
|
+
#define l_localtime(t,r) localtime_r(t,r)
|
31
|
+
|
32
|
+
#elif !defined(l_gmtime)
|
33
|
+
|
34
|
+
#define l_gmtime(t,r) ((void)r, gmtime(t))
|
35
|
+
#define l_localtime(t,r) ((void)r, localtime(t))
|
36
|
+
|
37
|
+
#endif
|
38
|
+
|
6
39
|
#include "lua.h"
|
7
40
|
#include "lauxlib.h"
|
8
41
|
#include "lj_err.h"
|
@@ -13,6 +46,26 @@ static int os_clock(lua_State *L) {
|
|
13
46
|
return 1;
|
14
47
|
}
|
15
48
|
|
49
|
+
/*
|
50
|
+
** {======================================================
|
51
|
+
** Time/Date operations
|
52
|
+
** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S,
|
53
|
+
** wday=%w+1, yday=%j, isdst=? }
|
54
|
+
** =======================================================
|
55
|
+
*/
|
56
|
+
|
57
|
+
static void setfield (lua_State *L, const char *key, int value) {
|
58
|
+
lua_pushinteger(L, value);
|
59
|
+
lua_setfield(L, -2, key);
|
60
|
+
}
|
61
|
+
|
62
|
+
static void setboolfield (lua_State *L, const char *key, int value) {
|
63
|
+
if (value < 0) /* undefined? */
|
64
|
+
return; /* does not set field */
|
65
|
+
lua_pushboolean(L, value);
|
66
|
+
lua_setfield(L, -2, key);
|
67
|
+
}
|
68
|
+
|
16
69
|
static int getboolfield(lua_State *L, const char *key) {
|
17
70
|
int res;
|
18
71
|
lua_getfield(L, -1, key);
|
@@ -35,6 +88,74 @@ static int getfield(lua_State *L, const char *key, int d) {
|
|
35
88
|
return res;
|
36
89
|
}
|
37
90
|
|
91
|
+
static const char *checkoption (lua_State *L, const char *conv, char *buff) {
|
92
|
+
static const char *const options[] = LUA_STRFTIMEOPTIONS;
|
93
|
+
unsigned int i;
|
94
|
+
for (i = 0; i < sizeof(options)/sizeof(options[0]); i += 2) {
|
95
|
+
if (*conv != '\0' && strchr(options[i], *conv) != NULL) {
|
96
|
+
buff[1] = *conv;
|
97
|
+
if (*options[i + 1] == '\0') { /* one-char conversion specifier? */
|
98
|
+
buff[2] = '\0'; /* end buffer */
|
99
|
+
return conv + 1;
|
100
|
+
}
|
101
|
+
else if (*(conv + 1) != '\0' &&
|
102
|
+
strchr(options[i + 1], *(conv + 1)) != NULL) {
|
103
|
+
buff[2] = *(conv + 1); /* valid two-char conversion specifier */
|
104
|
+
buff[3] = '\0'; /* end buffer */
|
105
|
+
return conv + 2;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
luaL_argerror(L, 1,
|
110
|
+
lua_pushfstring(L, "invalid conversion specifier '%%%s'", conv));
|
111
|
+
return conv; /* to avoid warnings */
|
112
|
+
}
|
113
|
+
|
114
|
+
static int os_date (lua_State *L) {
|
115
|
+
const char *s = luaL_optstring(L, 1, "%c");
|
116
|
+
time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL));
|
117
|
+
struct tm tmr, *stm;
|
118
|
+
if (*s == '!') { /* UTC? */
|
119
|
+
stm = l_gmtime(&t, &tmr);
|
120
|
+
s++; /* skip `!' */
|
121
|
+
}
|
122
|
+
else
|
123
|
+
stm = l_localtime(&t, &tmr);
|
124
|
+
if (stm == NULL) /* invalid date? */
|
125
|
+
lua_pushnil(L);
|
126
|
+
else if (strcmp(s, "*t") == 0) {
|
127
|
+
lua_createtable(L, 0, 9); /* 9 = number of fields */
|
128
|
+
setfield(L, "sec", stm->tm_sec);
|
129
|
+
setfield(L, "min", stm->tm_min);
|
130
|
+
setfield(L, "hour", stm->tm_hour);
|
131
|
+
setfield(L, "day", stm->tm_mday);
|
132
|
+
setfield(L, "month", stm->tm_mon+1);
|
133
|
+
setfield(L, "year", stm->tm_year+1900);
|
134
|
+
setfield(L, "wday", stm->tm_wday+1);
|
135
|
+
setfield(L, "yday", stm->tm_yday+1);
|
136
|
+
setboolfield(L, "isdst", stm->tm_isdst);
|
137
|
+
}
|
138
|
+
else {
|
139
|
+
char cc[4];
|
140
|
+
luaL_Buffer b;
|
141
|
+
cc[0] = '%';
|
142
|
+
luaL_buffinit(L, &b);
|
143
|
+
while (*s) {
|
144
|
+
if (*s != '%') /* no conversion specifier? */
|
145
|
+
luaL_addchar(&b, *s++);
|
146
|
+
else {
|
147
|
+
size_t reslen;
|
148
|
+
char buff[200]; /* should be big enough for any conversion result */
|
149
|
+
s = checkoption(L, s + 1, cc);
|
150
|
+
reslen = strftime(buff, sizeof(buff), cc, stm);
|
151
|
+
luaL_addlstring(&b, buff, reslen);
|
152
|
+
}
|
153
|
+
}
|
154
|
+
luaL_pushresult(&b);
|
155
|
+
}
|
156
|
+
return 1;
|
157
|
+
}
|
158
|
+
|
38
159
|
static int os_time(lua_State *L) {
|
39
160
|
time_t t;
|
40
161
|
if (lua_isnoneornil(L, 1)) { /* called without args? */
|
@@ -61,7 +182,7 @@ static int os_time(lua_State *L) {
|
|
61
182
|
|
62
183
|
static int os_difftime(lua_State *L) {
|
63
184
|
lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
|
64
|
-
|
185
|
+
(time_t)(luaL_optnumber(L, 2, (lua_Number)0))));
|
65
186
|
return 1;
|
66
187
|
}
|
67
188
|
|
@@ -69,13 +190,14 @@ static const luaL_Reg libluaos[] = {
|
|
69
190
|
{"clock", os_clock},
|
70
191
|
{"time", os_time},
|
71
192
|
{"difftime", os_difftime},
|
193
|
+
{"date", os_date},
|
72
194
|
|
73
195
|
{NULL, NULL}
|
74
196
|
};
|
75
197
|
|
76
198
|
int
|
77
199
|
luaopen_luaos(lua_State *L) {
|
78
|
-
luaL_checkversion(L);
|
200
|
+
// luaL_checkversion(L);
|
79
201
|
luaL_register(L, "perf", libluaos);
|
80
202
|
return 1;
|
81
203
|
}
|
@@ -1,4 +1,6 @@
|
|
1
|
+
#include <stdint.h>
|
1
2
|
#include <stdio.h>
|
3
|
+
#include <string.h>
|
2
4
|
|
3
5
|
#define LUA_LIB
|
4
6
|
#include "lua.h"
|
@@ -66,7 +68,7 @@ static const luaL_Reg libsha1[] = {
|
|
66
68
|
|
67
69
|
int
|
68
70
|
luaopen_sha1(lua_State *L) {
|
69
|
-
luaL_checkversion(L);
|
71
|
+
// luaL_checkversion(L);
|
70
72
|
luaL_register(L, "sha1", libsha1);
|
71
73
|
return 1;
|
72
|
-
}
|
74
|
+
}
|
@@ -1,4 +1,6 @@
|
|
1
|
+
#include <stdint.h>
|
1
2
|
#include <stdio.h>
|
3
|
+
#include <string.h>
|
2
4
|
|
3
5
|
#define LUA_LIB
|
4
6
|
#include "lua.h"
|
@@ -69,7 +71,7 @@ static const luaL_Reg libsha256[] = {
|
|
69
71
|
|
70
72
|
int
|
71
73
|
luaopen_sha256(lua_State *L) {
|
72
|
-
luaL_checkversion(L);
|
74
|
+
// luaL_checkversion(L);
|
73
75
|
luaL_register(L, "sha2", libsha256);
|
74
76
|
return 1;
|
75
|
-
}
|
77
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#define LUA_LIB
|
2
|
+
#include <lua.h>
|
3
|
+
#include <lauxlib.h>
|
4
|
+
|
5
|
+
#ifdef _WIN32
|
6
|
+
#define WIN32_LEAN_AND_MEAN
|
7
|
+
#include <windows.h>
|
8
|
+
#else
|
9
|
+
#include <sys/utsname.h>
|
10
|
+
#endif /* _WIN32 */
|
11
|
+
|
12
|
+
static int lua_uname(lua_State *L)
|
13
|
+
{
|
14
|
+
#ifdef _WIN32
|
15
|
+
const char *name;
|
16
|
+
SYSTEM_INFO info;
|
17
|
+
lua_pushliteral(L, "Windows");
|
18
|
+
name = getenv("COMPUTERNAME");
|
19
|
+
lua_pushstring(L, name ? name : "");
|
20
|
+
memset(&info, 0, sizeof(info));
|
21
|
+
GetSystemInfo(&info);
|
22
|
+
if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
|
23
|
+
lua_pushliteral(L, "AMD64");
|
24
|
+
else if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
|
25
|
+
lua_pushliteral(L, "X86");
|
26
|
+
else if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM)
|
27
|
+
lua_pushliteral(L, "ARM");
|
28
|
+
else if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
|
29
|
+
lua_pushliteral(L, "IA64");
|
30
|
+
else if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
|
31
|
+
lua_pushstring(L, "");
|
32
|
+
return 3;
|
33
|
+
#else
|
34
|
+
struct utsname info;
|
35
|
+
if (uname(&info) >= 0)
|
36
|
+
{
|
37
|
+
lua_pushstring(L, info.sysname);
|
38
|
+
lua_pushstring(L, info.nodename);
|
39
|
+
lua_pushstring(L, info.machine);
|
40
|
+
return 3;
|
41
|
+
}
|
42
|
+
lua_pushstring(L, "Unknown");
|
43
|
+
return 1;
|
44
|
+
#endif
|
45
|
+
}
|
46
|
+
|
47
|
+
static const luaL_Reg sys_utils[] = {
|
48
|
+
{"uname", lua_uname},
|
49
|
+
{NULL, NULL}
|
50
|
+
};
|
51
|
+
|
52
|
+
int luaopen_sysutils(lua_State *L) {
|
53
|
+
// luaL_checkversion(L);
|
54
|
+
luaL_register(L, "sysutils", sys_utils);
|
55
|
+
return 1;
|
56
|
+
}
|