views:

152

answers:

1

I have a windows mobile solution which contains two projects. One written in C# and another in C++ (unmaneged code that compiles into a dll). The part written in C# invokes some C++ functions from dll to connect to a server.

If I open my application and I connect to the server everything works ok. If I minimize it , or if I open another windows mobile application over my application and try again to connect to the server it fails with a native exception code. (Exception code: 0xc000001d.)

Any idea what happens to my native code when I minimize my application? Why it doesn't work anymore? The error appears both on emulator and target device. I use Windows 6.1 Professional and CF 3.5

+1  A: 

Exception code 0xc000001d is STATUS_ILLEGAL_INSTRUCTION. I.e. the code tried to run an instruction which doesn't belong to the processor's instruction set.

This could be because of many reasons:

  • stack corruption (because of overflow in arrays)
  • corrupted dll/binary

See the code that handles window state changes (minimize/maximize/restore). See if any calls to functions like memcpy, strcpy, etc. are ajar. These are unsafe functions for which secure equivalents are available with a _s suffix. Check if some raw pointer/array manipulation writes beyond it's boundary to cause a stack corruption. Also check the integrity of the dll, if you're sure it's because of the code in the dll.

Edit:

If you've the DLL's source with you, build it with the map file generation ON (Linker Param: /MAPINFO:EXPORTS). And when the exception is thrown, usually you'll get a address inside the binary where the crash happens; this can be looked-up in the map file, to know the exact function where it crashes (it it's a stack corruption the exact function will only help a little, but it'll give the corruption's vicinity). See this article for further details.

legends2k