Lucciefr
Lua code caving, injection and exploration framework
globals.h
1 
3 #ifndef GLOBALS_H
4 #define GLOBALS_H
5 
6 #include "limits.h"
7 #include "lua.h"
8 #include "process.h" // pid_t
9 /*
10 #include "config.h"
11 #include "bool.h"
12 #include <stdint.h>
13 */
14 #if _WINDOWS
15  #include <windows.h>
16 #endif
17 #ifndef HINSTANCE
18  #define HINSTANCE void*
19 #endif
20 
22 extern struct lcfr_globals_t {
23  pid_t pid;
24  void *libhandle;
25  HINSTANCE htarget;
26  HINSTANCE hself;
27  unsigned int pagesize;
28  char dllpath[PATH_MAX];
29 
30  lua_State *lua_state;
31 /*
32 #if CFG_LUA_PRECISION
33  uint16_t fpu_mode; // this field saves the previous FPU precision mode (within LuaEnter, restored in LuaLeave)
34 #endif
35  int lua_result; // Lua execution result (status code)
36  bool ticks_active; // used to control ticks callback during "reload", and when closing lua
37 */
38 } lcfr_globals;
39 
40 /*
41 // elapsed time since mmBBQ startup, in milliseconds
42 // gets initialized and updated in the timer thread (ticks_run)
43 extern double elapsed;
44 
45 // (Lua registry) references for system events
46 // These get assigned in create_system_events() during luaopen_event().
47 extern struct event_refs_t {
48  int console; // CONSOLE event (input line from console)
49  int ontick; // ONTICK event (periodic timer notification)
50  int shutdown; // SHUTDOWN event (reloading or exiting Lua)
51  int shutdown_late; // SHUTDOWN_LATE event (e.g. for auto-ejecting caves)
52  int userinput; // USERINPUT event (win messages from DispatchMessage hook)
53 } event_refs;
54 */
55 
56 // shortcut macros for frequently accessed elements
57 
58 #define LUA lcfr_globals.lua_state
59 #define PID lcfr_globals.pid
60 #define TID lcfr_globals.tid
61 #define BASE lcfr_globals.htarget
62 #define DLL_HANDLE lcfr_globals.hself
63 #define PAGESIZE lcfr_globals.pagesize
64 
65 /*
66 #define CONSOLE event_refs.console
67 #define ONTICK event_refs.ontick
68 #define SHUTDOWN event_refs.shutdown
69 #define SHUTDOWN_LATE event_refs.shutdown_late
70 #define USERINPUT event_refs.userinput
71 */
72 
73 void initialize_globals(void);
74 
75 #endif // GLOBALS_H
lua_State * lua_state
(main) Lua state
Definition: globals.h:30
struct lcfr_globals_t lcfr_globals
global state
Definition: globals.c:8
HINSTANCE htarget
"target" module handle = base addr of main executable
Definition: globals.h:25
void * libhandle
dynamic library handle, may be != hself under Linux
Definition: globals.h:24
This struct describes Lucciefr's global variables ("status"), accessible from anywhere.
Definition: globals.h:22
unsigned int pagesize
the system's page size (in bytes)
Definition: globals.h:27
HINSTANCE hself
"self" module handle = base addr of dynamic library
Definition: globals.h:26
pid_t pid
process ID
Definition: globals.h:23
char dllpath[PATH_MAX]
(absolute) file path of the dynamic library
Definition: globals.h:28