Results 1 to 12 of 12

Thread: [RESOLVED] Extracting a string from a DLL

  1. #1

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Resolved [RESOLVED] Extracting a string from a DLL

    Does anyone know of a way that you can get the string that is held at this reference point (its the contents of a registry value that corresponds to a string - see this thread for more info http://www.vbforums.com/showthread.php?t=617477):
    Code:
    @%Systemroot%\system32\wbem\wmisvc.dll,-204
    I think I've seen C# (or maybe C++) code use lines like this but I cant find any way of getting the value from the DLL in VB.NET

    Cheers
    Chris
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  2. #2
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Extracting a string from a DLL

    Try using IO.File.ReadAllText("%SystemRoot%\system32\wbem\wmisvc.dll") and find the string manually, then try to find its relation with -204. I don't understand what the - sign is for (how do you get a negative resource? is it because the sign bit is set and it's actually at position (Not 204) - 1?)

  3. #3

    Re: Extracting a string from a DLL

    A bit of googling (supposedly) tells me that's the WMI DLL. I tried utilizing Rundll32 and I got this:

    Code:
    ---------------------------
    RUNDLL
    ---------------------------
    Error in E:\WINDOWS\system32\wbem\wmisvc.dll
    Missing entry:-204
    ---------------------------
    OK   
    ---------------------------
    Removing the negative does the same thing. Do you know what the string you're looking for actually is? You might be able to use ResHack to look at it...

  4. #4
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Extracting a string from a DLL

    Quote Originally Posted by minitech View Post
    Try using IO.File.ReadAllText("%SystemRoot%\system32\wbem\wmisvc.dll") and find the string manually, then try to find its relation with -204. I don't understand what the - sign is for (how do you get a negative resource? is it because the sign bit is set and it's actually at position (Not 204) - 1?)
    A DLL is basically an executable, with the exception of an entry point. So you can't just ReadAllText like you would a text file.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  5. #5
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Extracting a string from a DLL

    I know that If you look inside an EXE using Notepad, you'll see that the strings are in the format:
    Hello World
    =
    H(NUL)e(NUL)l(NUL)o(NUL) and so on. Try it!

  6. #6
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Extracting a string from a DLL

    Quote Originally Posted by minitech View Post
    I know that If you look inside an EXE using Notepad, you'll see that the strings are in the format:
    Hello World
    =
    H(NUL)e(NUL)l(NUL)o(NUL) and so on. Try it!
    That's not necessarily true. Maye so with a .NET app, but even still, I don't think you could just ReadAllText.

    I just attempted to use that method with the .DLL Chris is trying to work with, and I got nothing.

    I opened the .DLL in notepad, I saw very few comprehensible pieces of text. Nothing of which, pertained to what Chris is trying to grab

    But... I could be wrong
    Last edited by weirddemon; Jun 7th, 2010 at 10:45 PM.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  7. #7
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Extracting a string from a DLL

    Really? I got (the attached file)
    ... and much more. Lots of readable stuff there that could be very valuable.
    Attached Files Attached Files

  8. #8
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Extracting a string from a DLL

    Quote Originally Posted by minitech View Post
    Really? I got (the attached file)
    ... and much more. Lots of readable stuff there that could be very valuable.
    I thought we were talking about the .DLL that Chris is referring to? If so, the attached file is what I got.

    Also, have you tried using ReadAllText on one?

    I got this when trying to read the aforementioned .DLL:

    MZ�
    Attached Files Attached Files
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  9. #9

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Extracting a string from a DLL

    Quote Originally Posted by formlesstree4 View Post
    A bit of googling (supposedly) tells me that's the WMI DLL. I tried utilizing Rundll32 and I got this:
    I dont think you can use RunDll to extract things from a DLL as thats for actually running methods from a DLL, maybe there is some way you can use it for that though I dunno.

    As for using ReadAllText, I was hoping that there would just be some way to pass this "address" straight to a method or some keyword and it would return the string, rather than having to try and parse the file manually. Perhaps there is a Windows API that will do it but I'm finding it hard to get any good search results on google as I think google takes out the @ symbol..
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  10. #10

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Extracting a string from a DLL

    Aha I think I may have found something and it looks like this person wrote it for the exact same reason I'm trying to do it http://www.planetsourcecode.com/URLS...10/anyname.htm

    http://msdn.microsoft.com/en-us/libr...86(VS.85).aspx
    Last edited by chris128; Jun 8th, 2010 at 03:23 AM.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  11. #11

    Thread Starter
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Extracting a string from a DLL

    Hmm well there's a few issues with that code, but it was certainly helpful so I've now got my own version working. For anyone interested, here's the code (needs some error handling adding):

    vb Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         MessageBox.Show(GetResourceString("@%Systemroot%\system32\wbem\wmisvc.dll,-204"))
    3. End Sub
    4.  
    5. Private Function GetResourceString(ByVal ResourcePath As String) As String
    6.         Dim SeparatedString() As String = ResourcePath.Split(","c)
    7.         Dim ModuleHandle As IntPtr = ApiDefinitions.LoadLibrary(Environment.ExpandEnvironmentVariables(SeparatedString(0).Replace("@", "")))
    8.         Dim SB As New StringBuilder(1024) 'not ideal but cant find a way of pre-determining the string length
    9.         ApiDefinitions.LoadString(ModuleHandle, CUInt(SeparatedString(1).Replace("-", "")), SB, SB.Capacity + 1)
    10.         ApiDefinitions.FreeLibrary(ModuleHandle)
    11.         Return SB.ToString
    12. End Function
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  12. #12
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Extracting a string from a DLL

    Quote Originally Posted by weirddemon View Post
    I thought we were talking about the .DLL that Chris is referring to? If so, the attached file is what I got.

    Also, have you tried using ReadAllText on one?

    I got this when trying to read the aforementioned .DLL:
    No, I haven't, but I asked you to open it in Notepad. And that is my version of the DLL Chris is referring to. I'm on XP, remember?

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