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 


stringToMD5String zero terminated the string?

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

Joined: 01 Oct 2008
Posts: 941

PostPosted: Sun Nov 06, 2016 6:52 pm    Post subject: stringToMD5String zero terminated the string? Reply with quote

Is it a expected result?
Code:

local xxx,zero = 'xxx',string.char(0)
local a = xxx..xxx
local b = xxx..zero..xxx
local c = xxx
print(stringToMD5String(a))
print(stringToMD5String(b))
print(stringToMD5String(c))

-- output
dad3a37aa9d50688b5157698acfd7aee
f561aaf6ef0bf14d4208bb46a4ccb3ad
f561aaf6ef0bf14d4208bb46a4ccb3ad


md5memory and md5file don't zero terminated its content.

thanks~

_________________
- Retarded.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Nov 06, 2016 9:22 pm    Post subject: Reply with quote

There are other things, for example we can not use
Code:
writeString( addr , str..string.char(0) )


I have to use this:
Code:
writeString( addr , str )
writeBytes( addr+#str, 0 )








yes, md5 should be:
Code:
-- output
dad3a37aa9d50688b5157698acfd7aee
efe8c109e39c79ef313df9f549e5572a
f561aaf6ef0bf14d4208bb46a4ccb3ad






This is because DB uses this:
Code:
function lua_stringToMD5String(L:PLua_State): integer; cdecl;
var s: string;
begin
  if lua_gettop(L)=1 then
  begin
    s:=Lua_ToString(L,1);              // at this line source string is cut on first zero byte
    lua_pushstring(L, MD5Print(MD5String(s)));
    result:=1;
  end
  else
    result:=0;
end;



instead of
Code:
function lua_stringToMD5String(L:PLua_State): integer; cdecl;
var msg: pchar;
    size: integer;
begin
  if lua_gettop(L)=1 then
  begin
    msg:=lua_tolstring(L, 1, @size);
    lua_pushstring(L, MD5Print(MD5Buffer(msg^,size)));
    result:=1;
  end
  else
    result:=0;
end;

_________________
Back to top
View user's profile Send private message MSN Messenger
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Mon Nov 07, 2016 1:01 am    Post subject: Reply with quote

I see.

Can we have version of c function for writeString,readString,stringToMD5String etc that treat Lua string not as zero terminated string? eg.
writeByteString(addr, string) ------ don't need widechar version
readByteString(addr, requestedStringLengthNotMaxLength)
md5string(string)

so that existed functions are stay compatible.

bye~

_________________
- Retarded.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Nov 07, 2016 4:23 am    Post subject: Reply with quote

stringToMD5String, I can add fixed version to my custom build.




About writeByteString, we can use something like this:
Code:
bt = stringToByteTable('xxx'..string.char(0)..'xxx')
--   bt = wideStringToByteTable('xxx'..string.char(0)..'xxx')
writeBytes(addr,bt)


readByteString:
Code:
bt = readBytes(addr, size, true)
str = byteTableToString(bt)
--    str = byteTableToWideString(bt)

_________________
Back to top
View user's profile Send private message MSN Messenger
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Mon Nov 07, 2016 4:48 am    Post subject: Reply with quote

Thank you! read/write work and faster than convert by Lua.
_________________
- Retarded.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Fri Nov 11, 2016 11:41 am    Post subject: Reply with quote

if you need fixed stringToMD5String, take this
https://docs.google.com/uc?id=0BwMAnE6mjogMaHZVU09NbGJTOXc&export=download

Code:
print(stringToMD5String('xxx\0xxx'))
> efe8c109e39c79ef313df9f549e5572a




 

_________________
Back to top
View user's profile Send private message MSN Messenger
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Sun Nov 13, 2016 9:31 am    Post subject: Reply with quote

mgr.inz.Player wrote:
if you need fixed stringToMD5String, take this
https://docs.google.com/uc?id=0BwMAnE6mjogMaHZVU09NbGJTOXc&export=download

Code:
print(stringToMD5String('xxx\0xxx'))
> efe8c109e39c79ef313df9f549e5572a


 


Thank you, I make a folder copy of standard ce 6.6 and extract over, it work as expected.

_________________
- Retarded.
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