|
If the Size of the Data is never known, or unknowable, the problem is unsolvable.
So, assuming that the size of the data is known at some stage, I would work with malloc, realloc and free. If needed, start with a very big buffer. Most protocols have a way of communicating the available buffer size, and give something like ERR_MOREDATA in case of overflow. It will take a littlebit of ingenuity but in principle should not be too difficult to write.
Bram van Kampen
|
|
|
|
|
When does this message get posted is it every time the process that load it the DLL creates a thread or when the thread invokes a fucntions in the DLL
Thankx
|
|
|
|
|
It's not strictly a message but a parameterised call to a DLL entry point. Anyway this is what the docs say.
"The current process is creating a new thread. When this occurs, the system calls the entry-point function of all DLLs currently attached to the process. The call is made in the context of the new thread. DLLs can use this opportunity to initialize a TLS slot for the thread. A thread calling the DLL entry-point function with DLL_PROCESS_ATTACH does not call the DLL entry-point function with DLL_THREAD_ATTACH.
Note that a DLL's entry-point function is called with this value only by threads created after the DLL is loaded by the process. When a DLL is loaded using LoadLibrary, existing threads do not call the entry-point function of the newly loaded DLL."
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
is there any way I can interogate some info regarding the thread that is being created via
DLL_ATTACH_PROCESS
I have many types of threads being created in My process and only want to do processing for
certian types of threads
Would lpreserved parm on DLLMAIN point to on a structure with info about the
newly created thread
Thankx
|
|
|
|
|
When your DLL_ATTACH_PROCESS handler is hit it will always be from the primary application thread so there is no issue there. To get thread info in your DllMain DLL_ATTACH_THREAD handler I'd start with the DWORD GetCurrentThreadId(void); API. Then either use the thread ID to index your own shared data structure (remember to lock it ) or use a well known variable to access the user data passed into your thread function. Most people use this one parameter which gets passed through to a thread start point to pass a data structure for identifying and controlling the thread.
<br />
HANDLE CreateThread(<br />
LPSECURITY_ATTRIBUTES lpThreadAttributes,<br />
SIZE_T dwStackSize,<br />
LPTHREAD_START_ROUTINE lpStartAddress,<br />
LPVOID lpParameter,<br />
DWORD dwCreationFlags,<br />
LPDWORD lpThreadId<br />
);<br />
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
My next question what gets control first the starting function of the createthread API or DLL_ATTACH_THREAD message
I would some how like to intilize/create a control block/structure that the DLL_ATTACH_THREAD message
can introgate and do certin processing based on the value of this structure
|
|
|
|
|
Interesting question, I'm not sure but I guess the DLL Entry point may be called with DLL_ATTACH_THREAD first which will make it difficult to use your thread creation parameter. I suggest you use the C Runtime thread spawning commands documented here[^] and include the C Runtime source in the include directories of your project. Then you can debug the thread startup process and see if there's somewhere you can attached your control object. You may be able to access your thread parameter through the C Runtime before your thread start function is called.
The alternative is to use structures shared between threads, set up the data for the new thread in this structure (list, array or whatever ) before you launch the thread and use synchronisation objects to safely access the shared data from your secondary thread. This kind of arrangement would probably require a singleton thread factory to ensure that only one thread is created and handed off its data at a time. I have seen arrangements like this working in the past in distributed applications.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
And If I have quad core CPU it makes hairer as I need another levle of syncronazation
Thnakx
|
|
|
|
|
I work on some software which needs to be low CPU usage and high performance.. But I find it hard and annoying to use perfmon to find what I need.
I was wondering what tools people use for profiling their applications?
I'd love to find something like "Super Perfmon". Something that let's me watch things, add events to the record, record system events, reporting, etc...
Any clues for some must-have debug tools?
P.S. I heart Process Explorer!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
I found one article in the website "optimization your worst enemy", take a look, at the bottom are links to other related articles, they maybe help you.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
We use VTune from Intel - works great.
|
|
|
|
|
Hey all,
I encountered this information in a definiton of some function's prototype in C++
<br />
<br />
Library Link to: Ws2_32.lib.<br />
<br />
DLL Requires: Ws2_32.dll. <br />
<br />
Can anyone explain me what does this mean, and how can I link to specified file above ?
|
|
|
|
|
That means the function is implemented in ws2_32.dll and the link library your
project needs to link to is ws2_32.lib.
One way to link to ws2_32.lib is to add ws2_32.lib to the Project/Properties/Linker/Input/Additional Dependencies list.
Another way is to use #pragma comment in the source code, something like
#pragma comment(lib, "ws2_32.lib")
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
I don't know anythign about C++ or classes. All I know is there's a strContent variable sitting in this:
LRESULT CMemMapCppClientDlg::OnDataReady(WPARAM, LPARAM) <br />
{<br />
HANDLE hMapFile = NULL;<br />
PVOID pView = NULL;<br />
<br />
hMapFile = OpenFileMapping(FILE_MAP_READ, FALSE, m_pszMemMapFileName);<br />
if(hMapFile == NULL) {<br />
MessageBox("Can not open file mapping");<br />
return 0;<br />
}<br />
<br />
pView = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);<br />
if(pView == NULL) {<br />
MessageBox("Can map view of file");<br />
CloseHandle(hMapFile);<br />
return 0;<br />
}<br />
<br />
LPSTR szContent = reinterpret_cast<LPSTR>(pView);<br />
int nLen = strlen(szContent);<br />
CString strContent;<br />
while(nLen > 0) {<br />
strContent += *szContent++;<br />
--nLen;<br />
}<br />
strContent += '\0';<br />
strContent.Replace("\n", "\r\n");<br />
MessageBox(strContent);<br />
<br />
if(pView) UnmapViewOfFile(pView);<br />
if(hMapFile) CloseHandle(hMapFile);<br />
<br />
return 0;<br />
} ...which I need to get to from another area of the program.
(The snip is from a Memory Map sample app download from Code Project.)
Is there anybody that can show me how to make some kind of a call (from another class in another module) to this class to get at the value of strContent? Does strContent first need to somehow be teased out of ::onDataReady and placed in its own small function in order to make it available to be called from a separate part of the program.
Thank you if anyone can help.
|
|
|
|
|
e40s wrote: }...which I need to get to from another area of the program.
Not possible since it is local to the OnDataReady() method. Can you make it a class member variable instead?
"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
|
|
|
|
|
|
does the term "class" means something to you ?
|
|
|
|
|
toxcct wrote: does the term "class" means something to you ?
Is that what you go to for learning about stuff?
"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
|
|
|
|
|
sorry, i've been too rude, i appologize Ô sir.
i should have started with "how to define the main() function"
|
|
|
|
|
toxcct, why don't you take a vacation.
>> Not possible since it is local to the OnDataReady() method.
Extremely informative! Thanks!!
>>Can you make it a class member variable instead?
David, if you or others can explain to me the proper way to do this, I would be grateful. Will it mostly be defined through the header file of this source module? (Also are class member variables ordinarily prefixed with "m_"?)
Thanks for any help.
-- modified at 10:37 Thursday 8th November, 2007
|
|
|
|
|
hum, well, i will consider this not to be a personal attack against me, but just a lack of knowledge and maturity about C++.
so, to puch you on the right way, you should start here[^] (we should all );
then, here is what i can say to you :
e40s wrote: >> Not possible since it is local to the OnDataReady() method.
Extremely informative! Thanks!!
well, if you don't know what local means, it's going to be hard for us to explain more, and hard for you to understand more. it part of the basics of many simple programming languages, which basics C and C++ are based upon.
a variable is local to the scope it's been defined within. if you define a variable inside a function, you will be able to access it from within the function, not from outside (outside can mean "from the caller").
if you don't understand this concept, you should first take a book about the programming language of your choice and read the control structures paragraph.
e40s wrote: >>Can you make it a class member variable instead?
David's reflexion makes perfect sense to me.
e40s wrote: David, if you or others can explain to me the proper way to do this, I would be grateful
as i said, his sentence made sense, so the problem is not that we don't explain the proper way, but that you don't understand it...
e40s wrote: Will it mostly be defined through the header file of this source module?
not quite. if it's a member of the class, it's defined inside the class, no matter which file the class is defined on.
e40s wrote: Also are class member variables ordinarily prefixed with "m_"?
that's it, but that's just naming conventions, nothing/noone obliges you to stick to such variable namings...
any more questions ?
|
|
|
|
|
>> so, to puch you on the right way, you should start here[^] (we should all );
then, here is what i can say to you :
You've proven yourself so unworthy of speaking with, and so insecure about your abilities and yourself in general (what kind of ass sneers at questions?), that I wouldn't consider following your links.
>> well, if you don't know what local means, it's going to be hard for us to explain more
I said I don't know C++. It doesn't mean I don't know what "local" means. It means I don't know the language well enough to inter-navigate into and out of localities properly, the way a seasoned C++ programmer would teach. It's why I posted the question.
>> David's reflexion makes perfect sense to me
David's reflection makes perfect sense to me too. But I wanted it matched up with language. (Concepts and their formal language implementation are two separate things.) Learn how to spell.
>> not quite. if it's a member of the class, it's defined inside the class, no matter which file the class is defined on.
The first semi-helpful answer you've provided. But which class? You're not much of a teacher either.
>> that's it, but that's just naming conventions, nothing/noone obliges you to stick to such variable namings
Re the latter, I know that much, but the question really pertained to naming conventions. Thanks.
|
|
|
|
|
e40s wrote: You've proven yourself so unworthy of speaking with, and so insecure about your abilities and yourself in general (what kind of ass sneers at questions?), that I wouldn't consider following your links.
and you think being a member of a forum for 2 weeks gave you more value here ?
wee should all be respecting the forum posting guidelines, and you too !
beeing a newbe here doesn't give you the rignt to ask anything on any ways...
e40s wrote: I said I don't know C++.
well, on swear, i missed that one
e40s wrote: It doesn't mean I don't know what "local" means
your answer to David (another major member which should be respected, far better than I could expect for me)'s post made me think you didn't, sorry.
e40s wrote: The first semi-helpful answer you've provided
i do my best with the few informations you provided from your side too
e40s wrote: But which class? You're not much of a teacher either
man, YOUR class !!! i don't know what class you were talking about, but you were talking about a class, so i meant THAT class.
what can a teacher teach to a student that doesn't want to understand ?
e40s wrote: Thanks
at least a nice word from your mouth too
well, it seems BadKarma gave you some code on another post that seems to satisfy you, happy for you.
for my part, know that I am here to help, but it's not really fair to think that asking somewhat rudely will bring you working code that you only have to incorporate in your code.
this been said,
Welcome on Codeproject, and have a nice end of day
|
|
|
|
|
>> asking somewhat rudely
Where? I really try not to be rude when asking a question.
>> only have to incorporate in your code
This betrays so much ignorance about how people learn, I don't know where to begin. I'll start buy mentioning a little concept of the nature of textbooks called "Examples." People don't learn by parable alone.
In fact, I don't even know why they post sample code to Code Project. People should be able to learn C++ class architecture and its associated language syntax by just having the sample described to them in metaphor, like the way you learned it. You're that talented.
-- modified at 12:21 Thursday 8th November, 2007
|
|
|
|
|