You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CodeFunctions.cpp
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -177,7 +177,7 @@ int luaExposeCode(lua_State* L) {
177
177
}
178
178
179
179
if (argumentCount > RPS_ARGUMENT_LIMIT) {
180
-
returnluaL_error(L, (std::string("too many arguments specified, max is ") + std::to_string(RPS_ARGUMENT_LIMIT) + ": " + std::to_string(argumentCount)).c_str());
180
+
returnluaL_error(L, "too many arguments specified, max is %d but %d were specified", RPS_ARGUMENT_LIMIT, argumentCount);
181
181
}
182
182
183
183
int adjustedArgCount = argumentCount - (int)(callingConvention == CallingConvention::THISCALL);
@@ -219,13 +219,13 @@ int luaHookCode(lua_State* L) {
219
219
}
220
220
221
221
if (argumentCount > RPS_ARGUMENT_LIMIT) {
222
-
returnluaL_error(L, ("too many arguments specified, max is " + std::to_string(RPS_ARGUMENT_LIMIT) + ": " + std::to_string(argumentCount)).c_str());
222
+
returnluaL_error(L, "too many arguments specified, max is %d but %d were specified" , RPS_ARGUMENT_LIMIT, argumentCount);
returnluaL_error(L, "a hook already exists for function at: " + address);
228
+
returnluaL_error(L, "a hook already exists for function at: 0x%X", address);
229
229
}
230
230
231
231
// Store a reference to the hook function that is to be called later.
@@ -316,11 +316,12 @@ int luaCallMachineCode(lua_State* L) {
316
316
int argumentCount = lua_tointeger(L, lua_upvalueindex(2));
317
317
int callingConvention = lua_tointeger(L, lua_upvalueindex(3));
318
318
319
+
int actualArgCount = lua_gettop(L);
320
+
319
321
if (callingConvention == CallingConvention::THISCALL) {
320
322
int totalArgCount = argumentCount + 1; // ecx is passed as the first parameter
321
-
if (lua_gettop(L) != totalArgCount) {
322
-
//std::cout << "[RPS]: calling function " << std::hex << functionLocation << " with too few arguments;" << std::endl;
323
-
returnluaL_error(L, ("[RPS]: calling function " + std::to_string(functionLocation) + " with too few arguments;").c_str());
323
+
if (actualArgCount != totalArgCount) {
324
+
returnluaL_error(L, "[RPS]: error when invoking function 0x%X: expected %d arguments, but received %d", functionLocation, totalArgCount, actualArgCount);
324
325
}
325
326
326
327
for (int i = 0; i < argumentCount; i++) {
@@ -331,20 +332,19 @@ int luaCallMachineCode(lua_State* L) {
331
332
}
332
333
333
334
if (lua_type(L, 1) != LUA_TNUMBER) {
334
-
returnluaL_error(L, ("[RPS]: calling function " + std::to_string(functionLocation) + "ecx value is not an integer (or pointer);").c_str());
335
+
returnluaL_error(L, "[RPS]: calling function 0x%X ecx value is not an integer (or pointer)", functionLocation);
335
336
}
336
337
337
338
currentECXValue = lua_tointeger(L, 1); // this parameter
338
339
}
339
340
else {
340
341
if (lua_gettop(L) != argumentCount) { // + 0
341
-
//std::cout << "[RPS]: calling function " << std::hex << functionLocation << " with too few arguments;" << std::endl;
342
-
returnluaL_error(L, ("[RPS]: calling function " + std::to_string(functionLocation) + " with too few arguments;").c_str());
342
+
returnluaL_error(L, "[RPS]: error when invoking function 0x%X: expected %d arguments, but received %d", functionLocation, argumentCount, actualArgCount);
343
343
}
344
344
345
345
for (int i = 0; i < argumentCount; i++) {
346
346
if (lua_type(L, i + 1) != LUA_TNUMBER) {
347
-
returnluaL_error(L, ("[RPS]: calling function " + std::to_string(functionLocation) + "argument #" + std::to_string(i+1) + "is not an integer (or pointer);").c_str());
347
+
returnluaL_error(L, "[RPS]: calling function 0x%X argument #%d is not an integer (or pointer)", functionLocation, i + 1);
348
348
}
349
349
fakeStack[i] = lua_tointeger(L, i + 1); // i + 1 to offset the 0-base
350
350
}
@@ -713,7 +713,7 @@ int luaDetourCode(lua_State* L) {
713
713
714
714
std::pair<std::map<DWORD, std::shared_ptr<LuaDetour>>::const_iterator, bool> hi = detourTargetMap.insert(std::pair<DWORD, std::shared_ptr<LuaDetour>>(address, std::make_shared<LuaDetour>(address, ret)));
715
715
if (!hi.second) {
716
-
returnluaL_error(L, ("detour already exists at this address: " + std::to_string(address)).c_str());
716
+
returnluaL_error(L, "detour already exists at this address: 0x%X", address);
0 commit comments