Page 1 of 1

Custom Symbol Mapping for Prefix Strings in [PRISM3D]

Posted: Mon Mar 20, 2023 5:41 pm
by J1327

Initially worked on American truck simulator traffic mod that would be based on OS time...
Goofing around with ATS in game timer didn’t lead anywhere there was I expecting to (in fact, for that, needs additional Lua - it is possible to make)
(At Night more traffic - at day time less traffic or versa) ...Ended up with many strings...



This prefix_string to cheat engine symbol can be done with celua code...

..so initially when scan begins (from start address) - it looks for an string with "ExpectedStringPrefix_String" if "ExpectedStringPrefix_" is discovered from first address then script will print in full string form (example "g_traffic") and afterwards jumps 0x140 (to the next string). If code finds "ExpectedStringPrefix_String" it prints another string and at this point (this is loop).

If code fails to find a string from pattern then from temporary location will be jumped +0x8 from temp location (jump variable) forward and attempts again search for "stringprefix*" until given END address is reached.

For each unique case variables/aob's must be accordingly edited!
NearFirstStringAOB, EndStringBlockAOB, block, GetStringList == everything else leave rest of the work to the script...

FirstAddressAOB – Aob pattern there scan starts
EndStringBlockAOB – Aob pattern there scan ends
block – Difference (in hex) between String_1 and String_2..
GetStringList – What strings expect to find

When it could be effective : If you have enabled STRING_TO_SYMBOL=1 : take for example as for ATS : "g_traffic", "g_traffic"+0x110=1 (1 == effective value), increasing value higher than 1 will increase spawned AI's car number...
..and for blocks: g_traffic+0x140=g_kdop_preview+0x140=g_screenshot_on_bug_quality+140=ect...

Note: that scan of aob is based on process (possible to set as module)

code for latest 23-11-16 PRISIM3D Engine game - ATS.

and so..
Code..



Code: Select all

Module=process
-- target

NearFirstStringAOB='72 5F 69 6D 67 75 69 5F 73 63 61 6C 65 00 00 00'
-- start address as aob

EndStringBlockAOB = '90 D2 12 06 F7 7F 00 00 80 67 12 06 F7 7F 00 00'
-- end address as aob

GetStringList = {'r_','t_','vid_','s_','cf_','g_','r_','test_','i_','inst_','shd_','ui_'}
-- prepare to find strings that begins with... (prefix)

DEBUG_TEXT = 0
-- additional print output, default 0 == off

jump = 8
-- Check intervals (How far "jump near(forward)" if expected string at given location is not to be found)

block = 0x140
-- Calculate MAX string block (...)

StringMaxLenght = 32
-- Must be set. If catches wrong strings (example ??Z?r_), enter lower number

STRING_TO_SYMBOL = 1
-- default off == 0 , registers matched strings into user defined symbols

NearFirstStringAddress = AOBScanModuleUnique(Module,NearFirstStringAOB)
if (NearFirstStringAddress==nil) then print("CRUCIAL: COULDNT FIND FIRST ADDRESS STRING AOB SIG") return end
-- Get First Address

EndStringAddress=AOBScanModuleUnique(Module,EndStringBlockAOB)
if (EndStringAddress==nil)then print("CRUCIAL: COULDNT FIND END ADDRESS STRING AOB SIG") return end
-- Get Last Address

NearFirstStringAddressString=readString(NearFirstStringAddress,StringMaxLenght)
EndAddressString=readString(EndStringAddress,StringMaxLenght)
-- Get First and last string


-- (below being used for calculations and print func)

found_strings=0
-- calculates how many found in given range

not_found_strings=0
-- calculates how many NOT found in given range

-- Below Function part

-- Search for strings
function checkstring()
         for i, v in ipairs(GetStringList)
             do
              if (DEBUG_TEXT==1) then print(i, v) end
                 if string.find(tempstring,v)
                    then

                    if (DEBUG_TEXT==1) then print(TXT_LINE);print(TXT_FOUND,tempstring);print(TXT_ATADR,temp);print(TXT_LINE);end
					 -- then found inform
					
					if (STRING_TO_SYMBOL==1) then registerSymbol(tempstring,temp) else end
					
						found_strings=found_strings+1
						-- add found info for later
						
						temp=temp+block
						-- jump block away
						
						tempstring=readString(temp,StringMaxLenght)
						-- prepare to read a new string
						
                    return
                else
             end
         end
         if (DEBUG_TEXT==1) then print (TXT_NOT,temp,TXT_W,tempstring) end
         not_found_strings=not_found_strings+1
		 
         temp = temp + jump
		 -- prepare to read a new address
		 
         tempstring=readString(temp,StringMaxLenght)
		 -- prepare to read a new string
end

-- First Initialize Block scan
function checkblock()

     if (DEBUG_TEXT==1) then debug_text() else end
	 -- check if additional custom logging is enabled
	 
     temp = NearFirstStringAddress
	 -- load first address into  check
	 
     tempstring = NearFirstStringAddressString
	 -- load first address STRING into check
	 
     while (temp < EndStringAddress)
           do
		   
             checkstring()
			 -- call strings check fx
			 
             if (DEBUG_TEXT==1) then print (TXT_SEARCH,temp,TXT_STOP,EndStringAddress) end
           end
		   
     checkstring()
	 -- run one more time.
	 
     if (DEBUG_TEXT==1) then print (TXT_TOTAL,found_strings,TXT_ANDNOT,not_found_strings) end

end

function debug_text()
TXT_LINE="---"
TXT_FOUND="FOUND STRING:"
TXT_ATADR="AT ADDRESS:"
TXT_TOTAL="TOTAL EXPECTED STRINGS FOUND:"
TXT_ANDNOT="AND SKIPPED:"
TXT_NOT="STRING WAS NOT FOUND AT:"
TXT_W="WHILE STRING IS"
TXT_SEARCH='SEARCHING STRINGS.. ADDRESS:'
TXT_STOP="STOP ADDRESS:"
end
-- Displays additional text if enabled

checkblock()
-- call this function

Image



these links contributed to this "build" -- from idea to script
https://www.tutorialspoint.com/lua/lua_while_loop.htm -- to maintain start address and end block address search
https://www.lua.org/pil/7.3.html -- check for expected strings (list method)
http://lua-users.org/wiki/StringLibraryTutorial -- Strings checks



day one code will be archived...
[Archived]



23-11-16 reviewed…
and 🙃. (...) idk. Here am using string prefix as "wild card" and if in the context when games use console or string variable system -- This can be useful. e.g., prefix_string has near effective value.Yet,

In overall could better rewritten from scratch. There is one point -- Here am jumping from start address to end address rather using celua memscan -- which solves block problem ish. (...). Also, here I use a lot of variables as global... instead of local temp = ... (...) ...
Anyway, a bit cleaned code and...