Martin's Tex-Blog

Posts on programming and generally technical topics

Archive for the ‘Visual Studio’ Category

Finding buffer overruns and other heap corruptions under Windows

leave a comment »

Windows SDK comes with great tool called debugging tools – it includes small application called gflags that allows to quickly find all buffer overruns and reads of unallocated memory. Actually I would really like to see it integrated in Visual Studio IDE. So how it works. First you register your application with gflags.exe, and then run it. During program testing, system will throw exceptions each time you do something bad with memory (like read or write unallocated regions). Gflags during each allocation will allocate slightly more memory and mark it as non-commited, so any access to it will result in exception which can be easily cought by Visual Studio – yes, after registration with gflags, you can run your program under VS debugger and catch all exceptions, read callstack and all variable contents.

Here is how you register your application with gflags:

gflags /p /enable pheap-buggy.exe /full

so even if your program runs flawlessly, use gflags to find bugs in regions which you would never suspect


Written by Marcin

March 14, 2012 at 11:24 pm

Posted in Visual Studio, Windows

Tagged with

Coloring C++ code for bloging

leave a comment »

Finally got it working  (as seen in previous post). You need Visual Studio (2005 – 2008), and CopySourceAsHtml addin. Actually it might show exceptions and you might need to copy as HTML 2-3 times before it will work. Also after pasting it to wordpress in new post, do not change to Visual, stay with HTML, otherwise your code will get messed up.

not perfect but still it gives best results

[edit] forget about using external tools and use hints from:

Written by Marcin

March 8, 2011 at 11:55 pm

Posted in Visual Studio

When intellisense stops working…

leave a comment »

It happens that intellisense stops working and you no longer see methods for STL containers and other classes. What is most often advised in such situation is to delete .ncb file, since this is such a huge problem, developers from Microsoft thought of fixing this issue by providing macro:

Written by Marcin

October 11, 2009 at 3:45 pm

Posted in Visual Studio