Question

DirectShow Filter Crashes on QueryInterface sometimes

Asked by: CSecurity

Hi

I'm using this code:
http://tmhare.mvps.org/downloads/vcam.zip

If you check the code, you'll see:

HRESULT CVCamStream::QueryInterface(REFIID riid, void **ppv)
{  
    // Standard OLE stuff
    if(riid == _uuidof(IAMStreamConfig))
        *ppv = (IAMStreamConfig*)this;
    else if(riid == _uuidof(IKsPropertySet))
        *ppv = (IKsPropertySet*)this;
    else
        return CSourceStream::QueryInterface(riid, ppv);

    AddRef();
    return S_OK;
}


After a lot of trace, I see it works well when I call it from AmCap, Yahoo Messenger, MSN, etc.

Just when I load it in Skype, After 3 times calling QueryInterface and those calls go to this part:
        return CSourceStream::QueryInterface(riid, ppv);

After 3-4 times calling that part of code, I get exception and entire Skype.exe crashes...

Any ideas?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-10-27 at 08:58:02ID24847692
Topics

C++ Programming Language

,

DirectX Graphics & Game Programming

,

Game Programming

Participating Experts
2
Points
500
Comments
27

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. DirectShow Filter
    I have created a filter using the DirectShow for playing a file, of my desired format, as a Media File. Making of the filter was a success. I have made a source filter only and the render filter is the default audio device filter. I was able to play the file using...
  2. MSN Messenger and FireWall
    I have MSN messenger, my voice is blocked by the network firewall, as well as my friends vioce (unlike video that is good). My network administrator wont open the ports for voice cause the port range is too large. what to do? what to do?
  3. msn messenger stops responding
    my msn messenger stops responding after each logon i can get it started when i do the following -i reconfigure my norton internet security firewall > personal firewall settings to reconfigure automatic then when i restart msn it works the next time i restart msn it will ag...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: jkrPosted on 2009-10-27 at 09:27:34ID: 25674366

What exception do you get?

 

by: CSecurityPosted on 2009-10-27 at 09:28:10ID: 25674371

You want assembly crash from Olly? I get send error report dialog

 

by: CSecurityPosted on 2009-10-27 at 09:32:33ID: 25674412

In Olly here is crash in Skype module Skype:


00B9018E   85C9             TEST ECX,ECX
00B90190   0F8E 93010000    JLE Skype.00B90329
00B90196   8B6C24 18        MOV EBP,DWORD PTR SS:[ESP+18]
00B9019A   8BDA             MOV EBX,EDX
00B9019C   F7DB             NEG EBX
00B9019E   E8 6DFDFFFF      CALL Skype.00B8FF10
00B901A3   8BF0             MOV ESI,EAX
00B901A5   83EE 01          SUB ESI,1
00B901A8   0FAFF2           IMUL ESI,EDX
00B901AB   037424 14        ADD ESI,DWORD PTR SS:[ESP+14]
00B901AF   894C24 18        MOV DWORD PTR SS:[ESP+18],ECX
00B901B3   85FF             TEST EDI,EDI
00B901B5   8BCE             MOV ECX,ESI
00B901B7   8BD5             MOV EDX,EBP
00B901B9   0F86 59010000    JBE Skype.00B90318
00B901BF   90               NOP
00B901C0   0FB702           MOVZX EAX,WORD PTR DS:[EDX]   <---- CRASH IS HERE

 

by: CSecurityPosted on 2009-10-27 at 09:33:13ID: 25674420

I debugged it with writing each stat to debug log, I see after 8 times calling QueryInterface with different values, 8th call makes it crash

 

by: jkrPosted on 2009-10-27 at 09:36:04ID: 25674463

Well, th eexception code would be more interesting, but from

00B901C0   0FB702           MOVZX EAX,WORD PTR DS:[EDX]

I assume it's 0xc0000005 - and it seems that it is a Skype-related problem, nothing that you can do much about.

 

by: CSecurityPosted on 2009-10-27 at 09:40:40ID: 25674526

But why and how??? I see a lot of webcams make Skype crash, but all of them released an update and fixed the issue, see google for webcam crash in Skype, all of them released an update and fixed it...

What do you think?

 

by: CSecurityPosted on 2009-10-27 at 09:41:38ID: 25674544

More details on Crash:


