String Reference Viewer [WIP]

Upload *YOUR* gamehacking tools/helpers here
Post Reply
aSwedishMagyar
Table Makers
Table Makers
Posts: 670
Joined: Mon Jul 06, 2020 3:19 am
Reputation: 1190

String Reference Viewer [WIP]

Post by aSwedishMagyar »

So I wanted to make a Referenced String search feature that was similar to x64dbg with a constantly updating list depending on your input. Here is what I've come up with. You can put the lua code in your auto run folder to make a button that will open the menu or you can just use the included .CT file.

Updates:
  1. Made two buttons for saving the dissected code state to your desktop. Also fixed an issue that could arise when you had a '-' in module names preventing the moduleName filter from working.
  2. Made the form start in the center of the screen. Added a toggle between case-sensitive. And added the ability to set software breakpoints on the list of instructions that reference the string. If the breakpoint is hit it will print the getNameFromAddress() and remove itself and the game will continue running.
  3. Modified the ListView to use the OnData function to populate it's contents instead of the EditBox's OnChange which seems to have sped things up significantly. Got the Idea from Retard in the CTG discord who asked DB. I also made the search convert each string into a byte table, and then converted that byte table into a hex string which seems to have taken care of issues regarding characters such as % (please let me know if this is not the case).
  4. Added spaces between each hex byte character to prevent erroneous detection.
This is the latest state of the Viewer:
Image

This is a snap with the new buttons and the breakpoint list showing how it sets a software breakpoint for each instruction in the 'Referenced By' window:
Image

It requires you to dissect code first but it will find all the reference points and clicking on them in the reference list will take you to the instruction address in the disassembler window.

The Selected Module Combo Box is for further filtering if you dissected multiple modules and wanted to only look at strings found in a particular region.

Hoping for some feedback on ways to improve the search speed or maybe use a separate thread for updating since I'm not really familiar with that area.

Cheers,
aSwedishMagyar
Attachments
stringReferenceMenu.zip
PW: aSwedishMagyar
(2.39 KiB) Downloaded 231 times
stringReferenceMenu.CT
(9.66 KiB) Downloaded 203 times
Last edited by aSwedishMagyar on Sun Aug 15, 2021 8:45 pm, edited 5 times in total.

iNvIcTUs oRCuS
Noobzor
Noobzor
Posts: 9
Joined: Fri Mar 03, 2017 6:22 am
Reputation: 5

Re: String Reference Viewer [WIP]

Post by iNvIcTUs oRCuS »

Nice work man...
One thing to mention. On some of my systems the position of windows taskbar is at the top of the screen.
I think its better when the gui of your addon is maybe in center of the screen.
I changed it by myself in the actual file.

Keep it up...

aSwedishMagyar
Table Makers
Table Makers
Posts: 670
Joined: Mon Jul 06, 2020 3:19 am
Reputation: 1190

Re: String Reference Viewer [WIP]

Post by aSwedishMagyar »

Added some more features if anyone is interested in testing/critiquing. I'd be especially interested if someone knew how to speed up the updating of the listview since with more than a few hundred strings it will lag noticeably.

panraven
Table Makers
Table Makers
Posts: 121
Joined: Fri Mar 03, 2017 12:03 am
Reputation: 108

Re: String Reference Viewer [WIP]

Post by panraven »

aSwedishMagyar wrote:
Sat Aug 14, 2021 8:21 am
Added some more features if anyone is interested in testing/critiquing. I'd be especially interested if someone knew how to speed up the updating of the listview since with more than a few hundred strings it will lag noticeably.
Hi, this may be a similar script [Link] you may be interested.

