|
Hey Folks,
Does anybody know of a way of determining which DLLs an EXE depends on pragmatically? Tools like Dependancy Walker work great, but I'm in the process of writing an About->File Info dialog, which lists all the DLLs/Versions. I could easily hardcode these values, but would much prefer to do it pragmatically, rather than updating the static list when the list changes.
Was leafing through a few development magazines recently, saw various references to CP, good to see
Thanks.
Mike.
doner@obtain.com
|
|
|
|
|
If you want functionality like Dependency Walker, you would have to read the PE header of the executable and locate the imports table. It lists the various modules the EXE depends on along with the functions from the modules that are needed. I can't say specifically where you can get that info but I've come across it on several occassions in the past.
There was an overview of the PE executable format in a recent MSDN magazine.
http://msdn.microsoft.com/msdnmag/issues/02/02/PE/PE.asp
Another approach is to examine the moudules that are currently in use. You can use the toolhelp32 functions for that. Basically you would create a snapshot with CreateToolhelp32Snapshot to get a snapshot of the modules in use by the process. Then call Module32First and successviely call Module32Next to get info about each module used by the process. Don't forget to call CloseHandle on the snapshot's handle when done.
|
|
|
|
|
Thanks for the info, great article to read... Managed to get it working!
Mike.
|
|
|
|
|
I've also been working in this area, and I found that the techniques used with the demo articals from MSDN (like PEDump, YAHU, etc.) don't cover calls made to a library that was loaded using LoadLibrary. Have you managed to get the export information from LoadLibrary calls? And if so could you give me a brief pointer as to how? (If it's even possible, I dunno...)
Dylan Kenneally
London, UK
|
|
|
|
|
Dylan,
I dont know of any way to determine the dependancies, as far as LoadLibrary goes. I opened up one of my EXE's who does a LoadLibrary() in a hex editor, and by the look of things, the DLL name was in the text area of the exe.
If you stumble across how to do this, let me know
Mike.
Ontario Canada.
|
|
|
|
|
Hi!
I have a win2000 service written in visual c++ 6.0 that has to access files from a shared folder from the local network neighborhood.
The shared folders are password protected, so I have to create a connection to that folder. I tried to use WNetAddConnection2.
But WNetAddConnection2 fails and returns the error code no. 1312.
I looked it up in the winapi headers, error 1312 is called ERROR_NO_SUCH_LOGON_SESSION, the explanation given is :
'A specified logon session does not exist. It may already have
been terminated.'.
The list of files/locations is taken from a database, so is dynamically changing over time.
Has anybody any idea how could I access files shared on other computers without logging in to the system?
Thanks, Alma
|
|
|
|
|
The solution i found is to use the CreateService function with user and password parameters set.
Ex:
--------------------------------------------------------------------------------
CString user = _T(".\\User");
CString pswd = _T("pswd");
LPSTR u = user.GetBuffer(user.GetLength()+1);
LPSTR p = pswd.GetBuffer(pswd.GetLength()+1);
SC_HANDLE hService = ::CreateService(
hSCM, m_szServiceName, m_szServiceName,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
szFilePath, NULL, NULL, _T("RPCSS\0"), u, p);
--------------------------------------------------------------------------------
To create the connection:
--------------------------------------------------------------------------------
NETRESOURCE nr;
char* a = new char[MAX_PATH];
memset(a, 0, MAX_PATH);
char* b = new char[MAX_PATH];
memset(b, 0, MAX_PATH);
strcpy(a, (char*)"\\\\alma\\geza");
strcpy(b,(char*)"x:");
char pswd[20] = "pswd";
char account[20] = "user";
nr.lpRemoteName = a;
nr.lpLocalName = b;
nr.lpProvider = NULL;
nr.dwType = RESOURCETYPE_DISK;
DWORD flags = CONNECT_UPDATE_PROFILE;
DWORD res;
res = WNetAddConnection2(&nr, (char*)pswd, (char*)account, flags);
delete []a;
delete []b;
if (res == NO_ERROR)
return TRUE;
else
return FALSE;
|
|
|
|
|
I have the following:
typedef std::list<CMyObject*> myObjectList
The list is populated and is already in alphabetic order by name.
Each item can be either selected or unselected. I want to bubble the selected items to the top of the list without affecting their relative positions to one another. In other words, I may have the following (Selected items are indicated with the "[]" bracket pair):
A
[B]
C
D
[E]
[F]
I want to end up with this:
[B]
[E]
[F]
A
C
D
What's the best way to do this? Should I just remove each item one at a time (starting at the end of the list) and re-insert it at the top of the list? Is there some exotic list function that I can use?
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
if you want exotic, you could use std::stable_sort with a custom predicate which says that A, C and D are equivalent and that B,E and F are equivalent (but less than A,C,D).
stable_sort preserves the (relative) order of equivalent items.
-c
Being just contaminates the void. --Robyn Hitchcock
|
|
|
|
|
I came up with this, but I have't tried compiling it yet. What do you think?
CMyList::iterator iCurr;
CMyList::iterator iNext;
bool bMovedItem = true;
while (bMovedItem)
{
iCurr = myEntryList.begin();
iNext = iCurr + 1;
bMovedItem = false;
while (iCurr < myEntryList.end())
{
bool currSelected = (*iCurr)->mySelected;
bool nextSelected = (*iNext)->mySelected
if (!currSelected && currSelected != nextSelected)
{
myEntryList.reverse(iCurr, iNext);
bMovedItem = true;
}
iCurr++;
}
}
I'm certainly no STL expert (more accurately, I'm a rank beginner with a complete disdain for STL - grin).
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
it might work
here's my top-of-the-head STL version:
bool operator < (const CListItem &a, const CListItem &b)
{
return (a.IsSelected && !b.IsSelected);
}
...
std::stable_sort(myList);
-c
Being just contaminates the void. --Robyn Hitchcock
|
|
|
|
|
Personally?
I would dump the list to a text file, exec the COMMAND.COM sort program and then read back in the text file.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
now that's exotic!
or... fire up an instance of Access, shoot the data into a special table, read it back with SQL, then pick the data out of the recordsets!
-c
Being just contaminates the void. --Robyn Hitchcock
|
|
|
|
|
I would try that but we're on CE...
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
One solution would be to use stable_partition. This will reorder the list based on a predicate which returns true or false, without changing the relative order of any of the items in the same grouping.
The following example shows a simple implementation:
#include <iostream>
#include <list>
#include <algorithm>
#include <functional>
void PrintChar( char ch )
{
std::cout << "'" << ch << "'" << std::endl;
}
struct Partition : public std::unary_function< char, bool >
{
bool operator()( char ch )
{
return ( ch == 'B' || ch == 'E' || ch == 'F' );
}
};
int main(int argc, char* argv[])
{
std::list<char> myList;
myList.push_back( 'A' );
myList.push_back( 'B' );
myList.push_back( 'C' );
myList.push_back( 'D' );
myList.push_back( 'E' );
myList.push_back( 'F' );
std::cout << "before:" << std::endl;
std::for_each( myList.begin(), myList.end(), PrintChar );
std::stable_partition( myList.begin(), myList.end(), Partition() );
std::cout << "after:" << std::endl;
std::for_each( myList.begin(), myList.end(), PrintChar );
return 0;
}
Best regards,
John
|
|
|
|
|
I have been taked with creating a TCP/IP file server app that can impliment drag and drop functionality to explorer.
My problm is that the app lists only the file names and attributes, that it is passed without a refrence to the original location. I need to be able to get the target of a drag and drop opperation onto the explorer window, so I can pass that target back to the calling app.
I've spent countless hours trying to figure out how to get the drop target on the drag opperation to explorer without any success.
Any help would be greatly appreciated.
Life is like a warm bath, the longer you're in the more wrinkled you get.
|
|
|
|
|
Is there a way to hook a window (SetWindowsHookEx) without using a DLL. So I can hook CreateWindow, that it doesn't send WM_CREATE before I want it to?
Thanks in advance,
Sjoerd
LPCSTR Dutch = "Double Dutch "
|
|
|
|
|
You only need a DLL if the hook is to be a system wide hook. A hook that is limited to the scope of the current process can keep its code within the application.
Beyond that, I'm not sure that I understand what you are trying to do with WM_CREATE.
|
|
|
|
|
Oliver Daniel wrote:
You only need a DLL if the hook is to be a system wide hook. A hook that is limited to the scope of the current process can keep its code within the application.
Thanks for this
Oliver Daniel wrote:
Beyond that, I'm not sure that I understand what you are trying to do with WM_CREATE.
CreateWindow does automatically send a WM_CREATE. But right under there, I call SetWindowLong, to change te Window proc. There, the WM_CREATE has to be handled. So, if I hook into the process, I can change the Window proc, before WM_CREATE has been sent.
Sjoerd van Leent
LPCSTR Dutch = "Double Dutch "
|
|
|
|
|
I've created a standard server for small LAN apps using class CAsyncSocket(in Visual C++ 6.0). The maximum number of active clients is 1996. Now this is not a problem cause this ain't a Web server but after the clients disconnect themselves (even all) the server doesn't accept ever again clients. This server worked just fine in Windows 98 SE (but restrincting me to 46 clients). In Win 98 i've conneted and disconnected arround of 7000 clients (150 times * 46 maximum allowed active connections) to see if crashes and it didn't happend. So what the hell is wrong with Windows XP ? It was supposed to be Better but ...
If anyone can answer to my question please reply at my email address.
Codu'
|
|
|
|
|
Probably a bug in your software that doesn't show up on the 9x platform. Like I just told someone else, 9x and NT/W2K/XP execute programs very differently. Hidden bugs can crop up when you switch from one platform to another.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi
Does anyone know how can I disable the activation of the screensaver from Visual C++? I tried the SendInput() function to simulate mouse movement but it doesn't work
Please help me
Thankx
Jancsi
xxx
|
|
|
|
|
Look at the SystemParameterInfo function and the SPI_SETSCREENSAVEACTIVE parameter
|
|
|
|
|
Had a type that should be SystemParametersInfo
|
|
|
|
|
How do you get the value of an unnamed key value? In regedit it is diaplayed as "(Default)". I've tried
RegQueryValueEx(hKey,
"(default)", 0, &type,
(unsigned char*)buf, &bufsize)
but it returns 2. I've also tried to RegEnumKey() and it gets the key name ok, but it just refuses to get the value.
|
|
|
|
|