You are not logged in.
Pages: 1
I'm working on a script to add extra settings to the stream.ini file, which will support CLEO 3 and CLEO 4 (at the moment I'm using CLEO 4 for ease and debugging).
Pretty well-optimized script as it uses mostly functions. I'm not sure all of it works yet, but the first problem I've noticed is calling 0x8229B6 (strcmp)
{$CLEO} wait 2 0A9A: 0@ = openfile "stream.ini" mode 0x72 // use CLEO 3 open mode else_jump @End 0AC6: 2@ = label @aFrameDelay offset :ScanFile while true wait 0 0AA7: call_function 0x536F80 num_params 1 pop 1 0@ 1@ // write the next line of stream.ini to 0xB71848 8039: not 1@ == 0 // above function returns "0xB71848" if it was successful jf break 0AA7: call_function 0x8229B6 num_params 2 pop 2 0xB71848 2@ 1@ // thread memory used for CLEO 3 support, "framedelay" instead of 2@ produces same results 0ACE: show_formatted_text_box "%d" 1@ wait 2000 0039: 1@ == 2 // I'll set back to 1 later, this is for debugging else_jump @ScanFile 0AA7: call_function 0x82258E num_params 1 pop 1 0xB71852 1@ 0A8C: write_memory 0x53E94C size 1 value 1@ virtual_protect 1 break end 0A9B: closefile 0@ :End 0A93: end_custom_thread :aFrameDelay hex "framedelay" 00 end
stream.ini
framedelay 5 memory 600000 devkit_memory 600000 vehicles 12 pe_lightchangerate 0.0008 pe_lightingbasecap 0.35 pe_lightingbasemult 0.4 pe_leftx 16 pe_topy 16 pe_rightx 16 pe_bottomy 16 pe_bRadiosity 1 dontbuildpaths
The problem is, the function returns -1 on the line which contains "framedelay". However, on the lines which contain "dontbuildpaths" and "devkit_memory" return 1. I see no reason why this is happening.
Offline
stricmp compares entire string, including trailing '\0'. It returns -1 if string1 < string2; 1, if string1 > string2 or 0 if strings are equal.
"framedelay" < "framedelay 5", because '\0' < ' '. So, stricmp returns -1
"framedelay" > "dontbuildpaths", because 'f' > 'd'
You shold use _strnicmp (0x835AC7) with exact length of the string, e.g., strnicmp ("framedelay", szLineBuf, 10);
Offline
Thanks for that.
After finding out IDA has a "pseudocode" feature I noticed it uses strtok first. By the looks of the C++ Reference, this is something else I need (since it can automatically separate strings by spaces/tabs). I've often thought sscanf was the only way of doing something like this.
for ( i = CFileMgr_getConfigLine(v3); i; i = CFileMgr_getConfigLine(v2) ) { if ( *(_BYTE *)i != '#' ) { if ( *(_BYTE *)i ) { v5 = strtok((char *)i, " ,\t"); v4 = strtok(0, " ,\t"); if ( stricmp(v5, "memory") || v1 ) { if ( stricmp(v5, "devkit_memory") ) { [...] } else { dword_8A5A80 = atoi(v4) << 10; v1 = 1; } } else { dword_8A5A80 = atoi(v4) << 10; } } } }
It's much easier to keep track of the variables this way.
Working Code
{$CLEO} wait 2 0A9A: 0@ = openfile "stream.ini" mode 0x72 else_jump @End 0AC6: 3@ = label @aFrameDelay offset 0AC7: 4@ = var 5@ offset :ScanFile while true wait 0 0AA7: call_function 0x536F80 num_params 1 pop 1 0@ 1@ 8039: not 1@ == 0 jf break 0A8D: 2@ = read_memory 1@ size 1 virtual_protect 0 8039: not 2@ == 0x23 jf break 0AA7: call_function 0x82244B num_params 2 pop 2 0x86A8C8 1@ 1@ 0AA7: call_function 0x82244B num_params 2 pop 2 0x86A8C8 0 4@ 0AA7: call_function 0x8229B6 num_params 2 pop 2 1@ 3@ 2@ 0039: 2@ == 0 else_jump @ScanFile 0AA7: call_function 0x82258E num_params 1 pop 1 4@ 2@ 0A8C: write_memory 0x53E94C size 1 value 2@ virtual_protect 1 break end 0A9B: closefile 0@ :End 0A93: end_custom_thread :aFrameDelay hex "framedelay" 00 end
Now I'll work on adding all sorts of settings to this file. Probably to do with optimisation and graphics in order to keep the stream.ini's original purpose. Since I don't know of too many memory locations of this stuff yet, I better start digging... Thanks for the help.
Offline
Pages: 1