Search for a string in a collection of dlls - dll

We have a number of dlls in a single directory. Most, but not all, are C++ resource dlls only. These dlls can be opened in Visual Studio for a "visual" inspection (you can see the "String Table").
Here's the scenario, we are looking for a particular string but we don't which DLL contains the string. Is there a tool that we can use that will perform a string search on DLLs?
Thanks!

You can use the findstr command to search strings in several files.

I've just successfully used .NET Reflector 6 to find a string (using Ctrl+S) in the list of loaded DLLs.
Slightly off for the original question (concerning C++) but I've stumbled upon this question by the title and this is my answer.

Related

Migrating a string table (binary .res file) from VB6 to VB.NET

I have to port an old VB6 program to VB.NET and stumbled across an old ".res" (Resource) file, which is stored in binary format. Using VS 2013, I can embed that file into my .NET project, and VS shows me that it contains simply a string table.
The problem is, I cannnot figure out how to bring those res file into a more modern text format, or how to load the strings directly from the res file. I linked file to my application es an embedded resource, but all my atttempts to use VB6.LoadResString from the "Visual Basic Compatibility library" lead to an exception, showing the key was not found.
Furthermore, it seems VS does not allow me to copy/paste the string table into a text file, at least, not at a whole. Actually, it allows me to copy/paste one string after another, but as you can imagine, that is extremely cumbersome and error-prone. That is why I am looking for a better solution. Any ideas?
There is a functional VB6 Class for doing this at:
ResDecomp Class Decompiles RES Files
Sample programs are included, one of them a sort of "viewer" and the other just extracts RT_STRING resource strings to an XML document. You could easily change the latter to dump the string values to a text file, database, etc. instead.
Embed the .res file to a simple VB6 program which loops from min to the max ID and write out the strings to a text file using LoadResString (error trap for missing IDs).

How can I find the binary which defines a COM object or interface with a given GUID?

(Note: Names and GUID have been changed from original values)
While debugging an application, I found that a likely culprit for a bug I had was in a library my application was linking with, in the function
pAgent->raw_Open()
agent is declared in our C++ code as
XX::IAgentPtr pAgent
All Visual Studio can tell me about IAgentPtr is that its type is
_com_ptr_t<_com_IIID<XX::IAgent,&_GUID_deadbeef_1234_1234_1234_1234deadbeef> >
And my debugger cannot step into the code of agent->raw_Open() to see what's going on. I'd like to know which DLL defines XX:IAgent, as I may be able to get debugging information or source code for that DLL.
I've figured out that IAgent is a COM interface, and through searching elsewhere, I found that I might be able to find the location of the DLL file by looking in the registry (HKEY_CLASSES_ROOT\CLSID\{guid}). However, I could not find the GUID I'm looking for there.
How might I find the DLL that contains the definition for IAgent given that I know IAgent's GUID?
(Note: Although they have similar titles, this question is not a duplicate of this question, as the asker of the linked question knows the DLL which defines the interface with the GUID)
A program that can search through binary files to find plain text data will work.
I used Windows Grep and searched all DLL files for "deadbeef-1234-1234-1234-1234deadbeef" and found the DLL which defined IAgent.
However, there is a better way to find this information. HKEY_CLASSES_ROOT\CLSID\ has subkeys for objects, but IAgent is an interface. If you know the GUID of the interface, you can look in HKEY_CLASSES_ROOT\Interface\{guid}. There, if you find a key TypeLib, the default value is a GUID that you can find in HKEY_CLASSES_ROOT\TypeLib, and from there you can find the path to the dll. If that isn't there, the default value in a key called ProxyStubClsid or ProxyStubClsid32 is a GUID that can be found in HKEY_CLASSES_ROOT\CLSID.

Error when trying to zip files VB.NET 2003

