|
Hi.
I need to access not only the sent data but the whole IP packets to analyze the headers (for a firewall-like app).
My problem is, that I can't find any entry point in the MSDN to learn about access to the low level network traffic.
How can I
1. get notified when a packet arrives ?
2. get the packet form the queue ?
3. put packets into the queue ?
I'd be happy to learn about a good website/tutorial about this issue...
|
|
|
|
|
You have to write a packet driver. To do that you need the DDK (Driver Development Kit) for win9x. (download from MS)
There is a demo driver, in the DDK, that can do a lot of the things that you want
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hello,
I seem to be having a problem with my message queue. I am working on a data aquisition app (multi-threaded). The data aquisition thread(s) post messages to the MFC gui thread when data is received and when the graph needs to be refreshed. Occasionally, the graph stops displaying data until the refresh occurs (rather than as it is received). When this happens, all of the buttons in the dialog become inoperable. Is there a way to do something with the message queue? I'd like to be able to see if it's getting full and, perhaps, increase its size.
Thank you.
Paul Ebert
|
|
|
|
|
Hi.
Perhaps you should try to prevent the message queue from getting overload.
I assume you don't need more than a few refreshs in a second?! So you can implement a global thread-safe bool which
- is set when a message is sent to the GUI.
- is reset by the paint reoutine after completion.
The threads only send a refresh request, when the bool is not set.
Hope it will help you.
Karl
|
|
|
|
|
In Windows 3.1 there was SetMessageQueue function that made increasing the queue size possible, but it's obsolete now - they probably made it a no-op call.
Do you really have to post multiple messages from data acquisition thread? Before posting you could check if GUI is already refreshed. If not, no need for second PostMessage.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
If you need a utility that generates a windows help file automatically from
a type library, you might want to take a look at Oberon TLB Tools utility:
http://www.vakcer.com/oberon/products/tlbtools/
This utility includes 3 tools:
TLB2HLP - generates a complete WinHelp project containing .rtf, .cnt, .prj,
and other files ready to be compiled into a .hlp file. The .rtf file
contains help topics on each objects, method, properties, etc. with
descriptions, place holders for code samples, etc. A good start to create
full online help for a COM object model or ActiveX control properties.
TLB2HTML - creates an HTML file containing all type information from a type
library with cross-references, object index, and so on...
TLB Compare - compares two type libraries and writes differences as an HTML
file.
You can find examples of how each of the tools work on the web page given
above...
I hope this is helpful...
--
Alex
----
Do you still use a stopwatch to track your project time?
Why not try a completely automatic time tracking and billing
application for Windows - VAKCER Project Tracker v2.1?
Get your free trial copy today at http://www.vakcer.com
|
|
|
|
|
I am interesting in using Mr. Naughter CCPUTicker, but I want to use it as accurately as possible.
Is there a way to place a "lock," something like a semaphore, around a set of C++ instructions, and stop all other messages from being serviced during this time?
In other words, can I change
foo(a);
bar(b);
to
BEGIN(lock)
foo(a);
bar(b);
END(lock)
and know that foo and bar were executed sequentially? For CCPUTimer, this would allow me to time between to calls as accurately as possible.
Thanks,
Ryan
|
|
|
|
|
Remember that 32-bit Windows systems use preemptive multitasking. You can't ensure that your process is utilizing all CPU resources all the time.
You can of course ensure that other thread from your process is not called during foo and bar. Is your application multithreaded?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
No, I am not using a multithreaded application.
Would CWinThread::SetThreadPriority(THREAD_PRIORITY_TIME_CRITICAL) be the closest I could get to locking out the other processes? I realize windows is not a RTOS, but thought it might be possible to force a process to "utilize all CPU resources" for a short time.
-Ryan
|
|
|
|
|
Yeah, SetThreadPriority and SetPriorityClass will make your process real resource hog
If your app is singlethreaded, don't worry about message pump - it's running in the same thread. Just don't call PeekMessage/GetMessage manually inside foo and bar.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hmmm... I'm looking at Richter's Advanced Windows, chapter 4, and it looks like if you were to get really piggy you could SetPriorityClass for the process to REALTIME_PRIORITY_CLASS and SetThreadPriority to THREAD_PRIORITY_TIME_CRITICAL to give it a level of 31.
31 is the maximum. 31 is extreme. 31 will never yield. 31 can alter the fabric of the space time continuum as we know it.
Well, thats the impression I get anyway.
On NT you'll need the Increase Scheduling Priority privilege.
|
|
|
|
|
I have been programming C++ for about a year, and have learnt quite a lot. However, moving to Visual C++ has really created problems for me. I understand most things, I can deal with messages properly, interact with UI elements etc, but it still seems a long way off that I would be able to put together a complex application or game. How did you guys learn, and what is the best way for me to go from here?
|
|
|
|
|
designing software to implement is the vision thing ... it takes a bit longer to do architecture but keep plugging away and you'll get there
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I need to draw transparent rectangle (will have only BOUNDING LINES VISIBLE) above existing drawing. Rectangle will be drawn in real time by the user. No part of drawing underneath must be destroyed. Is there any smart way of how to save & restore overlaid parts of the existing drawing?
I am relatively new to GDI.
Thanks in advance.
|
|
|
|
|
Hold the two images in different bitmaps and merge them in OnPrepareDC or OnPaint direct to the screen.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Thanks, I'll keep it in my mind. Any other ideas?
|
|
|
|
|
Use DrawFocusRect. Or set the ROP2 mode to R2_NOTXORPEN, brush to NULL_BRUSH and draw whatever you want. To remove drawn rectangle, repeat the steps - since you're XORing the pixels, second pass will restore them to initial values.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
If I draw black (black pen, black brush) rectangle with R2_NOTXORPEN, will it appear all black? Where are stored pixels of original drawing in this case? Where is stored this information? I must restore them from somewhere.
|
|
|
|
|
Geez, man - do you know how XOR works?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
|
> 1 xor 1 makes 0
And what about 1 xor 0, 0 xor 1 and 0 xor 0? If you draw rectangle *twice* in XOR mode, it will disappear and your original picture will remain intact. XOR 'toggles' bits - zeros become ones and vice versa. Two XORs give you original bits. Of course, you have to ensure that rectangle coordinates do not change. Is that clear enough?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Ok, I tried DrawFocusRect which is XOR function.
CRect rc (0, 200, 200, 0);
pDC -> DrawFocusRect (&rc);
in my OnPaint (). I see no rectangle on the screen.
I doubt now. I believe DrawFocusRect draws in logical coord. space.
Mapping mode, window origin and extent are set accordingly. Everything seems to be all right. Did I something wrong?
|
|
|
|
|
From the DrawFocusRect documentation:
"DrawFocusRect works only in MM_TEXT mode."
If you need some other mapping mode, the only way is to call SetROP2 and draw rectangle manually. You can use MoveTo/LineTo or set a brush to GetStockObject(NULL_BRUSH) and call Rectangle. I'm assuming you need only outline of the rectangle - as specified in original post.
You can check KB article Q135865 to get sample on "How to use Win32 API to Draw a Dragging Rectangle on Screen DC". Your task is probably easier - you'll be drawing inside your own window only. You can also search for "sample setrop2" in your VC++ help - this search gives more than 20 hits on my workstation.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
You are right, I'm using MM_ANISOTROPIC mapping mode.
Now I'm trying:
CRect rc (10, 200, 200, 40);
pDC -> SetROP2 (R2_NOTXORPEN);
pDC -> Rectangle (&rc);
It looks fine. This is what I wanted. THANKS!
|
|
|
|
|
I'd code it differently. Assuming that you want to decrease dialog height to hide the button, it would look like this:
CRect rcDialogClient, rcDialogWindow;
GetWindowRect(rcDialogWindow);
GetClientRect(rcDialogClient);
CRect rcBtnWindow;
m_btn.GetWindowRect(rcBtnWindow);
ScreenToClient(rcBtnWindow);
int cyDelta = rcDialogClient.Height() - rcBtnWindow.top;
SetWindowPos(NULL, 0, 0,
rcDialogWindow.Width(),
rcDialogWindow.Height() - cyDelta,
SWP_NOMOVE | SWP_NOZORDER);
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|