Showing tag results for Code

Oct 31, 2008
Post comments count0
Post likes count1

Working with ambiguous and invalid points in time in managed code

Raymond Chen

Public Service Announcement: Daylight Saving Time ends in most parts of the United States this weekend. I pointed out some time ago that Win32 and .NET deal with daylight saving time differently. Specifically, Win32 always deals with the time zone you are currently in (even if it's not the time zone that corresponds to the timestamp you are mani...

CodeTime
Oct 27, 2008
Post comments count0
Post likes count1

If you don’t want to try to repair the data, then don’t, but you should at least know that you have corrupted data

Raymond Chen

When I wrote about understanding the consequences of , I mentioned that one of the possible responses was to try to repair the damage, but some people are suspicious of this approach. Mind you, I'm suspicious of it, too. Repairing corruption is hard. You have to anticipate the possibility, create enough of a trail to be able to reconstruct the ...

Code
Oct 24, 2008
Post comments count0
Post likes count1

Sucking the trap frame out of a kernel mode stack trace

Raymond Chen

If you are placed in the unfortunate position of having to debug a user-mode crash from kernel mode, one of the first things you have to do is get back to the exception on the user-mode side so you can see what happened. We saw earlier how you can get symbols for operating system binaries to help you suck the exception pointers out of a user-mode...

Code
Oct 20, 2008
Post comments count0
Post likes count1

Why can’t you thunk between 32-bit and 64-bit Windows?

Raymond Chen

It was possible to use generic thunks in 16-bit code to allow it to call into 32-bit code. Why can't we do the same thing to allow 32-bit code to call 64-bit code? It's the address space. Both 16-bit and 32-bit Windows lived in a 32-bit linear address space. The terms 16 and 32 refer to the size of the offset relative to the selector. Oka...

Code
Oct 16, 2008
Post comments count0
Post likes count1

Psychic debugging: Why your thread is spending all its time processing meaningless thread timers

Raymond Chen

I was looking at one of those "my program is consuming 100% of the CPU and I don't know why" bugs, and upon closer investigation, the proximate reason the program was consuming 100% CPU was that one of the threads was being bombarded with messages where the is . The program was dispatching them as fast as it could, but the messages just kept on c...

Code
Oct 10, 2008
Post comments count0
Post likes count1

How do I suppress the CapsLock warning on password edit controls?

Raymond Chen

One of the features added to version 6 of the shell common controls is a warning balloon that appears if CapsLock is on in a password control. Let's demonstrate. Take the scratch program, add a manifest that requests version 6 of the common controls (perhaps by using a Visual C++ extension), and add the following: BOOL OnCreate(HWND ...

Code
Oct 9, 2008
Post comments count0
Post likes count1

How can I increase the number of files I can open at a time?

Raymond Chen

People who ask this question invariably under-specify the question. They just say, "How can I increase the number of files I can open at a time?" without saying how they're opening them. From the operating system's point of view, the number of files you can open at a time is limited only by available resources. Call until you drop. (This remark ap...

Code
Oct 3, 2008
Post comments count0
Post likes count1

Acquire and release sound like bass fishing terms, but they also apply to memory models

Raymond Chen

Many of the normal interlocked operations come with variants called InterlockedXxxAcquire and InterlockedXxxRelease. What do the terms Acquire and Release mean here? They have to do with the memory model and how aggressively the CPU can reorder operations around it. An operation with acquire semantics is one which does not permit subsequent me...

Code
Sep 29, 2008
Post comments count0
Post likes count1

Anybody can make up a generic mapping

Raymond Chen

Each component that uses ACLs to control access has its own idea of what GENERIC_READ, GENERIC_WRITE, and GENERIC_EXECUTE mean. It's not like there's a master list that somebody can make that lists them all, because I can make up a new one right here. Watch me: #define GIZMO_QUERY_STATUS 0x0001 #define GIZMO_QUERY_MEMBERS 0x0002 #define GIZM...

Code
Sep 26, 2008
Post comments count0
Post likes count2

ERRORLEVEL is not %ERRORLEVEL%

Raymond Chen

The command interpreter cmd.exe has a concept known as the error level, which is the exit code of the program most recently run. You can test the error level with the IF ERRORLEVEL command: IF ERRORLEVEL 1 ECHO error level is 1 or more <sidebar> The IF ERRORLEVEL n test succeeds if the error level is n or more. This was presumably becaus...

Code