Monthly Archives: June 2011

The Things You Spot During Code Reviews

I was doing an informal code review the other day, and I ran into some code that I thought would make a fascinating blog post. It had to do with a pure virtual destructor declaration, followed by the same destructor’s … Continue reading

Posted in C/C++ | Tagged , | Leave a comment

Hiding in Plain Sight

Sometimes, the hardest bugs to find are the ones that hide in plain sight. They’re the sort of bug where your eyes skim over the offending code and your brain continuously says “yup, fine, right, good, yup” and you can’t … Continue reading

Posted in C/C++ | Tagged , , , | Leave a comment

Remote Thread Injection on Windows

I happened to have a legitimate case where I needed to inject a thread into another process, and in the process of solving this problem I realized there’s very little accurate information on the topic of remote thread injection available … Continue reading

Posted in Win32 | Tagged , | 2 Comments

Function Pointer Basics

At their core, functions are nothing more than a location in memory with some special semantics attached to them. The assumption is that the location in memory is the start of some machine code to be executed, and that there … Continue reading

Posted in C/C++ | Tagged | Leave a comment

Allocations and Exceptions

One of the things I dislike about many programming languages are exceptions. They go against the natural flow of thinking for most programmers. We tend to think of code as flowing in one direction only: forward. But with exceptions, code … Continue reading

Posted in C/C++ | Tagged , , | Leave a comment

When Should You Use const_cast?

C++ provides an explicit casting mechanism called const_cast, and yet the question pops up: when would I ever use this? You can always assign a non-const value to a const value without requiring a cast operation. So you don’t need … Continue reading

Posted in C/C++ | Tagged , , | 7 Comments

When Const isn’t Const, it’s Mutable

I’m a programmer who strives to write const-correct code. I’ll admit that it can be challenging, but once you get used to doing it, your code is generally cleaner and more maintainable. This happens at the expense of flexibility. When … Continue reading

Posted in C/C++ | Tagged , | Leave a comment

Deleted Class Methods

One of the new features in C++0x is a declaration syntax allowing you to remove methods from a class entirely. While this may sound rather strange at first blush, it does have some interesting usages that will make your code … Continue reading

Posted in C/C++ | Tagged , , | Leave a comment