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 


Running an exe as stream file use CE lua

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri Oct 23, 2015 1:01 am    Post subject: Running an exe as stream file use CE lua Reply with quote

Hi guys,

Credit to Panraven for his function to execute a lua file has store as stream file in Cheat Engine > Table :

Code:

function loadTableCode(n)     --- Load Table / File Lua Store in CE Table
  local t = findTableFile(n)
  if t ~= nil then
    local s = t.Stream
    local c = readStringLocal(s.Memory,s.Size)
    return c ~= nil and loadstring(c) -- return a function
  end
end

local f = loadTableCode('testbin.lua')
print(type(f))
if type(f) == 'function' then f() else print('not loaded') end


Now, i have testbin.lua for a test with the function above, it worked good.
Next, how to use that function for an execute file ?.

I try something like this. I have a small exe file and i think a exe file contain binaries = a binary file (If I am not wrong).
Convert the binary file (exe file, say it "blablabla.exe") to a string file with this code :

Code:

local hBinaryFile = io.open("blablabla.exe", "rb");
local sBinaryContent = "";
if(hBinaryFile)then
    while(true)do
        local block = hBinaryFile:read(512); -- Read only 512 bytes per iteration
        if(not block)then break;end
        sBinaryContent = sBinaryContent..block
    end
    hBinaryFile:close();
end
-- Now lets output it again.
local hBinaryOutput = io.open("output.txt", "wb");
if(hBinaryOutput)then
     hBinaryOutput:write(sBinaryContent);
     hBinaryOutput:close();
end


I got the output string file save to a file "output.txt".
Last, is it possible we load this string file as a function and executing it using lua ?.

Or is there other ways executing an exe file has store in CE table as a stream file ?

Regards
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Fri Oct 23, 2015 3:18 am    Post subject: Reply with quote

exe's need to be executed from disk. so you'll always have to first write them to disk and then execute it (shellExecute).
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri Oct 23, 2015 9:27 am    Post subject: Reply with quote

Thanks Dark Byte, understood
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