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

Kamil

What is cheating?
Mar 12, 2018
1
0
1
#1
I am integrating Cheat Engine Lua into my C# .NET program using
Code:
openLuaServer("NameHere")
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: http://forum.cheatengine.org/viewtopic.php?p=5687454

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.
 
Mar 3, 2017
31
0
6
#2
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?
bye~

never mind, I had mistaken other thing, sorry~

ADDED:
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.

bye~
 
Top Bottom