Year: 2009

GSCookie helps in finding buffer overrun cases on the stack and terminates the application when this is detected. In the .NET environment this would happen when calling into a native function when the function overrides the buffer on the stack corrupting the GSCookie put in place. Here is a similar case. I have a sample…

In this article we will be talking about MFC Module state and Thread state , and how do we troubleshoot issues related to Module state mismatch. Why MFC dll does needs a module-specific state? Well reason is MFC is a shared dll, it needs to be shared between various modules (dlls\exe) that are linked with…

Computers are not intuitive; they can predict the future perhaps, but they cannot paint magic doors through the boundaries of traditional logic – at least not yet. Imagine, if you will, a cup-stacking champion during his or her early life. How does one begin stacking cups? Very carefully, as the saying goes. At first, a…

In this blog I am going to talk about Marshal.StructuretoPtr , especially its last parameter fDeleteOld. Although its msdn description is pretty concise but I have seen it to be a source of confusion a lot of times. Following is what it says: fDeleteOld Type: System..::.Booleantrue to have the Marshal..::.DestroyStructure method called on the ptr…

This is one of the interesting scenario in which an unmanaged application built with Non-Microsoft technology was crashing during application shutdown with BOOTUP_EXCEPTION_COMPLUS exception (c0020001). This unmanaged application happened to be using unmanaged dll (built with Microsoft compiler) which in turn used IJW (a.k.a. C++ Interop) to interact with windows forms and create some ActiveX…

1. How do I know which dll/control needs to be rebuilt? Please check the guidelines to understand if your dll/control could be affected or not. Installing the Visual Studio ATL Security patch and rebuilding the binaries alone will not mitigate the vulnerability. You may need to make code changes as given in the document. …

Most of the developers work with CToolBarCtrl but they get stuck when it comes to display chevron button. This article is all about how to get chevron button displayed on CToolBarCtrl control while resizing its content window. There is a good MSDN article on handling chevrons but no good sample implementation on it. I wrote a small…

Internal Mechanism Internally the Visual Studio IDE interacts with editor and the language parsers to create a list of tokens that are updated frequently. In this process the background threads continuously update the Intellisense database. The priority of threads change automatically to make sure that the database is updated as and when user writes the…

Suppose you are calling some native code from your managed code, and you observe an Access Violation crash soon after returning from the native code inside your managed code. if you run the application inside the Visual Studio debugger you will see the following exceptions in the output window if IDE. First-chance exception…

I am back with some more PInvoke Stuff. Recently I was working on a PInvoke issue which I found interesting. I have a C++ dll which has a function whose signature is int TestFunc(IN_STRUCT in_Params, RET_STRUCT * pret_Par). I wanted to call this function from C#. Function has two arguments. First argument is input structure…