Return string from Lua Client (C# named pipe client)

Anything Cheat Engine related, bugs, suggestions, helping others, etc..
Post Reply
What is cheating?
What is cheating?
Posts: 1
Joined: Mon Mar 12, 2018 5:04 am
Reputation: 0

Return string from Lua Client (C# named pipe client)

Post by Kamil » Mon Mar 12, 2018 5:12 am

I am integrating Cheat Engine Lua into my C# .NET program using

Code: Select all

and a named pipe client in C# to send commands to the Lua server and get the return value.

This the code I am using, thanks to DarkByte:

This is working fine, but I am having no success trying to be able to return a string, or any other value than an integer.
Does anyone know how to achieve this?

Otherwise, I'll probably be using file IO to get the return values, but I'd rather not if possible.

Posts: 31
Joined: Fri Mar 03, 2017 12:03 am
Reputation: 17

Re: Return string from Lua Client (C# named pipe client)

Post by panraven » Tue Mar 13, 2018 10:30 pm

I may be wrong, but I guess there are hint in mono/pipeserver, search 'writeString'.
ie. read 4 byte as integer for string length, then read that many bytes as string?

never mind, I had mistaken other thing, sorry~

Hi, try to mess with the luapipe, got some problem and fixed by Dark Byte help here (it is in lua, but should be easy convert to C#).
Here some note to return non integer type:
ref TLuaServerHandler.execute>ExecuteLuaFunction>ExecuteLuaFunction_Internal

1. use command 3 (TLuaServerHandler.execute), it require a function reference (dword integer return from server), or a defined function name in server side, the bytes to be sent will be different in these 2 cases;
2. the bytes to be recieve should be received by each approiate type (Dword word byte string), instead read all bytes once (that's my problem, see readAll)
3. the input parameter type and return type should both use (ptNil=0, ptBoolean=1, ptInt64=2, ptInt32=3, ptNumber=4, ptString=5, ptTable=6 <Yet to be done>, ptUnknown=255 < for error? >), not LUA_TNUMBER /LUA_TSTRING etc.
4. when server result has a LUA_TNUMBER return number, it can be of Integer type (ptInt64) or double (ptNumber) depend on if it can be convert to integer, for Static Type Language like C#, it may need cautious when expecting a double return value, it may receive (ptInt64, Qword) instead of (ptNumber, double-value) if the number is a whole number/integer.
5. it seems it only can receive nil/boolean/integer/double(both number, LUA_TNUMBER)/string types, may be multiple return values.
6. Lua (in server side) is dynamic type, it may not return the type as expected, for example, for a function expected to retunr an address as integer, it may return nil due to unreadable memory. The C# side should consider such exception.


Post Reply

Who is online

Users browsing this forum: No registered users