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 


help string.char(unpack(t)) too many results to unpack

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Lynxz Gaming
Expert Cheater
Reputation: 4

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Tue Jun 18, 2019 8:36 am    Post subject: help string.char(unpack(t)) too many results to unpack Reply with quote

help
Code:
string.char(unpack(t))

but
Code:
Error in native thread called Unnamed::[string "local luaL = {}
..."]:106: too many results to unpack

#t = 4866053

how to solve it?
what is max for unpack?

thx

_________________
my english is bad
discord : rynx#9828
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Tue Jun 18, 2019 9:17 am    Post subject: Reply with quote

My opinion, You try to reverse your script encoded using string.bytes which stores in Lua table t and decoded using string.char unpack from Lua table t.

Total characters on your table = 4866053 characters including white spaces.

To adjust max for unpack, adjust on _luaMaxCStack. but I don't know where to adjust _luaMaxCStack on CE. This was also known as Lua bugs issue.

Maybe, separate your script into some parts and table should fix the problem.

Or change the unpack function to custom unpack function, like this:

Code:
function get_str(t)
  local str = ""
   for i,c in ipairs(t) do
     if( c ~= nil ) then
        str = str..string.char(c)
     end
   end
     return str
end



This not too good and should running too slow, sometimes stack overflow.

or use:

Code:
function unpack (t, i)
  i = i or 1
    if t[i] ~= nil then
     return t[i], unpack(t, i + 1)
    end
 end

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL


Last edited by Corroder on Tue Jun 18, 2019 9:26 am; edited 1 time in total
Back to top
View user's profile Send private message
Lynxz Gaming
Expert Cheater
Reputation: 4

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Tue Jun 18, 2019 9:25 am    Post subject: Reply with quote

the t is a 4MB exe bytes
_________________
my english is bad
discord : rynx#9828
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Tue Jun 18, 2019 9:29 am    Post subject: Reply with quote

Lynxz Gaming wrote:
the t is a 4MB exe bytes


Why say now?. Not on the first post.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Lynxz Gaming
Expert Cheater
Reputation: 4

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Tue Jun 18, 2019 9:43 am    Post subject: Reply with quote

sorry. forgot
_________________
my english is bad
discord : rynx#9828
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Thu Jun 20, 2019 1:57 pm    Post subject: Reply with quote

I don't understand why you obtain executable as in bytes (in the first place), as if it was fetched from internet, you could have saved it directly to a file using io functions.
if you wish to store the executable in a long string, you may try to use memory stream, write those bytes, save the file locally (as readStringLocal would not suit here) and read it using io functions.
Code:
ms = createMemoryStream();    -- memory stream;
ms.write(tab,#tab);         -- your table with bytes;
-- if does not work (as I have not tested this with 4mb file) you should run in ipairs;
-- for _,byte in ipairs(tab) do
   -- ms.writeByte(byte);
-- end

local path = 'C:\\folder\\file.exe';
ms.saveToFile(path);
ms.destroy();

local file = io.open(path);
text = file:read('*a'); file:close();

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
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