Two idea may be consider (IIRC the detail...):
1. the search box onChange has a idle delay time before doing actual search, this help responsive;
2. I break down each items' string into [words], pattern ''%u%l*' then '%a+', then index [words] (or its hash which I use soundex, case-insensitive and allow spelling error) with an array/dict that insert/store the items's uid (in my case the array index of original item-list, for your case, it could be the address, which can later retrieve the actual string ).
So when user type some words, I can only look for the part of items contain such words.
In my case I also rank the contained items with how many hit(how many words user typed match the item's string) , so more relevant item appear first.

ADDED:
You may need modification of the idea, as I would search like '%d' "%f" etc. to look for debug string, but [words] thing won't include such pattern.

Hope the description is not too messy and be helpful in some way.

bye~

aSwedishMagyar
Table Makers
Table Makers
Posts: 670
Joined: Mon Jul 06, 2020 3:19 am
Reputation: 1190

Re: String Reference Viewer [WIP]

Post by aSwedishMagyar »

panraven wrote:
Sat Aug 14, 2021 12:03 pm
ADDED:
You may need modification of the idea, as I would search like '%d' "%f" etc. to look for debug string, but [words] thing won't include such pattern.

Hope the description is not too messy and be helpful in some way.

bye~
Howdy, thanks for the idea! I think I manged to fix it by converting each string into a byte table and then back into a hex string which I use the :find() function on. So far it seems to work properly. Could you give it a test and let me know?

panraven
Table Makers
Table Makers
Posts: 121
Joined: Fri Mar 03, 2017 12:03 am
Reputation: 108

Re: String Reference Viewer [WIP]

Post by panraven »

Hi,
I test it with Steam Tap Adventure Time Travel
dissect the main exe module , which has 14861 referenced string, with total string bytes size of 340505.
before testing the actual ui function, I extract your code for string comparison for benchmarking, which I suspect is source of lag.
The difference between new and previous version is the conversion made, where previous just use :lower() while new version use
:lower -> stringToByteTable -> char-to-hex, this benchmark result to found a random string of 6 bytes size.
new version
0.1730000000025 sec
prev version
0.010000000002037 sec
It show similar scale with 100x multiple loop.


In actual testing the ui, I first input '~' , both version show result almost instantly, but prev version show 1 result, while the new version show many more result, 1 result match prev version, others all random bytes.
Newer version probably has some bug?

Next I test 'c' which suppose match many result, new version show result instantly, prev version lag.
With above benchmark, the string comparison, even with 10x more string, seems not the bottleneck, onData seems do help .

Next I test 'content' typing char one by one SLOWLY,
in new version it refresh result fast enough not consider lag as I type each char,
in prev version 'c' show longest lag, 'co' show lag but shorter, and shorter and shorter as I type more char.

Then I copy 'content', clear the search box in prev version, then paste the 'content' into it, it show result instantly .

It seems to me, the lag in prev version is caused by how sending result to the list ui, which onData help.

The new version seems no need further optimize.

That's it.
Bye~

aSwedishMagyar
Table Makers
Table Makers
Posts: 670
Joined: Mon Jul 06, 2020 3:19 am
Reputation: 1190

Re: String Reference Viewer [WIP]

Post by aSwedishMagyar »

panraven wrote:
Sun Aug 15, 2021 2:04 am
Hi,
I test it with Steam Tap Adventure Time Travel
dissect the main exe module , which has 14861 referenced string, with total string bytes size of 340505.
before testing the actual ui function, I extract your code for string comparison for benchmarking, which I suspect is source of lag.
The difference between new and previous version is the conversion made, where previous just use :lower() while new version use
:lower -> stringToByteTable -> char-to-hex, this benchmark result to found a random string of 6 bytes size.
new version
0.1730000000025 sec
prev version
0.010000000002037 sec
It show similar scale with 100x multiple loop.
Okay so I got around this (I think) by making three tables which hold all values, one for uppercase, one for lowercase and one that has both the address and normal string in it. Should be just as fast as the regular string.find now.
panraven wrote:
Sun Aug 15, 2021 2:04 am
In actual testing the ui, I first input '~' , both version show result almost instantly, but prev version show 1 result, while the new version show many more result, 1 result match prev version, others all random bytes.
Newer version probably has some bug?
I realized as soon as you posted this that I wasn't spacing the hex representation out so it would be able to detect 'fake' characters that weren't even in the regular string. I fixed this by just adding a space between them in the convertToHexString() function.

Thanks for taking the time to test and give feedback!

panraven
Table Makers
Table Makers
Posts: 121
Joined: Fri Mar 03, 2017 12:03 am
Reputation: 108

Re: String Reference Viewer [WIP]

Post by panraven »

line 21:

Code: Select all

        local lowerBT = stringToByteTable(v:lower())
        local upperBT = stringToByteTable(v:lower())
        lowerList[j] = convertToHexString(lowerBT)
        upperList[j] = convertToHexString(lowerBT)
both lower?

aSwedishMagyar
Table Makers
Table Makers
Posts: 670
Joined: Mon Jul 06, 2020 3:19 am
Reputation: 1190

Re: String Reference Viewer [WIP]

Post by aSwedishMagyar »

panraven wrote:
Sun Aug 15, 2021 5:24 am
line 21:

Code: Select all

        local lowerBT = stringToByteTable(v:lower())
        local upperBT = stringToByteTable(v:lower())
        lowerList[j] = convertToHexString(lowerBT)
        upperList[j] = convertToHexString(lowerBT)
both lower?
Fixed, sorry about that. Was excited that the spaces worked for the convertToHexString so I wasn't paying attention to that part.

Hold on I don't know what I was going for here. There only needs to be a lowercase list. Let me revise it real quick.

gideon25
Table Makers
Table Makers
Posts: 1389
Joined: Mon Mar 20, 2017 1:42 am
Reputation: 2288

Re: String Reference Viewer [WIP]

Post by gideon25 »

Hi, The table works fine, but when I use the Lua script (put in the autorun folder) Cheat engine refuses to run dissect code when I choose view referenced strings.. Also when you get it all fixed up can you have it add a button to the memory view window instead of the Main window? Actually, eventually it would be even better to add it to the View dropdown menu in the memory viewer just under referenced strings (but not sure you can do that with a lua script?). Anyway looks cool.

Post Reply

Who is online

Users browsing this forum: 99parklife