Registers status on crash:
EAX 00000000
ECX 078DD000
EDX 05109000
EBX FFFFF600
ESP 069FFEC8
EBP 05108B80
ESI 078DCA00
EDI 00000010
EIP 00B901C0 Skype.00B901C0
C 0  ES 0023 32bit 0(FFFFFFFF)
P 0  CS 001B 32bit 0(FFFFFFFF)
A 0  SS 0023 32bit 0(FFFFFFFF)
Z 0  DS 0023 32bit 0(FFFFFFFF)
S 0  FS 003B 32bit 7FFA1000(FFF)
T 0  GS 0000 NULL
D 0
O 0  LastErr ERROR_SUCCESS (00000000)
EFL 00000202 (NO,NB,NE,A,NS,PO,GE,G)
ST0 empty 0.0
ST1 empty 0.0
ST2 empty 0.0
ST3 empty 1.0000000000000000000
ST4 empty 1.0000000000000000000
ST5 empty 20466.832656250000580
ST6 empty 200.00000000000000000
ST7 empty 0.0
               3 2 1 0      E S P U O Z D I
FST 0000  Cond 0 0 0 0  Err 0 0 0 0 0 0 0 0  (GT)
FCW 027F  Prec NEAR,53  Mask    1 1 1 1 1 1


Access Violation when reading 05109000

 

by: jkrPosted on 2009-10-27 at 09:44:52ID: 25674579

>> Access Violation when reading 05109000

Can you check what module is loaded at this address (if any)?

 

by: CSecurityPosted on 2009-10-27 at 09:50:25ID: 25674637

As you may know that address vary on each time, now I got exception in:
05249000

In memory view, I have some garbage data from 0521000 - 05248FF0
and there is no data in 05249000 and again in next memory block I have garbage full of data from 0526000 to 0527000

 

by: jkrPosted on 2009-10-27 at 10:05:58ID: 25674834

Well, anyway, since that happens inside Skype, it is not your fault and you'll hardly be able to fix that. Skype is widely known for it's encryption and obfuscation techniques, and sh*t happens when one does things like that...

 

by: CSecurityPosted on 2009-10-27 at 10:12:36ID: 25674904

I got updates...

It's not related to Skype, Flash also crashes in IE and Firefox, I tried to load my webcam in IE and Firefox with Flash, same happened, got crash there!

 

by: CSecurityPosted on 2009-10-27 at 10:14:49ID: 25674924

This time exception was in Vcam.ax which is our code, exception details:



