Results 1 to 7 of 7

Thread: String Identifiers ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2022
    Posts
    98

    String Identifiers ?

    Hi,

    Using the LoadString api I can get a string resource from the executable file associated with a specified module.

    But where\how can I find the list of all the identifier constants ? (such as OK_CAPTION = 800 for the user32.dll)

    Is there a programmatic way or a tool available ? I tried Resource Hacker but they are not shown there.

    Thanks.

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    3,499

    Re: String Identifiers ?

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2022
    Posts
    98

    Re: String Identifiers ?

    Quote Originally Posted by Zvoni View Post
    Thanks Zvoni but the api viewer doesn't contain resource string IDs\Constants as these are specific to exes and dlls .

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2022
    Posts
    98

    Re: String Identifiers ?

    Code:
    Option Explicit
    
    Declare Function LoadString Lib "user32" Alias "LoadStringW" ( _
        ByVal hInstance As Long, _
        ByVal wID As Long, _
        ByVal lpBuffer As Long, _
        ByVal nBufferMax As Long _
    ) As Long
    
    Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleW" ( _
        ByVal lpModuleName As String _
    ) As Long
    
    
    Sub Test()
        Dim hModule As Long
        Dim sLen As Long
        Dim Buffer As String
        Dim Index As Long
        Buffer = Space(1024)
        
        hModule = GetModuleHandle(StrConv("user32", vbUnicode))
        If hModule Then
            For Index = 1 To 10000
                sLen = LoadString(hModule, Index, StrPtr(Buffer), 1024)
                If sLen Then
                    Debug.Print "[Index]:" & Index, , "[String Resource]:" & Left(Buffer, CLng(sLen))
                End If
            Next
        End If
    End Sub
    The above code snippet does list the user32 dll local resource strings by iterating them.

    The problem is I only figured out by trial & error that 10000 is the aproximate number of iterations that need to be performed to scan the entire list of reource strings. Last string index being 8743.

    Is there a way to know how many resource string entries there are prior to running the For\Next loop ?

    Thanks.

  5. #5
    Fanatic Member
    Join Date
    Jun 2015
    Posts
    813

    Re: String Identifiers ?


  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jun 2022
    Posts
    98

    Re: String Identifiers ?

    Quote Originally Posted by dz32 View Post
    Thanks dz32 but those functions enumerate resources, Not entries within a given resouce .

    I am looking after a count of entries within a given resource.

  7. #7
    Fanatic Member
    Join Date
    Jun 2015
    Posts
    813

    Re: String Identifiers ?

    humm seems like one would have been for enumerating the individual entries

    anyway, that reminds me you can "just" walk the PE file format to get them all

    https://github.com/dzzie/libs/blob/m...ources.cls#L58

    there is an example project in the /demo folder that has a resource viewer form

    Code:
    Sub ShowResources(pe As CPEEditor)
        
        Dim r As CResData
        Dim li As ListItem
        
        For Each r In pe.Resources.Entries
            Set li = lv.ListItems.Add(, , r.path)
            Set li.Tag = r
        Next
        
    End Sub
    Edit: just reread your post. if you just after the identifiers to number mapping and not enumerating the resources themselves, those would only be in the source/header files for those libraries. They donít get compiled in.
    Last edited by dz32; Oct 7th, 2022 at 08:05 AM.

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