|
Hey, thanks for the reply. Here is the result of removing const, minus setting the memory and zeroing it, because I am not sure what that means or how to do that. I am still quite new. Hopefully, this provides a better description of the 0xc0000005 access violation error I am having and why.
ERROR: C:\test.cpp error C2664: 'pcap_next_ex' : cannot convert parameter 3 from 'unsigned char ** ' to 'const unsigned char ** '
Caused by: u_char *pkt_data
Prevents error: const u_char *pkt_data
Here is where it is intialised: while((res = pcap_next_ex( fp, &header, &pkt_data)) >= 0)
Here is where it fails: (5 times through)
if (i < 7) { //dst address (ETH)
fprintf(out, "%.2x", pkt_data[i-1]);
if (i > 0 && i < 6) { fprintf(out, ":"); } else { fprintf(out, "\neSrc="); }
I am sorry, but I do not know what you meant by: "...set the memory and zero it. When you come to use it later simply test it." Can I see an example?
If you need more info, let me know. Thanks in advance.
|
|
|
|
|
borono wrote: am sorry, but I do not know what you meant by: "...set the memory and zero it. When you come to use it later simply test it." Can I see an example?
sure:
unsgined char *foo;
foo = new unsigned char [100];
ZeroMemory(foo,sizeof foo);
int size = strlen((char *)foo);
strcpy((char *)foo,"Some random string");
if (!foo)
MessageBox(0,"foo is still empty",0,0);
delete foo;
As for your code, have you checked the size of pkt_data? You are using it as an array, but are you sure it is correctly being initialised? It's hard to see from your code since you do it in a while loop and there is no specified number of loops.
You later use if(i<7) which may be reading past the end of your array. Watch the values of i at this point. I would also put a check for the size there: if ((i<7)&&(i<strlen(pkt_data)).
If you have further problems, and if you are using VC6, I can take a look at your project.
|
|
|
|
|
waldermort wrote: Watch the values of i at this point.
Especially when i is equal to 0. Then, referencing an array with -1 would be very suspicious.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
borono wrote: could that be the reason.
If you suspect it is, then try:
fprintf(out, "%.2x", 123);
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
@DavidCrow
Good idea and I tried that just now and it still failed after five times through. I have yet to try waldermort's suggestion, so let me try that here in a few hours, after I get off work and I will let you know if that fixed it. I am sure it is something very simple. I write in assembler too and when I first started I kept forgetting to initialise the DS in my code, went through everything over and over, got real frustrating but showed my code to a friend, he saw it and that was that. --something so simple it hurts. I bet that is what this is too.
Im off in three hours, talk to you again then. thanks guys.
|
|
|
|
|
borono wrote: Good idea and I tried that just now and it still failed...
Which indicates the problem (probably) has nothing to do with pkt_data .
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I think your right, I am about to send my project or source to waldermort -- as soon as he tells me what he preffers. Hopefully, he will be able to look through it and correct the problem, or at least identify it better than I have.
I want to say, yeah it is the pkt_data variable, because when it is non-existant, my dll works, when it is existant, it fails. So it can't be the device I am reading from, which is what I first assumed. Then I thought maybe it was the file output portions, but if I remove that it still fails. I have no idea whatsoever.
It's a riddle. I am stumped.
best regards
-- modified at 21:50 Thursday 6th April, 2006
Eureka. I have it working. After picking at it, it turns out I was leading us completly the wrong way --miles away. It happened to be from a variable further down in the code that deals with the hex dumpage, it becomes corrupt after a few times through the loop. Why, I have no idea as of now. However, it is now printing to the file as intended.
best regards
|
|
|
|
|
Hi ya'all,
I'm sure this might be a very easy and simple thing but I would like to find out how to package my project application so it can run without the developing environment; yes, just want to make it executable. Any pointers will be appreciated.
Regards...
|
|
|
|
|
first of all, build it in release mode.
then, use the "Dependency Walker" tool to find which DLL are required
provide them with your exe, and use installshield (or any install packager) to provide an installer if you like...
|
|
|
|
|
Hi,
I want to query, modify and write a REG_MULTI_SZ values from Registry.Can anyone pleeeease show me some code samples.
Thanks in advance.
|
|
|
|
|
See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
|
Hello!
I'm just a basic MFC user. Mostly I do my UIs in resource editor in VS.NET 2003. I know how to handle BN_CLICKED message from button and do something with it (trough message map). But now I have a problem. I should do something on button "press" and something different on button "release". It's the situation when event is dispatched on press and release not just release like it is the case with BN_CLICKED. Is it even possible?
Thank you for all the help.
Best regards,
Rostfrei
|
|
|
|
|
WM_LBUTTONDOWN and WM_LBUTTONUP should do
|
|
|
|
|
Can you please give me more instructions? Like I said I am using resource editor for it. What to type into message map?
Rostfrei
|
|
|
|
|
do you mean LButtonDown??
Regards,
FarPointer
|
|
|
|
|
What do you mean by LButtonDown? I just want do something on button down and something else on button up.
Rostfrei
|
|
|
|
|
|
Which means you need to supply handlers for the WM_LBUTTONDOWN and WM_LBUTTONUP messages.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I managed to supply the handlers. I have the Dialog based application. If I press the mouse anywhere on the dialog I can detect it and can read the coordinates. The problem is when I click on the button. Click is not detected and I guess its intercepted by button. I want to detect the button down and check if mouse down happened in the area where button is. I don't have any method registered with the button. All I want to use it for now is button press/release shadow effect. What can I do? I don't want to draw custom button pictures and place them on the button region.
Regards,
Rostfrei
|
|
|
|
|
One way is to derive your own class from CButton and put the message handlers in it. If that does not work, perhaps message reflection will.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I already tried that but it is not possible to declare message map in there
<br />
class CCustomButton : public CButton<br />
{<br />
private:<br />
DECLARE_MESSAGE_MAP ()<br />
};<br />
<br />
<br />
BEGIN_MESSAGE_MAP(CCustomButton, CDialog)<br />
<br />
END_MESSAGE_MAP()<br />
because I get error
<br />
mainAppDlg.cpp(106): error C2248: 'CDialog::GetThisMessageMap' : cannot access protected member declared in class 'CDialog'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(2864) : see declaration of 'CDialog::GetThisMessageMap'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(2767) : see declaration of 'CDialog'<br />
What is message reflection?
Regards,
Rostfrei
|
|
|
|
|
Rostfrei wrote: I already tried that but it is not possible to declare message map in there
Sure it is. MFC would not be worth a whole lot otherwise.
Rostfrei wrote: class CCustomButton : public CButton
...
BEGIN_MESSAGE_MAP(CCustomButton, CDialog)
Notice the discrepancy?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I'm sorry I just don't get it. What is different?
Rostfrei
|
|
|
|
|
a button inherits from CButton , not CDialog
|
|
|
|