|
Is there any Windows API function to determine the dependent DLLs of an application or a DLL?
Arash Sabet
Computer Engineer
E-mail: afifi@sympatico.ca
|
|
|
|
|
No, you'd have to roll your own. It's a matter of parsing through the import tables of the file. There are utilities in place for this already, however. One of them, Depends, ships with Visual Studio.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
So, isn't there any function or method to parse the import table? I have to load the dependent DLLs dynamically through my application. I have no more options to use the utilities? I appreciate it if you have more info.
Regards
Arash Sabet
Computer Engineer
E-mail: afifi@sympatico.ca
|
|
|
|
|
Arash Sabet wrote:
So, isn't there any function or method to parse the import table?
No, you'd have to make your own.
Arash Sabet wrote:
I have to load the dependent DLLs dynamically through my application.
Why can't you just let the DLL/EXE load its own?
Arash Sabet wrote:
I have no more options to use the utilities?
Don't know what you mean by this.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
My question is that whether there any API function in VC++ or C# or... to parse the import table? What's the clean way to parse the impprt table?
thanks.
Arash Sabet
Computer Engineer
E-mail: afifi@sympatico.ca
|
|
|
|
|
Arash Sabet wrote:
My question is that whether there any API function in VC++ or C# or... to parse the import table?
As I've already indicated, there is nothing built-in. You'd have to roll your own.
Arash Sabet wrote:
What's the clean way to parse the impprt table?
Knowing the layout of the PE file format is very helpful.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks David,
Just my final query:
Are the DLLs that are loaded dynamically by AfxLoadLibrary(..) function included in the PE?
Arash Sabet
Computer Engineer
E-mail: afifi@sympatico.ca
|
|
|
|
|
No, only libraries that are implicitly linked are stored in the import table.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
|
I'm having a really strange problem with one of my classes.
Upon destruction visual c reports damage.
I installed a trial of purify and it catches the damage during constructor...
its when a member boolean variable gets assigned to false????
How is that possible?
I'm certain its not the fault of the classes because I can replicate it even without calling any member functions. The damage occurs immediately in the constructor of which there are only two lines (both of which assign member variables to defaults).
If I remove the assignments from the constructor purify detects no problems.
The only thing I can think of is its something to do with the class being derived from a class which uses multiple inheritence. Are there any documented bugs relating to this?
I found one related article on MSDN[^] but the solution didn't help
Here is a replica of my structure:
.----------.
|CObject |
| |
·^---------·
|
|
.^---------. .----------.
|Class A | |Class B |
| | | |
·-------^--· ·^---------·
| |
| |
| |
| .^---------.
| |Class C |
| | |
| ^----------·
| |
| |
.^-------^-----.
|Class D |
| |
·^-------------·
|
|
|
.^-------------.
|Class E |
| |
·--------------·
The problem occurs in class E.
--
The Obliterator
|
|
|
|
|
Probably not a bug in the compiler.
Usually problems like this are the result of header files not matching the code that is being pulled in from a library--like the header files have been updated and the library not recompiled, or building with debug on and linking with non-debug libraries.
|
|
|
|
|
I'm using Visual C++ 6.0
I'm trying to creat a small Inventory program to keep track of my CD sales
First I want to create a file called cd1.txt and be able to update it with the following:
Total Onhand
60
Then each time someone clicks on the OnRadio1 substract from the Total OnHand.
Total Ordered
10
Total OnHand
50
Once the Total OnHand gets below 20 dislpay a message box to tell me to I need to update the cd1.txt file. I should then be able to add to total OnHand
for a new total.
This is what I have so far. And It doesn't seem to work. Could someone get me started on the right track?
void CCdInventoryDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
FILE*cd1;
char buffer[81];
int i,ch ;
cd1 = fopen("cd1.txt","a+"); //create cd1 text file
ch = fgetc(cd1);
for(i=0; (i < 80) && ( feof(cd1) == 0); i++)
{
buffer[i] = (char)ch;
ch = fgetc( cd1 );
}
/* Add null to end string */
buffer[i] = '\0';
fprintf(cd1, "%d", buffer );
fclose( cd1 );
}
|
|
|
|
|
Not to sound rude but why do you want to use a text file? I would suggest that you either use an .ini file or store those three entries in the registry. That way, you won't have to worry about reading from a text file, parsing the strings, checking for errors, updating them etc.
mike.beck wrote:
And It doesn't seem to work
What is it that doesn't work? In your fprintf statement, you are trying %d and that works for decimals. You might not be printing what you want to print.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
Hi Toni78,
It doesn't sound rude... I just need to create a simple inventory program for my cd's....And I guess I really don't know what to do....
|
|
|
|
|
As I said earlier, you can use an ini file or the registry. Check MSDN for references because it will be very helpful.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
If you could settle for an INI file in the following format, it'd be much simpler:
[Inventory]
TotalOrdered=10
TotalOnHand=50
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
If you are not well versed in INI files, take a look at
CWinApp::WriteProfileString();
CWinApp::WriteProfileInt();
CWinApp::GetProfileString();
CWinApp::GetProfileInt();
Peter Molnar
|
|
|
|
|
Is there any way in C# or other languages to detect the dependent DLLs of an existing non-DotNET DLL (regular DLL)? For i.e. if XXXX.DLL is using AA.DLL and BB.DLL, the last two DLLs are detected by the small piece of code after passing XXXX.DLL name.
Thank you.
Arash Sabet
Computer Engineer
E-mail: afifi@sympatico.ca
|
|
|
|
|
You can analyze dependency list by reading import table from PE file.
Matt Pietrek had an article and source in MSJournal, Feb 1997.
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
I just tried to build a simple program like Hello.cpp by using Visual C++. NET but I got errors for Linking problem. Anyone has any idea how to set it up correctly?
|
|
|
|
|
What kind of liking problems did you get?
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
When i pressed build and it gave me this error
error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup
fatal error LNK1120: 1 unresolved externals
this is my code
#include <iostream>
using std::cout;
using std::endl;
int main()
{
cout << "Hello" << endl;
return 0;
}
|
|
|
|
|
This link error is occuring because your compiler/linker settings are expecting WinMain(...) as the entry function, not main(). This occurred when creating the project.
You can get the above code to compile by manually setting the compiler/linker settings:
- Make sure your "Solution Explorer is visible" ( View | Solution Explorer)
- Right click on project (**not the solution**) node in Solution Explorer tree view and select properties
- Click on C/C++ | Preprocessor. On the right hand side you will see "Preproccesor Definitions".
- Replace _WINDOWS with _CONSOLE (NOTE the underscore)
- Now, click on Linker | System. Click on the "Subsystem" on the right. Once the Subsystem line is active and drop down arrow appears to the far right. Click on that and you will see a list of choices. You want to change the "Windows (/SUBSYSTEM:WINDOWS)" to "Console (/SUBSYSTEM:CONSOLE)".
- Compile. Should work. Now "int main()" is the expected entry function.
The above can all be avoided by selecting a "Win32 Console Project" instead of a "Win32 Project" when you create a new project.
And by the way, I am assuming your iostream header was included and was clipped from your code above because the "< >" was treated as an HTML tag in the post.
Mike
|
|
|
|
|
Thanks Mike...i solved my problems by choosing Console Project.
|
|
|
|
|
Hi!
I am looking for a C++ compiler for AMD64 platform, preferrably a free version!
Does GNU GCC work for me? They do not explicitly say that it produce AMD x86-64 code!
Thanks in advance!
Rob
|
|
|
|