Log in

View Full Version : problem when registering a directshow filter with regsvrce in windows 6


Rabal
04-17-2008, 03:34 PM
Hi all,

I'm a newcomer in Windows Mobile developement. I try to create and register a DirectShow filter for Windows mobile 5 or 6.

1. I create a new SmartDevice Win32 DLL project with ATL option checked in Visual studio 2008.

2. I write the .h, .def and .cpp following MSDN documentation : http://msdn2.microsoft.com/en-us/library/aa451266.aspx (see the code further down).

3. I copy the tool 'regsvrCE' onto the emulator file system, along with the generated SampleGrabber.dll.

4. When I try to register 'SampleGrabber.dll' with regsvrce.exe, the emulator crashes, and the error I get is:

--------------------------------------------------------------------------------------------------------------------------------------
A problem has occured with regsvr_arm.exe

Please tell Microsoft about this problem, at no cost to you. The data is used exclusively to improve products.

Report Details :
----------------

This error report includes information regarding the condition of regsvr_arm.exe when problem occured.

TO view our data collection policy on the web, select here
To view technical information contained in this error report, select here

The report also includes information about the operating system version and device hardware you use and the internet Protocol (IP) adress of your device.

We do not intentionally collect your files, name, address, email address or any other form of personally identifiable information. However, this error report could contain customer-specific information such as data from open files. While this information could potentially be used to determine your identity, if present, it will not be used.

The data that collect will only be used to fix the problem. If more information is available, we will tell you when your report the problem. This error report will be sent using a secure connection to a database with limited access and will not be used for marketing purposes.


Error Reporting :
-----------------

Bucket Parameters
-----------------

EvntType : WinCE50lbException
AppName : regsvr_arm.exe
AppVer : 1.0.0.1
AppStamp : 40c4830c
ModName : samplegrabber.dll
ModVer : 5.2.0.0
ModStamp : 480718e5
Offset : 00001388
OwnName : regsvr_arm.exe
OwnVer : 1.0.0.1
OwnStamp : 40c4830c

Exception Information
---------------------

API Cur Process : 0x00000000
API cur Thread : 0x00000000
API Own Process : 0x00000000
Info Flags : 0x00000000
Current Process : 0x16C2C68A
Faulting Thread : 0x16CBAAD6
Owner Process : 0x16C2C68A
Code : 0x00000005
Flags : 0x00000000
Record : 0x00000000
Address : 0x019C1388
Parameters : 2
Param[0] : 0x00000000
Param[1] : 0x24000001

System Information
------------------
OS Version : 5.2.1235.3
LCID : 1033
CPU Architec : 5
CPU Type : 2577
CPU Level : 4
CPU Revision : 1
Machine : 0x01C2
OEM String : Microsoft dev
Platform : PocketPC
Platform Ver : 4.0

Process List
------------
Name, hProcess
NK.EXE, 0x17FFF002
gwes.exe, 0x7791D296
regsvr_arm.exe, 0x16C2C68A

Thread List
-----------
hThread
0xD6815146
0x7695CB56
0x16CBAAD6

Thread Context List
-------------------
ThreadID, Pc
0x16CBAAD6, 0x019C1388

Thread Call Stack List
----------------------
PID = 16C2C68A, TID = 16CBAAD6
--------------------------------------------------------------------------------------------------------------------------------

Can you tell me what I did wrong in my code?

Did I miss an option in Visual Studio at compiling or linking?

Am I starting from the right Visual Studio project type??

Your help is greatly appreciated.




Code :
--------------------------------------------------------------------------------------------------------------------------------------
-----------------
SampleGrabber.def
-----------------

LIBRARY "SampleGrabber.dll"

EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE

---------------
SampleGrabber.h
---------------

#include <windows.h>
#include <streams.h>
#include <initguid.h>

// {75C097E9-6655-45e1-B81D-5A5D2379FFD1}
DEFINE_GUID(CLSID_CSampleGrabber, 0x75c097e9, 0x6655, 0x45e1, 0xb8, 0x1d, 0x5a, 0x5d, 0x23, 0x79, 0xff, 0xd1);

