Strange unexpected native exception with pInvoke and WZCSetInterfaceEx API

N

nickmachielse

Hi,

We are dealing with a very strange problem and we cannot figure out
where it comes from so we need some help.

Currently we are implementing the new WPA2 and AES features for
Wireless networks to our applications. These features became available
through the Windows CE QFE from noverber 2006. Untill now we are using
the standard Wireless Zero Config API set but with this QFE a couple
of new API's became available for using WPA2 and AES. These new API's
are basically the same as the old ones but they have an "Ex" extention
( for example: WZCSetInterfaceEx ).

We replaced all old API's with the new API's but a strange problem
occured by implementing the WZCSetInterfaceEx API.

We are running the .net compact framework on Windows CE 5.0. Our
application written in C# is calling a native function using pInvoke.
We can reach this native function without any problems. This native
functions calls WZCSetInterfaceEx and here we get the native
exception: "First-chance exception in COREDLL.DLL. (0xC0000005: Access
Violation)".

The strange thing is the we CAN use this same native function called
from our test application which is also written in C# and is using
exactly the same pInvoke class!!!

We compared all data from our testapplication and our main application
and logged all of it hondreds of times but we could not find anything.

Since we do not have source code for the Wireless Zero Config we are
unable to check where this exception exactly comes from.

This is the pInvoke method we call:
[DllImport( PlatformDll, CharSet = CharSet.Auto )]
private extern static int NETWORK_addWifiNetworks( string
networkName, int InfraMode, int AuthMode, int EncrMode, string key,
int keyEap );
public static int addWifiNetworks( string networkName, int
InfraMode, int AuthMode, int EncrMode, string key, int keyEap )
{
int retVal = NETWORK_addWifiNetworks( networkName,
InfraMode, AuthMode, EncrMode, key, keyEap );
return retVal;
}

The native interface:
int NETWORK_addWifiNetworks( WCHAR networkName[], int infraMode, int
authMode, int encrMode, WCHAR key[], int keyEap )

{
.............
 
G

Guest

This doesn't appear to be the WZC call itself, so you're calling som proxy
or shim that you wrote? Do you get the exception every time, or just
sometimes? If we assume that said shim is correct, then my guess (and it's
only a guess since I'm missing a lot of the picture) is that the native call
is asynchronous and that the string pointer you're passing to it is becoming
invalid after the call either due to you destroying it or due to compaction.

We'd need to see your native shim call to know more (and why not just
P/Invoke WZC directly?)


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com



Hi,

We are dealing with a very strange problem and we cannot figure out
where it comes from so we need some help.

Currently we are implementing the new WPA2 and AES features for
Wireless networks to our applications. These features became available
through the Windows CE QFE from noverber 2006. Untill now we are using
the standard Wireless Zero Config API set but with this QFE a couple
of new API's became available for using WPA2 and AES. These new API's
are basically the same as the old ones but they have an "Ex" extention
( for example: WZCSetInterfaceEx ).

We replaced all old API's with the new API's but a strange problem
occured by implementing the WZCSetInterfaceEx API.

We are running the .net compact framework on Windows CE 5.0. Our
application written in C# is calling a native function using pInvoke.
We can reach this native function without any problems. This native
functions calls WZCSetInterfaceEx and here we get the native
exception: "First-chance exception in COREDLL.DLL. (0xC0000005: Access
Violation)".

The strange thing is the we CAN use this same native function called
from our test application which is also written in C# and is using
exactly the same pInvoke class!!!

We compared all data from our testapplication and our main application
and logged all of it hondreds of times but we could not find anything.

Since we do not have source code for the Wireless Zero Config we are
unable to check where this exception exactly comes from.

This is the pInvoke method we call:
[DllImport( PlatformDll, CharSet = CharSet.Auto )]
private extern static int NETWORK_addWifiNetworks( string
networkName, int InfraMode, int AuthMode, int EncrMode, string key,
int keyEap );
public static int addWifiNetworks( string networkName, int
InfraMode, int AuthMode, int EncrMode, string key, int keyEap )
{
int retVal = NETWORK_addWifiNetworks( networkName,
InfraMode, AuthMode, EncrMode, key, keyEap );
return retVal;
}

The native interface:
int NETWORK_addWifiNetworks( WCHAR networkName[], int infraMode, int
authMode, int encrMode, WCHAR key[], int keyEap )

{
............
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top