I have to make a simple zip file using Visual Studio and VB.NET 2003.
After some googling I got to this page: http://www.digioz.com/tutorials/zip_unzip_vbNET/Zip_and_Unzip_VB_NET_1.html wich basically provides me 3 DLLs with classes that are ready to zip files.
When I try to create an instance of the class like the tutorial tells me to:
Dim zp As New CGZipLibrary.CGZipFiles
I get this error:
COM object with CLSID {293364BA-43F8-11D3-BC2D-4000000A2806} is either not valid or not registered.
Ideas?
If anybody got a better/easier approach to zip files using VB.NET 2003 it would be helpful too.
Thanks.
EDIT:
Thanks for all who answered, but I've used a different approach than the suggested ones to zip my files.
I used the Shell function of the Microsoft.VisualBasic.Interaction class like this:
Shell("zip -j " & fileName, AppWinStyle.Hide, True)
Thanks again for those who dedicated their time trying to help me!
It looks like that library you are trying to use is an old COM dll. That means you have to register the dll first using regsvr32.exe before you can use it. However, I would recommend using a native .NET (managed) library. Unless it doesn't meet your needs, I'd simply recommend looking at the GZipStream class which is part of the .NET framework.
Have you tried this one? This is pretty good: ionic.zip.reduced, a dotnetzip library.
Example:
Using zip As ZipFile = New ZipFile()
zip.AddFile("c:\photos\personal\7440-N49th.png")
zip.AddFile("c:\Desktop\2008_Annual_Report.pdf")
zip.AddFile("ReadMe.txt")
zip.Save("MyZipFile.zip")
End Using
More VB.NET examples of Ionic.ZIP
UPDATE:
Your problem is that VS2003 can't use the targeting of the dll which was created in a newer (eg. VS2005) version of VS. For many have tried to use that, a tool was created which you can download here. For more information, visit this site.
Another option that I use in most of my projects is #ZipLib (SharpZipLib), downloads available here:
http://www.icsharpcode.net/opensource/sharpziplib/Download.aspx
Documentation and samples for both VB and C# are available at the same site. It has specific binary assemblies (dll) for .NET framework 1.1, as well as later versions. It's likely that some of the other libraries that you're run across are compiled for .NET 2.0 or later, which won't work in VS2003.
Don't let the name fool you -- it's written in C# (hence the name) but the compiled assemblies work just fine in VB.NET. It supports Zip, GZip, tar, and BZip2 archives.

what language is dotnet executable written in?

I thought it would be Common Intermediate Language, but in notepad it does not look like that at all. Does it just look uglier in reality than in tutorials? Or is it some bytecode form that is further compiled from CIL?
It's CIL is the name of the binary format, not of the "assembler" you're thinking of.
Can you possibly imagine that .NET assemblies would be text files?
A .NET executable is a binary file that has a PE header (same as a native executable, but with slightly different values). The PE header tells the OS to load the CLR, which in turn loads the assembly.
The content beyond the header is a binary representation of the CIL code, plus some metadata and other stuff. The text you see in tutorials is the text representation of CIL, in much the same way that the assembly language code you see in a tutorial about assembly language programming is just the text representation of the binary machine code.
See http://www.yetanotherchris.me/home/2010/7/12/inside-net-assemblies-part-1.html (among many others) for more information.
A .Net executable is usually not written, it is compiled from another language such as C#, F# or VB.Net.
The contents of a .Net executable can be viewed with the ILDASM tool.
The contents are first a manifest which is used for reflection, signatures or other meta-code purposes.
Secondly there are the MSIL instructions themselves. These are in a kind of bytecode format, but ILDASM will show you what the instructions are.
And there are sometimes resources such as imagery, sounds or other content packed into the executable.
The executable is just-in-time compiled to native code either during installation (I think this is uncommon), or as a precursor to execution. The resulting native code can be stored for reuse. (This is what I was told during PDC 2001, might be "out of date".)

Finding embedded DLL resources

I'm using a decompiler to look at a DLL I built a while ago because I don't have the original source anymore. I want to see what a specfic value for a resource string is, but I can't seem to find them. I embedded the resource file, so I figured I could just decompile the DLL and see the string, but it isn't anywhere to be found. Any place I should be checking or is this not possible?
Ended up using Reflector and saw what I needed.
Would a tool like XN Resource Editor work for you?