.NET

All stuff related to .NET.

Protection Error while debugging application

I had a strange debugger problem recently. Tried to debug an application, what was hosting a DirectShow graph and when the application

This happened while the application was running with windbg attached. Breaking-in and listing every thread's call stack I found the one whom was displaying the message box:

4 Id: 338.754 Suspend: 1 Teb: 7ffda000 Unfrozen
ChildEBP RetAddr Args to Child 01b3e020 77d49418 77d5e2a2 00000000 00000000 ntdll!KiFastSystemCallRet
01b3e058 77d561c6 00150af8 00000000 00000001 USER32!NtUserWaitMessage+0xc
01b3e080 77d6a92e 77d40000 001a5fa0 00000000 USER32!InternalDialogBox+0xd0
01b3e340 77d6a294 01b3e49c 00000000 ffffffff USER32!SoftModalMessageBox+0x938
01b3e490 77d95fbb 01b3e49c 00000028 00000000 USER32!MessageBoxWorker+0x2ba
01b3e4e8 77d96060 00000000 001a1b08 00166478 USER32!MessageBoxTimeoutW+0x7a
01b3e51c 77d80577 00000000 022f6f18 022c6c38 USER32!MessageBoxTimeoutA+0x9c
01b3e53c 77d8052f 00000000 022f6f18 022c6c38 USER32!MessageBoxExA+0x1b
01b3e558 022b572c 00000000 022f6f18 022c6c38 USER32!MessageBoxA+0x45
WARNING: Frame IP not in any known module. Following frames may be wrong.
01b3e580 7c91056d 00143ac6 0014379a 00000000 0x22b572c
01b3e6a8 7c9011a7 10000000 00000001 00000000 ntdll!RtlFreeHeap+0x647
01b3e760 7c91c8e4 01b3ed70 01b3ed50 00000000 ntdll!LdrpCallInitRoutine+0x14
01b3e7d0 7c916178 00000000 c0150008 00000000 ntdll!LdrpWalkImportDescriptor+0x205
01b3ea7c 7c9162da 00000000 0016b3d8 01b3ed70 ntdll!LdrpLoadDll+0x3e5
01b3ed24 7c801bb9 0016b3d8 01b3ed70 01b3ed50 ntdll!LdrLoadDll+0x230
01b3ed8c 7752e1b1 01b3ee08 00000000 00000008 kernel32!LoadLibraryExW+0x18e
01b3edb0 7752e0cd 01b3ee08 01b3edd4 01b3edd8 ole32!CClassCache::CDllPathEntry::LoadDll+0x6c
01b3ede0 7752d550 01b3ee08 01b3f0e4 01b3ee00 ole32!CClassCache::CDllPathEntry::Create_rl+0x37
01b3f02c 7752d473 00000001 01b3f0e4 01b3f05c ole32!CClassCache::CClassEntry::CreateDllClassEntry_rl+0xd6
01b3f074 7752d3d1 00000001 0015fcb0 01b3f09c ole32!CClassCache::GetClassObjectActivator+0x195

It seems that the message box is shown, while the system loads the dll and calls the dll's initializing routine. Looking at the function call should tell what component was loaded and causing this trouble.

01b3ed8c 7752e1b1 01b3ee08 00000000 00000008 kernel32!LoadLibraryExW+0x18e

0:004> du 01b3ee08
01b3ee08  "C:\Program Files\Common Files\Ah"
01b3ee48  "ead\DSFilter\NeVideo.ax"

It seems that the problem is caused by the NeVideo.ax, its says "MPEG-1/2/4 & AVC video decoder w/ DxVA". It pretty much looks like that the writer of this vide decoder does not want others to uncover his secrets, so he made the extra effort to detect and disrupt any debugger attached to the process, where this component is loaded.

After unregistering NeVideo.ax there is no problem debugging the app.

Generics, Partial classes, Iterators and anonymous methods.

These are the big things in .NET framework 2.0. Thy are goign to change our code and how we write code:

What's new in Visual Studio.NET 2005

I compiled a list of the new features in Visual Studio.NET 2005. The list is not complete but I try to do my best. I will also add links to articles/documentations for the related subjects. First of all the documentation and the MSDN center ofr Visual Studio 2005 are really usefull. 

and here is my list:

If you have any suggestion or there is a topic I missed, please let me know.

New C# language elements and keywords...

In C# 2.0 there are new language elements like new operator and keywords, for example. 

  • where
  • yield
  • partial
  • :: Operator
  • global
  • pragma directives and pragma warning.
  • conditional attribute classes

The where and yield keywords are for generics and iterators. The partial keyword is for defining partial classes. The :: Operator is called the namespace alias qualifier and is used to create name space aliases. global and :: Operator are used together to access a member from the global namespace. Pragma warnings are used to control compiler warnings and
With conditional attribute classes you can make attributes included or omitted depending on whether a condition compilation symbol is defined or not.

There are also some exisitng keywords what I did not know about it but found them interesting

  • fixed
  • stackalloc

The fixed keyword is for generating pinned variable. When using fixed the variable will not be moved by the Garbage Collector. stackalloc is for allocating structures on the stack.