fc762ac200
- Rename COMBAT_LOG_EVENT -> COMBAT_LOG_EVENT_UNFILTERED across Zig/Lua - DPSMate CLEU adapter: absorb pipeline (SetUnregisterVariables, Absorb, ConfirmAbsorbApplication, UnregisterAbsorb), BuildFail type 2/3, "(Periodic)" suffix, removed dead handler - WSBT (Weird Scrolling Battle Text): CLEU adapter fork of MSBT with dispatch table, A/B combat profiling, selective event unregistration - Module version API: GetWeirdUtilsVersion(name?) Lua function + WeirdUtils global table, additive across independent DLLs. Build system passes per-module version strings via build_options. - Hook Glue_LoadScriptFunctions (0x46ABB0) for login screen availability - Rename lsf_hook -> register_commands_hook (real name: Player_LoadScriptFunctions) - lua.zig: add setglobal/getglobal via LUA_GLOBALSINDEX (-10001)
161 lines
5.1 KiB
Zig
161 lines
5.1 KiB
Zig
//! WoW 1.12.1 Lua C API wrappers (all __fastcall, L in ECX)
|
|
|
|
const std = @import("std");
|
|
const hook = @import("zhook");
|
|
|
|
pub const State = *anyopaque;
|
|
|
|
pub fn getContext() State {
|
|
const f: *const fn () callconv(hook.cc.fastcall) State = @ptrFromInt(0x7040D0);
|
|
return f();
|
|
}
|
|
|
|
pub fn gettop(L: State) i32 {
|
|
const f: *const fn (State) callconv(hook.cc.fastcall) i32 = @ptrFromInt(0x6F3070);
|
|
return f(L);
|
|
}
|
|
|
|
pub fn settop(L: State, index: i32) void {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) void = @ptrFromInt(0x6F3080);
|
|
f(L, index);
|
|
}
|
|
|
|
pub fn pop(L: State, n: i32) void {
|
|
settop(L, -n - 1);
|
|
}
|
|
|
|
pub fn pushvalue(L: State, index: i32) void {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) void = @ptrFromInt(0x6F3350);
|
|
f(L, index);
|
|
}
|
|
|
|
pub fn remove(L: State, index: i32) void {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) void = @ptrFromInt(0x6F30D0);
|
|
f(L, index);
|
|
}
|
|
|
|
pub fn insert(L: State, index: i32) void {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) void = @ptrFromInt(0x6F31A0);
|
|
f(L, index);
|
|
}
|
|
|
|
pub fn typeOf(L: State, index: i32) i32 {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) i32 = @ptrFromInt(0x6F3400);
|
|
return f(L, index);
|
|
}
|
|
|
|
pub fn typeName(L: State, tp: i32) [*:0]const u8 {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) [*:0]const u8 = @ptrFromInt(0x6F3480);
|
|
return f(L, tp);
|
|
}
|
|
|
|
pub fn isnumber(L: State, index: i32) bool {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) u32 = @ptrFromInt(0x6F34D0);
|
|
return f(L, index) != 0;
|
|
}
|
|
|
|
pub fn isstring(L: State, index: i32) bool {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) u32 = @ptrFromInt(0x6F3510);
|
|
return f(L, index) != 0;
|
|
}
|
|
|
|
pub fn pushnil(L: State) void {
|
|
const f: *const fn (State) callconv(hook.cc.fastcall) void = @ptrFromInt(0x6F37F0);
|
|
f(L);
|
|
}
|
|
|
|
pub fn pushnumber(L: State, n: f64) void {
|
|
// __thiscall: ECX=L, f64 on stack [EBP+8]/[EBP+0xc], ret 8.
|
|
// .never_tail: callee-cleanup pops stack args - tail-call would corrupt the stack.
|
|
const f: *const fn (State, f64) callconv(.{ .x86_thiscall = .{} }) void = @ptrFromInt(0x6F3810);
|
|
@call(.never_tail, f, .{ L, n });
|
|
}
|
|
|
|
pub fn pushstring(L: State, s: [*:0]const u8) void {
|
|
const f: *const fn (State, [*:0]const u8) callconv(hook.cc.fastcall) void = @ptrFromInt(0x6F3890);
|
|
f(L, s);
|
|
}
|
|
|
|
pub fn pushboolean(L: State, b: i32) void {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) void = @ptrFromInt(0x6F39F0);
|
|
f(L, b);
|
|
}
|
|
|
|
pub fn pushcclosure(L: State, func: usize, n: i32) void {
|
|
const f: *const fn (State, usize, i32) callconv(hook.cc.fastcall) void = @ptrFromInt(0x6F3920);
|
|
@call(.never_tail, f, .{ L, func, n });
|
|
}
|
|
|
|
pub fn tonumber(L: State, index: i32) f64 {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) f64 = @ptrFromInt(0x6F3620);
|
|
return f(L, index);
|
|
}
|
|
|
|
pub fn tostring(L: State, index: i32) ?[*:0]const u8 {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) ?[*:0]const u8 = @ptrFromInt(0x6F3690);
|
|
return f(L, index);
|
|
}
|
|
|
|
pub fn toboolean(L: State, index: i32) i32 {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) i32 = @ptrFromInt(0x6F3660);
|
|
return f(L, index);
|
|
}
|
|
|
|
pub fn newtable(L: State) void {
|
|
const f: *const fn (State) callconv(hook.cc.fastcall) void = @ptrFromInt(0x6F3C90);
|
|
f(L);
|
|
}
|
|
|
|
pub fn settable(L: State, index: i32) void {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) void = @ptrFromInt(0x6F3E20);
|
|
f(L, index);
|
|
}
|
|
|
|
pub fn gettable(L: State, index: i32) void {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) void = @ptrFromInt(0x6F3A40);
|
|
f(L, index);
|
|
}
|
|
|
|
pub fn next(L: State, index: i32) i32 {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) i32 = @ptrFromInt(0x6F4450);
|
|
return f(L, index);
|
|
}
|
|
|
|
pub fn pcall(L: State, nargs: i32, nresults: i32, errfunc: i32) i32 {
|
|
const f: *const fn (State, i32, i32, i32) callconv(hook.cc.fastcall) i32 = @ptrFromInt(0x6F41A0);
|
|
return @call(.never_tail, f, .{ L, nargs, nresults, errfunc });
|
|
}
|
|
|
|
pub fn luaError(L: State, msg: [*:0]const u8) void {
|
|
hook.call(fn (*anyopaque, [*:0]const u8) callconv(hook.cc.cdecl) void, 0x6F4940, .{ L, msg });
|
|
}
|
|
|
|
pub const LuaReg = extern struct {
|
|
name: ?[*:0]const u8,
|
|
func: usize,
|
|
};
|
|
|
|
pub fn openlib(L: State, libname: ?[*:0]const u8, funcs: [*]const LuaReg, nup: i32) void {
|
|
const f: *const fn (State, ?[*:0]const u8, [*]const LuaReg, i32) callconv(hook.cc.fastcall) void = @ptrFromInt(0x6F4DC0);
|
|
@call(.never_tail, f, .{ L, libname, funcs, nup });
|
|
}
|
|
|
|
pub fn checknumber(L: State, index: i32) f64 {
|
|
const f: *const fn (State, i32) callconv(hook.cc.fastcall) f64 = @ptrFromInt(0x6F4C80);
|
|
return f(L, index);
|
|
}
|
|
|
|
// Lua 5.0 pseudo-index for globals table
|
|
pub const GLOBALS_INDEX: i32 = -10001;
|
|
|
|
pub fn setglobal(L: State, name: [*:0]const u8) void {
|
|
pushstring(L, name);
|
|
insert(L, -2); // swap: value is now at -1, name at -2 → after insert: name at -2, value at -1
|
|
settable(L, GLOBALS_INDEX);
|
|
}
|
|
|
|
pub fn getglobal(L: State, name: [*:0]const u8) void {
|
|
pushstring(L, name);
|
|
gettable(L, GLOBALS_INDEX);
|
|
}
|