05C25400   53               PUSH EBX
05C25401   8B5C24 08        MOV EBX,DWORD PTR SS:[ESP+8]
05C25405   55               PUSH EBP
05C25406   8B6C24 10        MOV EBP,DWORD PTR SS:[ESP+10]
05C2540A   56               PUSH ESI
05C2540B   57               PUSH EDI
05C2540C   B9 12000000      MOV ECX,12
05C25411   8BF5             MOV ESI,EBP
05C25413   8BFB             MOV EDI,EBX
05C25415   F3:A5            REP MOVS DWORD PTR ES:[EDI],DWORD PTR DS> <--- Exception here!
05C25417   8B45 40          MOV EAX,DWORD PTR SS:[EBP+40]
05C2541A   85C0             TEST EAX,EAX
05C2541C   74 33            JE SHORT Vcam.05C25451
05C2541E   50               PUSH EAX
05C2541F   FF15 B470C205    CALL DWORD PTR DS:[<&ole32.CoTaskMemAllo>; ole32.CoTaskMemAlloc
05C25425   85C0             TEST EAX,EAX
05C25427   8943 44          MOV DWORD PTR DS:[EBX+44],EAX
05C2542A   75 0F            JNZ SHORT Vcam.05C2543B



Registers status:
EAX 00000000
ECX 00000012
EDX 0000004F
EBX 02F42CA4 ASCII "vids"
ESP 00B0D4B0
EBP 00000000
ESI 00000000
EDI 02F42CA4 ASCII "vids"
EIP 05C25415 Vcam.05C25415
C 0  ES 0023 32bit 0(FFFFFFFF)
P 1  CS 001B 32bit 0(FFFFFFFF)
A 0  SS 0023 32bit 0(FFFFFFFF)
Z 1  DS 0023 32bit 0(FFFFFFFF)
S 0  FS 003B 32bit 7FFDC000(FFF)
T 0  GS 0000 NULL
D 0
O 0  LastErr ERROR_SUCCESS (00000000)
EFL 00000246 (NO,NB,E,BE,NS,PE,GE,LE)
ST0 empty 1.6460435905164033450e+2736
ST1 empty -UNORM EE88 01180000 4000027F
ST2 empty 0.0
ST3 empty 0.0
ST4 empty 0.0
ST5 empty 0.0
ST6 empty 1.0000000000000000000
ST7 empty 15.500000000000000000
               3 2 1 0      E S P U O Z D I
FST 0000  Cond 0 0 0 0  Err 0 0 0 0 0 0 0 0  (GT)
FCW 027F  Prec NEAR,53  Mask    1 1 1 1 1 1


Access Violation when reading 00000000

 

by: jkrPosted on 2009-10-27 at 10:28:11ID: 25675049

What's the source code for that one?

 

by: CSecurityPosted on 2009-10-27 at 10:55:35ID: 25675395

No idea... Because entire code doesn't have call to CoTaskMemAlloc

 

by: jkrPosted on 2009-10-27 at 11:06:09ID: 25675517

Get the Process Explorer (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx) and check which module is loaded at the address 0x05C25400

 

by: CSecurityPosted on 2009-10-27 at 11:33:24ID: 25675802

It is Vcam.ax, our compiled DirectShow filter from source code I said in Q

 

by: jkrPosted on 2009-10-27 at 12:07:15ID: 25676153

Are you linking statically to the DX libs?

 

by: CSecurityPosted on 2009-10-27 at 12:20:49ID: 25676323

Yes

 

by: CSecurityPosted on 2009-10-27 at 12:31:00ID: 25676434

I got doubt about your last question, why do you ask that?

I'm compiling using /MD which will link statically to msvcrt.lib, I have no idea about DX libs...

 

by: jkrPosted on 2009-10-27 at 13:04:07ID: 25676806

>>I got doubt about your last question, why do you ask that?

Since you say you never call 'CoTaskMemAlloc()', there are two options: Code that you are statically linking to does that (msvcrt.lib doesn't) or you are just experiencing that "happily-move-code-around-in-memory" thing that Skype does, and if the latter applies (most likely), we've hit a dead end.

 

by: CSecurityPosted on 2009-10-27 at 13:17:18ID: 25676954

But as I said I get same crash here:
http://oldes.multimedia.cz/swf/mx-webcam.html

It's Macromedia Flash trying to read the webcam, I get crash!

 

by: CSecurityPosted on 2009-10-27 at 13:18:37ID: 25676968

As I said I'm 100% sure it's some failure in QueryInterface on line 17 of Filters.cpp on the project.

QueryInterface is so tricky function, failing to processing requests, ALWAYS causes crash, something is wrong there and in AddRef() function in QueryInterface

 

by: CSecurityPosted on 2009-10-28 at 07:33:05ID: 25683627

Any updates JKR? Did you tried code?

 

by: CSecurityPosted on 2009-10-28 at 11:09:45ID: 25686366

I found solution in text, but I don't know what does it mean... Can you explain?


In order your code to work with Flash Player, you need to implement all neccessary methods like SetFormat/SetMediaType and since DirectShow is rather non friendly interface, you'll spend some time on it.

What's missing in SetFormat/SetMediaType etc. in that code?

 

by: trinitrotoluenePosted on 2009-10-28 at 16:49:40ID: 25689410

yes since its an interface you need to implement all methods exposed by that interface, something similar to over-riding all methods in an abstract base class if you inherit from it.

If Flash Player doesn't require it just return the defaults from these functions....or set the defaults. Check the out type or in type populate a dummy and then code them into the method.

 

by: CSecurityPosted on 2009-10-28 at 23:22:42ID: 25691071

What type of dummy code I should insert?

I tried to return
return CSourceStream::QueryInterface(riid, ppv);

For each query, but it didn't worked...

I tried to AddRef() for each query again not worked.

I tried to return S_OK for each query again not worked.

I think I'm doing something wrong or maybe we should implement all methods properly...

What do you think?

 

by: trinitrotoluenePosted on 2009-10-31 at 16:59:35ID: 25712109

"I tried to return
return CSourceStream::QueryInterface(riid, ppv);

For each query, but it didn't worked..."

you should call QueryInterface only if you need the interface pointer. Do not get an interface pointer if you do not need it.


20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...