Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


CE7.0 source lua_pcall function has a bug

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
gfetgkh
Newbie cheater
Reputation: 0

Joined: 06 Apr 2018
Posts: 22

PostPosted: Thu Jan 02, 2020 1:10 am    Post subject: CE7.0 source lua_pcall function has a bug Reply with quote

My operating system is 64 bit. When CE7.0 trying to require a 32-bit DLL, the error is garbled if the error contains utf8 characters.I can't read the error message from the garbled code.

for example:
Code:
require('mydll')


Quote:
Error:error loading module 'mydll' from file 'D:\Program Files\Cheat Engine 7.0\mydll.dll':
%1 ?????Ч?? Win32 Ӧ?ó???


Lua_pcall function of luahandler.pas should be updated to support utf8 characters.

Quote:
Error:error loading module 'mydll' from file 'D:\CheatEngine\CheatEngine70src\Cheat Engine\bin\mydll.dll':
%1 不是有效的 Win32 应用程序。


Code:
function lua_pcall(L: Plua_State; nargs, nresults, errf: Integer): Integer; cdecl;
var
  error: string;
  usesluaengineform: boolean;
begin
  try
    if lua_isfunction(L, (-nargs)-1)=false then
    begin
      lua_pop(L,nargs+1);

      outputdebugstring(pchar('lua_pcall with invalid parameter'));
      //MessageBoxA(0, pchar('lua_pcall with invalid parameter'), pchar('Lua: Not a function'), MB_OK);
      exit(LUA_ERRRUN);
    end;

    result:=lua.lua_pcall(L, nargs, nresults, errf);
  except
    on e: exception do
    begin
      lua_pop(L, lua_gettop(L));
      result:=LUA_ERRRUN;
      lua_pushstring(l, e.Message);

      if (GetCurrentThreadId=MainThreadID) and (e.Message='Access Violation') and mainform.miEnableLCLDebug.checked then
      begin
        DebugLn('Lua Exception: '+e.Message);
        lazlogger.DumpExceptionBackTrace;
      end;
    end;
  end;

  if (result=LUA_ERRRUN) and (errf=0) then //an error occured and no error handler was specified
  begin
    if GetCurrentThreadId=MainThreadID then
    begin


      //lua_Debug
      error:=Lua_ToString(l, -1);
      if (error<>'') then
      begin
        usesluaengineform:=false;
        if printoutput=nil then
        begin
          if frmLuaEngine=nil then
            frmLuaEngine:=TfrmLuaEngine.Create(application);

          printoutput:=frmLuaEngine.mOutput.Lines;
          usesluaengineform:=true;
        end;

        printoutput.add(rsError+WinCPToUTF8(error));

        if (frmLuaEngine<>nil) and usesluaengineform and (frmLuaEngine.cbShowOnPrint.checked) then
          frmLuaEngine.show;

        if usesluaengineform then
          printoutput:=nil;

        lua_pop(L, lua_gettop(L));
      end;
    end
    else
    begin
      //MessageBoxA(0, pchar(Lua_ToString(l, -1)), pchar(rsNonMainthreadLuaError), MB_OK);
    end;
  end;
end;
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites