|
Thanks CPallini,
Cool sample!
Two more comments,
1. You agree with my points in original post?
2. In MSDN, there is no inheritance hierarchy information (at least I can not find from API document for ostrstream, could you find such information from MSDN)? for example ostrstream inherits from ostream.
regards,
George
|
|
|
|
|
George_George wrote: 1. You agree with my points in original post?
Since it is a (output) stream, yes.
George_George wrote: 2. In MSDN, there is no inheritance hierarchy information (at least I can not find from API document for ostrstream, could you find such information from MSDN)? for example ostrstream inherits from ostream.
Yes, here [^] (check out the grey rectangle).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
For the "grey rectangle" you mentioned, do you mean the grey rectangle containing text "class ostrstream : public ostream", we can not click it to expand, and we only know ostrstream directs inherits from ostream. Right?
Sorry I have not made myself understood, is there an electronic form of all the classes hierarchy (GUI) form from MSDN?
regards,
George
|
|
|
|
|
AFAIK there isn't such diagram for STL in MSDN.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
My question is answered. There is a hard copy in Bjarne's book.
regards,
George
|
|
|
|
|
George_George wrote: Any other situations which use of this class (compared with other string and stream related class) will give us special benefits?
This boost library[^] uses stringstream and offers a good way of formating strings.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
|
Sure.
ostringstream is part of the Standard.
If you are interested in some background, there is a chapter in N. Josuttis "The C++ Standard Library"
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Thanks jhwurmbach,
My question is answered.
regards,
George
|
|
|
|
|
Hi Friends,
I am in need to extract the exported
functions of a DLL.
If a DLL name is given,all exported functions in that
DLL must be listed out.
I used Dumpbin and tdump utility tools to do so.
But I need to make this without using any utility tools,
just mere by coding.
Could anyone please help me?
|
|
|
|
|
Can you give more details? Is the DLL loaded into the memory space of the process used to list the exports?
Steve
|
|
|
|
|
The DLL is chosen by the user.
Once it is chosen,the names of the
exported functions in that DLL has to shown.
So it is during runtime the DLL is known, for
which its functions are listed out.
Thanks!
|
|
|
|
|
poda123 wrote: But I need to make this without using any utility tools,
just mere by coding.
Use SymEnumSymbols . It takes a callback function pointer which in turn gets called for every symbol found, as a parameter to the function you get a pointer to a SYMBOL_INFO structure.
Use the Flags member of this struct along with SYMFLAG_EXPORT to find out whether this particular symbol is exported or not.
I am doing the same in my Process viewer article here -> http://www.codeproject.com/KB/cpp/processviewer.aspx[^]
I guess you will have to load the DLL into your process. Not sure!
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Thanks for your reply.
I tried to execute the process viewer,
but could not run due to the error message
"...desktop\procviewer\utils.h(829) : error C2065: 'SLR_NOSEARCH' : undeclared identifier"
Could you please help me out to run your application,where
I can learn more things out there.
Thanks!
|
|
|
|
|
poda123 wrote: Could you please help me out to run your application,where
I can learn more things out there.
Do you have latest platform sdk installed?
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Hi,
I have downloaded and installed the version
Microsoft® Windows Server 2003 R2 Platform SDK - March 2006 Edition.
But still I get the same error.
If there is a newer version,please send me the link.
Thanks!
|
|
|
|
|
poda123 wrote: I tried to execute the process viewer,
but could not run due to the error message
"...desktop\procviewer\utils.h(829) : error C2065: 'SLR_NOSEARCH' : undeclared identifier"
This makes no sense. C2065 is a compiler error, which means you would not have had a Process Viewer executable.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Here's a program I knocked up which lists the functions exported by name from a dll:
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <Imagehlp.h>
#pragma comment(lib, "Imagehlp.lib")
using namespace std;
int main(int argc, char* argv[])
{
if (argc!=2)
{
cerr << "Usage:\n\tExports <path to dll>" << endl;
return 1;
}
LOADED_IMAGE li;
BOOL bOK = MapAndLoad(
argv[1],
NULL,
&li,
TRUE,
TRUE
);
if (!bOK)
{
cerr << "MapAndLoad failed!" << endl;
return 2;
}
DWORD expVA = li.FileHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
PIMAGE_EXPORT_DIRECTORY pExp = (PIMAGE_EXPORT_DIRECTORY)ImageRvaToVa(
li.FileHeader,
li.MappedAddress,
expVA,
NULL
);
DWORD rvaNames = pExp->AddressOfNames;
DWORD *prvaNames = (DWORD*)ImageRvaToVa(
li.FileHeader,
li.MappedAddress,
rvaNames,
NULL
);
for (DWORD i=0; i<pExp->NumberOfNames; ++i)
{
DWORD rvaName = prvaNames[i];
const char *pName = (const char*)ImageRvaToVa(
li.FileHeader,
li.MappedAddress,
rvaName,
NULL
);
cout << pName << endl;
}
UnMapAndLoad(&li);
return 0;
}
Steve
modified on Wednesday, February 13, 2008 10:58 PM
|
|
|
|
|
Awesome!
Thanks a lot Steve for your help.
Thank you so much!
|
|
|
|
|
Could you please share how did you come up
with such a nice code to export dll functions.
Any website reference?
Thanks!
|
|
|
|
|
Many years ago I read this[^] and this[^]. The "WinNT.h" header file is also informative.
Steve
|
|
|
|
|
HI,
i'm trying to derive from an Interface that looks like this (the iport.h):
<br />
<br />
#ifndef _PORT_<br />
#define _PORT_<br />
#pragma once<br />
<br />
class IPort<br />
{<br />
public:<br />
IPort(int pi): portId(pi) {}<br />
~IPort(void) {}<br />
<br />
virtual int Send(const void * data , int len, int cNum = 0 , short mId = 0 )=0;<br />
virtual int InitPort(void) = 0;<br />
virtual int ClosePort(void) = 0;<br />
virtual int BindAndConnect(void) = 0;<br />
<br />
int GetPortId(void)<br />
{<br />
return portId ;<br />
}<br />
<br />
protected:<br />
<br />
int portId;<br />
};<br />
#endif<br />
my class is as sipmale as can get(the *.h) :
<br />
#pragma once<br />
#include "iport.h"<br />
<br />
class _COM :<br />
public IPort<br />
{<br />
public:<br />
_COM(void);<br />
_COM(int port, int rt);<br />
public:<br />
~_COM(void);<br />
<br />
private:<br />
int portNumber;<br />
int RT_Number;<br />
};<br />
But It Keeps thorwing my the TITLE error
for the .cpp file:
#include "_COM.h"<br />
<br />
_COM::_COM(void)<br />
{<br />
}<br />
<br />
_COM::_COM(int port, int rt):portNumber(port),RT_Number(rt)<br />
{<br />
<br />
}<br />
<br />
_COM::~_COM(void)<br />
{<br />
}
What am i'm missing?
THANKS
Have Fun
Never forget it
|
|
|
|
|
half-life wrote: _COM::_COM(void)
That is your problem: your base class (IPort) doesn't have a default constructor, so you are required to call its constructor and provide a value to it. Within your default _COM constructor, you need to call the constructor of IPort and passing a parameter to it.
|
|
|
|
|
Yep Indeed, THAMKS A lot
Have Fun
Never forget it
|
|
|
|
|
Your interface contains state (the member variable int portId ).
Is that really intended?
Also, you probably should make the d'tor virtual. Also the portIt-getter.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|