# Anyone feel like testing my simple packet sniffer?

**URL:** https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189
**Category:** Miscellaneous and Personal Stuff I Must Share
**Created:** [March 29, 2004, 11:22pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189 "2004-03-29T23:22:38Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![Revtim](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/revtim/32/1042_2.png) [@Revtim](https://boards.straightdope.com/u/Revtim)
#### Post date: [March 31, 2004, 3:17pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/21 "2004-03-31T15:17:36Z")

</div>

> [@Revtim](#):
>
> (in case for some reason my .dll files are different from **caphis** ’s, which I think is)

…unlikely.

---

<div class="post-metadata">

### Author: ![Revtim](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/revtim/32/1042_2.png) [@Revtim](https://boards.straightdope.com/u/Revtim)
#### Post date: [March 31, 2004, 3:39pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/22 "2004-03-31T15:39:52Z")

</div>

And make sure the .dll files you downloaded have READ access, in case you haven’t’ already. That could cause a “The application failed to initialize properly” error.

---

<div class="post-metadata">

### Author: ![caphis](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@caphis](https://boards.straightdope.com/u/caphis)
#### Post date: [March 31, 2004, 4:48pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/23 "2004-03-31T16:48:11Z")

</div>

> [@Revtim](#):
>
> And make sure the .dll files you downloaded have READ access, in case you haven’t’ already. That could cause a “The application failed to initialize properly” error.

Nope, still locks up after pressing Start. Upon loading, however, the box is now populated with the following (before pressing anything):

```auto

BEFORE pcap_findalldevs
BEFORE displaying devices
Device
1
Description
\Device\NPF_{5DC3CBB8-B922-42F0-ABDB-ED06ECA827D5}
NET IP/1394 Miniport
Device
2
Description
\Device\NPF_{7465BDE4-63E4-4B03-AB85-0DC573D8D54D}
National Seminconductor Corp. DP83815 10/100 MacPhyter 3v PCI Adapter 
=====================================================

```

---

<div class="post-metadata">

### Author: ![Revtim](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/revtim/32/1042_2.png) [@Revtim](https://boards.straightdope.com/u/Revtim)
#### Post date: [March 31, 2004, 5:13pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/24 "2004-03-31T17:13:23Z")

</div>

Thanks again **caphis**

The very odd thing is the text that populates the screen initially is from code that was cut 'n pasted from the beginning of the START routine. The exact same code.

It’s kind of like just the basic event handler isn’t working. Could this be because we have different mfc70.dll files? (they are exact same length, though)

If you feel like it, make a backup of yours, and try it using mine from [http://users.adelphia.net/~tlaplaca/mfc70.dll](http://users.adelphia.net/%7Etlaplaca/mfc70.dll).

Thank you again.

And I know you had to type the output by hand, which is more work that you should have had to do.

---

<div class="post-metadata">

### Author: ![caphis](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@caphis](https://boards.straightdope.com/u/caphis)
#### Post date: [March 31, 2004, 6:16pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/25 "2004-03-31T18:16:08Z")

</div>

> [@Revtim](#):
>
> It’s kind of like just the basic event handler isn’t working. Could this be because we have different mfc70.dll files? (they are exact same length, though)
> 
> If you feel like it, make a backup of yours, and try it using mine from [http://users.adelphia.net/~tlaplaca/mfc70.dll](http://users.adelphia.net/%7Etlaplaca/mfc70.dll).

No go that time, either. Infinite loop somewhere? (don’t have the source code anymore)

> [@](#):
>
> And I know you had to type the output by hand, which is more work that you should have had to do.

All in the name of science. 😃

---

<div class="post-metadata">

### Author: ![Revtim](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/revtim/32/1042_2.png) [@Revtim](https://boards.straightdope.com/u/Revtim)
#### Post date: [March 31, 2004, 6:56pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/26 "2004-03-31T18:56:52Z")

</div>

I added a simple dialog first thing in the START handling. If it still locks after hitting START, and no dialog, the problem is somehow between pressing the START button but before the START button handler is run. Of course, I have no clue how to fix that.

[http://users.adelphia.net/~tlaplaca/sps12\_dialog.exe](http://users.adelphia.net/%7Etlaplaca/sps12_dialog.exe)

---

<div class="post-metadata">

### Author: ![caphis](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@caphis](https://boards.straightdope.com/u/caphis)
#### Post date: [March 31, 2004, 7:42pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/27 "2004-03-31T19:42:15Z")

</div>

> [@Revtim](#):
>
> I added a simple dialog first thing in the START handling. If it still locks after hitting START, and no dialog, the problem is somehow between pressing the START button but before the START button handler is run. Of course, I have no clue how to fix that.
> 
> [http://users.adelphia.net/~tlaplaca/sps12\_dialog.exe](http://users.adelphia.net/%7Etlaplaca/sps12_dialog.exe)

START button Pressed.

🙂

---

<div class="post-metadata">

### Author: ![caphis](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@caphis](https://boards.straightdope.com/u/caphis)
#### Post date: [March 31, 2004, 7:43pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/28 "2004-03-31T19:43:40Z")

</div>

Oh-- and, same lockup afterward. Looks like we’re making progress, though. 😃

---

<div class="post-metadata">

### Author: ![Revtim](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/revtim/32/1042_2.png) [@Revtim](https://boards.straightdope.com/u/Revtim)
#### Post date: [March 31, 2004, 8:23pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/29 "2004-03-31T20:23:47Z")

</div>

The dialog is shown? Wow, that surprises the hell out of me. I was _sure_ it wasn’t even getting into the button handling code.

This is indeed great progress. The problem almost certainly has to be in this code, where I get the ClistBox object so I can send output to it.

// get access object for ListBox  
CWnd\* pListWnd = GetDlgItem(IDC\_LIST4);  
ASSERT(pListWnd);  
// CListBoxes derive from CWnds, so we can downcast the pointer to get a pointer to the listbox, and then use its methods  
CListBox\* OutBox = dynamic\_cast\<CListBox\*\>(pListWnd);  
ASSERT(OutBox);

Strange things:

- This same code works fine for you when it runs in the Init (to display adapters)
- The ASSERTs aren’t being thrown
- IT WORKS FINE FOR ME!!! ARRGHH!!!

Maybe I’ll make another that pops another dialog after this code, just to be sure it’s this stuff.

Thanks again.

---

<div class="post-metadata">

### Author: ![Revtim](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/revtim/32/1042_2.png) [@Revtim](https://boards.straightdope.com/u/Revtim)
#### Post date: [March 31, 2004, 8:35pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/30 "2004-03-31T20:35:17Z")

</div>

OK, made a new one with a dialog after that suspect code.  
[http://users.adelphia.net/~tlaplaca/sps13.exe](http://users.adelphia.net/%7Etlaplaca/sps13.exe)

---

<div class="post-metadata">

### Author: ![Revtim](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/revtim/32/1042_2.png) [@Revtim](https://boards.straightdope.com/u/Revtim)
#### Post date: [March 31, 2004, 9:18pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/31 "2004-03-31T21:18:08Z")

</div>

Actually, skip 13, try this:  
[http://users.adelphia.net/~tlaplaca/sps14.exe](http://users.adelphia.net/%7Etlaplaca/sps14.exe)

This may actual have a fix, in that you’ll be able to exit with the EXIT button. Likely, it still won’t display packet data. (likely it ain’t fixed either…)

---

<div class="post-metadata">

### Author: ![caphis](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@caphis](https://boards.straightdope.com/u/caphis)
#### Post date: [March 31, 2004, 9:29pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/32 "2004-03-31T21:29:48Z")

</div>

> [@Revtim](#):
>
> Actually, skip 13, try this:  
> [http://users.adelphia.net/~tlaplaca/sps14.exe](http://users.adelphia.net/%7Etlaplaca/sps14.exe)
> 
> This may actual have a fix, in that you’ll be able to exit with the EXIT button. Likely, it still won’t display packet data. (likely it ain’t fixed either…)

Loads up as normal, press Start -\> START button Pressed dialog appears, After Getting ListBox Object dialog appears, “START clicked” and “(after getting ClistBox object)” added to listbox.

No hanging this time, but no packets, either. Keep up the good debugging. 😉

---

<div class="post-metadata">

### Author: ![Revtim](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/revtim/32/1042_2.png) [@Revtim](https://boards.straightdope.com/u/Revtim)
#### Post date: [March 31, 2004, 9:40pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/33 "2004-03-31T21:40:00Z")

</div>

Woohoo!!!

There were loops in that code that seemed to be able to handle timeouts (it’s code copied from the WinPCap website that I modified), but apparently not. I added some PeekMessage code into these loops.

Seems obvious now…  
I bet your active connection is the second one, right? The prog is still hard coded to the first.

Now seems a good time to start working on the dialog to prompt the user for which network connection to sniff.

Thanks man, I think I turned the corner. Couldn’t have done it without you.

---

<div class="post-metadata">

### Author: ![caphis](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@caphis](https://boards.straightdope.com/u/caphis)
#### Post date: [March 31, 2004, 9:43pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/34 "2004-03-31T21:43:30Z")

</div>

> [@Revtim](#):
>
> Woohoo!!!
> 
> There were loops in that code that seemed to be able to handle timeouts (it’s code copied from the WinPCap website that I modified), but apparently not. I added some PeekMessage code into these loops.
> 
> Seems obvious now…  
> I bet your active connection is the second one, right? The prog is still hard coded to the first.
> 
> Now seems a good time to start working on the dialog to prompt the user for which network connection to sniff.
> 
> Thanks man, I think I turned the corner. Couldn’t have done it without you.

I believe my active connection is the second one, yeah. Nice job!

When you finish the selection code for choosing an adapter, I’d love to try that one out.

---

<div class="post-metadata">

### Author: ![Bambi\_Hassenpfeffer](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@Bambi\_Hassenpfeffer](https://boards.straightdope.com/u/Bambi_Hassenpfeffer)
#### Post date: [March 31, 2004, 9:57pm UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/35 "2004-03-31T21:57:05Z")

</div>

**Revtim** , with your .14 release, I can see that it’s focusing on the Bluetooth PAN adapter. Seeing that, I decided to start some BT activity – SPS picked up and reported those packets, so it does work. Good job! After you do the device selection dialog, I’d be happy to test it for you also.

---

<div class="post-metadata">

### Author: ![Revtim](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/revtim/32/1042_2.png) [@Revtim](https://boards.straightdope.com/u/Revtim)
#### Post date: [April 1, 2004, 12:23am UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/36 "2004-04-01T00:23:33Z")

</div>

Thanks all.

I’m having some trouble with accessing a control on another dialog, though.

> [@](#):
>
> ```
> Prompt_For_Interface_Dlg dlg; 
> dlg.DoModal();
> 
> CWnd* pCBox = dlg.GetDlgItem(IDC_COMBO1);
> 
> ```

The 1st line refrences the new dialog I made, the prompt for the interface. The dlg.DoModal(); command works fine popping it up (which is only there now for a test).

But, I need to to access the IDC\_COMBO1 ComboBox in the new dialog, to populate it with the interface choices. That’s what the last line is attempting to do, but it fails in some ASSERT deep in the generated code somewhere.

What surprised me is that dlg is NULL after the first line, which makes me think it odd that the dlg.DoModal() works. But looking at other progs, I think that’s OK, at least for DoModal.

Searching on the net, I couldn’t find any other way I could shoehorn into my prog. This method was indeed refrenced by somebody, and it seems logical, except for dlg being NULL.

I also tried

> [@](#):
>
> ```
> Prompt_For_Interface_Dlg *dlg = new Prompt_For_Interface_Dlg;
> dlg-&gt;DoModal();
> 
> CWnd* pCBox = dlg-&gt;GetDlgItem(IDC_COMBO1);
> 
> ```

with no difference.

**caphis** , do have any idea what I’m doing wrong?

---

<div class="post-metadata">

### Author: ![caphis](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@caphis](https://boards.straightdope.com/u/caphis)
#### Post date: [April 1, 2004, 12:39am UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/37 "2004-04-01T00:39:20Z")

</div>

Hmm… I’m not sure, but how about trying it backwards? That is, set a hidden property in the initial form to hold the list, then, in the new dialog, load the values from it?

Does that make any sense?

---

<div class="post-metadata">

### Author: ![Revtim](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/revtim/32/1042_2.png) [@Revtim](https://boards.straightdope.com/u/Revtim)
#### Post date: [April 1, 2004, 12:51am UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/38 "2004-04-01T00:51:56Z")

</div>

But wouldn’t I have the same problem in the new dialog, trying to access the control in the initial dialog?

I also thought about doing it in the intialization of the new dialog, but it doesn’t have an OnInitDialog function, and I cannot see how to add one. When I right click it, the “Add New Event Handler” function is ghosted.

---

<div class="post-metadata">

### Author: ![Revtim](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/revtim/32/1042_2.png) [@Revtim](https://boards.straightdope.com/u/Revtim)
#### Post date: [April 1, 2004, 1:41am UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/39 "2004-04-01T01:41:46Z")

</div>

OK, now I think it’s failing because the dialog’s controls don’t exist until DoModal(), and are gone when it’s done.

I think the solution is to do it in OnInitDialog of the new dialog, but for some reason that handler does not exist. Maybe I need to make a new dialog.

---

<div class="post-metadata">

### Author: ![Revtim](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/revtim/32/1042_2.png) [@Revtim](https://boards.straightdope.com/u/Revtim)
#### Post date: [April 1, 2004, 2:10am UTC](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189/40 "2004-04-01T02:10:32Z")

</div>

Hey, I was able to manually add an OnInitDialog() to the new dialog (and it actually gets called), so I’ll just start using that.

[Previous page](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189.md?page=1)

[Next page](https://boards.straightdope.com/t/anyone-feel-like-testing-my-simple-packet-sniffer/237189.md?page=3)
