CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    May 2002
    Location
    Somewhere over the rainbow
    Posts
    423

    Post String References

    hi all,
    i am trying to doa little app which will read an EXE file and look at the ".text" section for all strings references the progeam uses.
    i mean,i want to display all strings that it uses, but the thing is that when u read from an exe file u acn't determine the lenght of the string becuz u read it like a vector of bytes, i.e:
    sd Hello World @#$df which in hex its: 73 64 20 48 65 6C 6C 6F 20 57 6F 72 6C 64 20 20 40 23 24 64 66

    my app need to display "Hello World" and not the garbage before, also note some string can come after the "hello world" which i need to display as well.
    i hope u can help me figure it out, thnx
    ben
    Bengi

  2. #2
    Join Date
    Oct 2001
    Location
    Dublin, Eire
    Posts
    880
    I don't think there is a way. The best is probably to "guess" what a string is: It is a succession of at least N letters, numbers and spaces. It will very rarely happen than plain binary code will contain, say, more than 5 letters in a row.

    Once you get that, may be you can accept a few more isolated characters included in a string (there is letters, numbers and spaces before and after). Some characters like #,=,.... And then you also need to include punctuation (.,,,?,!, ...).

    I guess you have to write your own rules and try them to see if you get a good result.

    Whatever happen, it will never be perfect, and you will probably miss a few strings (if they are just a short word), cut some other in two strings (if they contain some special characters) and include one or two pieces of binary code.

    I'd be interested if you have a better solution.

    If you want to improve the result, you can also use a dictionnary, the only problem with this being that some strings may contains special word (like the program name) that will not be in any dictionnary.
    Last edited by Elrond; July 9th, 2002 at 06:38 AM.
    Elrond
    A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
    -- George Steiner

  3. #3
    Join Date
    May 2002
    Location
    Somewhere over the rainbow
    Posts
    423

    Post hm..

    check Win32Dasm app, it gives Perfec String References, thats how i try to do it.
    yeah i know about the missing words, than how win32dasm do it?...weird indeed
    anybody with some sulotions??
    Bengi

  4. #4
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    There is a Unix utility call strings that prints out all printable strings. There might be a windows version that will do the same thing.
    Succinct is verbose for terse

  5. #5
    Join Date
    Apr 1999
    Location
    Altrincham, England
    Posts
    4,470
    I remember that - I used it once to find the wizard password in Rogue. It was the only to complete the blasted game!
    Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
    --
    Sutter and Alexandrescu, C++ Coding Standards

    Programs must be written for people to read, and only incidentally for machines to execute.

    --
    Harold Abelson and Gerald Jay Sussman

    The cheapest, fastest and most reliable components of a computer system are those that aren't there.
    -- Gordon Bell


  6. #6
    Join Date
    May 2002
    Location
    Somewhere over the rainbow
    Posts
    423

    heh

    hhe, but i still need to code such string finder er..
    Bengi

  7. #7
    Join Date
    Mar 2002
    Location
    California
    Posts
    1,582
    Graham,

    Rogue? Boy you must be old. All us modern people played nethack. Superior graphics, better sound. It's almost like your there!

    Jeff

  8. #8
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    nethack didn't have sound when I played it. It had the kitchen sink though.

    I still play rogue and advnture (PC version).
    Succinct is verbose for terse

  9. #9
    Join Date
    Mar 2002
    Location
    California
    Posts
    1,582
    Actually, I was thinking of Angband or ZAngband, a Nethack derivative, which has very primitive, repetetive, annoying sounds. Regardless, I was poking fun at those ridiculously addicting games.

    Jeff

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured