Page 1 of 1

Enumerate all strings in your program

Posted: Fri Jun 03, 2005 2:09 pm
by Tommeh
Code updated For 5.20+

Ok, i have just been fiddling around with asm just seeing what there is.

I found a way that lists all strings in your program with just a few lines of code.

If a string is done something like: For n = 1 to 10 : n$ + "h" : next n then it won't work but here is the code:

Code: Select all

String$ = "hello"
String$ = "world"
Message$ = "Hello"
Message$ = "in"

Goto EnumerateStrings

channel$ = "#purebasic!"

End


EnumerateStrings:

!MOV    edx,_S1
!MOV    edx,dword _S1
!MOV    [v_value],edx

If PeekS(value) = ""
  Debug "Strings have not been initiated yet!"
  End
EndIf

Repeat
  Debug CString$
  CString$ = PeekS(value + totallen)
  totallen + Len(CString$) + 1
Until CString$ = Chr(255)+Chr(255)+Chr(255)+Chr(255)
If you change the last line to Until 1 = 2 then it keeps going and starts getting strings from the pbcompiler or something, very strange :s

EDIT: Ahh Fred said it was because the debugger adds a lot of stuff, thats why you get all the extra stuff if you let it keep going :-)