Showing tag results for Code

Aug 15, 2006
Post comments count0
Post likes count0

Do not change program semantics in the debug build

Raymond Chen
Raymond Chen

What you don't want is a problem that goes away when you debug it. It is expected that a program have additional debugging code inside blocks. After all, that's why it's a debug build. But what you definitely don't want to do is have that debugging to fundamentally change the program's behavior. You can perform additional validation. You can ra...

Code
Aug 1, 2006
Post comments count0
Post likes count0

C# nested classes are like C++ nested classes, not Java inner classes

Raymond Chen
Raymond Chen

When you declare a class inside another class, the inner class still acts like a regular class. The nesting controls access and visibility, but not behavior. In other words, all the rules you learned about regular classes also apply to nested classes. The keyword in an instance methods of a class (nested or not) can be used to access members of...

Code
Jul 10, 2006
Post comments count0
Post likes count0

Before you can learn to recognize what's wrong, you must learn to recognize what's right

Raymond Chen
Raymond Chen

Sometimes, when I'm debugging a problem, I'll ignore a particular thread and somebody will ask, "What is that thread doing, and how did you know to ignore it?" My reply: "I have no idea what it's doing, but whatever it's doing, it's normal." Tess has been running an excellent series of posts on debugging the CLR, but one of the most important le...

Code
Jul 6, 2006
Post comments count0
Post likes count0

Is the maximum size of the environment 32K or 64K?

Raymond Chen
Raymond Chen

There appears to be some confusion over whether the maximum size of the environment is 32K or 64K. Which is it? Both. The limit is 32,767 Unicode characters, which equals 65,534 bytes. Call it 32K or 64K as you wish, but make sure you include the units in your statement if it isn't clear from context.

Code
Jul 3, 2006
Post comments count0
Post likes count0

Security: Don't forget to initialize the stuff you don't care about

Raymond Chen
Raymond Chen

Lost in excitement of privilege escalation vulnerabilities is the simple information disclosure through missing garbage initialization. Everybody should by now be familiar with the use of the function to ensure that buffers that used to contain sensitive information are erased, but you also have to zero out buffers before you write their contents...

Code
Jun 29, 2006
Post comments count0
Post likes count0

Generating tooltip text dynamically

Raymond Chen
Raymond Chen

Our multiplexed tooltip right now is displaying the same string for all items. Let's make it display something a bit more interesting so it's more obvious that what we're doing is actually working. Instead of providing fixed tooltip text, we generate it on the fly by setting the text to and producing the text in response to the notification. ...

Code
Jun 28, 2006
Post comments count0
Post likes count0

Multiplexing multiple tools into one in a tooltip

Raymond Chen
Raymond Chen

The tooltip control lets you set multiple "tools" (regions of the owner window) for it to monitor. This is very convenient when the number of tools is manageably small and they don't move around much. For example, the toolbar control creates a tool for each button. But if you have hundreds or thousands of screen elements with tooltips, creating a ...

Code