class CSampleGrabber : public CBaseRenderer
{
public:

DECLARE_IUNKNOWN

CSampleGrabber(LPUNKNOWN pUnk, HRESULT *phr);

static CUnknown* WINAPI CreateInstance(LPUNKNOWN punk, HRESULT *phr);

HRESULT CheckMediaType( const CMediaType *pMT);

// This is called for each media sample received.
HRESULT DoRenderSample(IMediaSample *pMediaSample) ;

ULONG NonDelegatingRelease();

// this is necessary for automatic registration of the filter when doing
// a regsvr32.
AMOVIESETUP_FILTER *GetSetupData();

private:

};

-----------------
SampleGrabber.cpp
-----------------

#include "stdafx.h"
#include "SampleG.h"

// Fill in media type information below, this information is used when registering the filter with dshow
const AMOVIESETUP_MEDIATYPE sudPinTypes = {&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL };

const AMOVIESETUP_PIN sudPins = {
L"SampleGrabber", // Pin string name.
FALSE, // Is this pin rendered?
FALSE, // Is it an output pin?
FALSE, // Can the filter create zero instances?
FALSE, // Does the filter create multiple instances?
&CLSID_NULL, // Connects to filter.
NULL, // Connects to pin.
1, // Number of media types.
&sudPinTypes // Pointer to media types.
};

const AMOVIESETUP_FILTER sudNULL = {
&CLSID_CSampleGrabber, // Filter CLSID.
L"SampleGrabber", // Filter name.
MERIT_DO_NOT_USE, // Merit.
1, // Number of pin types.
&sudPins // Pointer to pin information.
};


// this is necessary for automatic registration of the filter when doing a regsvr.
AMOVIESETUP_FILTER* CSampleGrabber::GetSetupData() {return((AMOVIESETUP_FILTER*)&sudNULL);}

// this is needed for COM to register the component with RegSvr
extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);

CFactoryTemplate g_Templates[1] = {
L"SampleGrabber", // Name
&CLSID_CSampleGrabber, // CLSID
CSampleGrabber::CreateInstance, // Method to create an instance of MyComponent
NULL, // Initialization function
&sudNULL // Set-up information (for filters)
};
int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);


BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
g_hInst = (HINSTANCE) hModule;
return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved);
}

STDAPI DllRegisterServer()
{
return AMovieDllRegisterServer2( TRUE );
}

STDAPI DllUnregisterServer()
{
return AMovieDllRegisterServer2( FALSE );

}

CSampleGrabber::CSampleGrabber(LPUNKNOWN pUnk, HRESULT *phr) : CBaseRenderer(CLSID_CSampleGrabber, NAME("CSampleGrabber"), pUnk, phr)
{ }

CUnknown* WINAPI CSampleGrabber::CreateInstance(LPUNKNOWN punk, HRESULT *phr)
{
return new CSampleGrabber(punk, phr);
}

HRESULT CSampleGrabber::CheckMediaType( const CMediaType *pMT)
{
return S_OK;
}

// This is called for each media sample received.
HRESULT CSampleGrabber::DoRenderSample(IMediaSample *pMediaSample)
{
return S_OK;
}

ULONG CSampleGrabber::NonDelegatingRelease()
{
return 0;
}

--------------------
SampleGrabber.vcprog
--------------------


<visualstudiouserfile>
ProjectType="Visual C++"
Version="9,00"
ShowAllFiles="false"
>
<configurations>
<configuration>
Name="Debug|Windows Mobile 6 Professional SDK (ARMV4I)"
>
<debugsettings>
Command=""
WorkingDirectory=""
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="ALEXANDRE-PC"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor="5"
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
<deploymenttool>
DeploymentDevice="d1a7b239-28d5-4485-9b8c-5764e3dc79b6"
/>
<debuggertool>
RemoteExecutable=""
Arguments=""
/>
</debuggertool>
<configuration>
Name="Release|Windows Mobile 6 Professional SDK (ARMV4I)"
>
<debugsettings>
Command=""
WorkingDirectory=""
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="ALEXANDRE-PC"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor="5"
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
<deploymenttool>
DeploymentDevice="d1a7b239-28d5-4485-9b8c-5764e3dc79b6"
/>
<debuggertool>
RemoteExecutable=""
Arguments=""
/>
</debuggertool>
</deploymenttool>
</debugsettings></configuration></deploymenttool></debugsettings></configuration></configurations></visualstudiouserfile></initguid.h></streams.h></windows.h>