Junfeng Zhang's Windows Programming Notes

Win32, Fusion, CLR, .Net Framework, and others

Browse by Tags

Tagged Content List
  • Blog Post: Windows Performance Tools Kit

    Windows Performance Team has released Windows Performance Tools Kit to the Windows SDK for Windows Server 2008 and .NET Framework 3.5. http://www.microsoft.com/whdc/system/sysperf/perftools.mspx This is the same tool Windows team uses to diagnose Windows performance problem. Along with the tool comes...
  • Blog Post: From Unhandled Exception to Debugger Attach

    I was always wondering what is happening between an application throws an unhandled exception, and a debugger attached to the process. Apparently the information is right under my nose, but I was blind. Windows Debugger's documentation about post-mortem debugging has all the details you want to know...
  • Blog Post: Windows Vista Sxs Activation Context Cache

    Sxs activation model is built on top of Actication Context. To create an activation context, use the API CreateActCtx. Activation Context is used very frequently in Windows. For example, a simple operation like start notepad, open the common file dialog, select a file, will call CreateActCtx many...
  • Blog Post: advantages and disadvantages of delay load (LoadLibrary)

    Some knowledgeable people posted the following wisdom about delay load. Archived here to share. The advantages are that dlls get loaded only when they are used, and you can “statically” bind to an i mport that may not exist at runtime, and as long as you are careful not to call it, the program...
  • Blog Post: RT_MANIFEST resource, and ISOLATION_AWARE_ENABLED

    RT_MANIFEST Since Windows XP, Windows reserves a new type of resource RT_MANIFEST for SxS manifests. Within the RT_MANIFEST resource, Windows reserves ID 1-16. A binary cannot have two IDs of resource type RT_MANIFEST within 1-16. Windows will refuse to load such binary in Windows XP/Windows Server...
  • Blog Post: Diagnose SideBySide failures in Windows XP/Windows Server 2003

    Since I published my article on how to diagnose SideBySide failures , I have received many feedbacks that since Sxstrace is not available in Windows XP/Windows Server 2003, it is hard to figure out what is wrong in Windows XP/Windows Server 2003. This article intends to help people diagnose SideBySide...
  • Blog Post: Activation Context Creation flow

    The following describes how activation context is created currently in Windows XP/Windows Server 2003/Windows Vista. 1. CreateProcess/CreateActCtx is called. 2. CreateProcess/CreateActCtx does some validation, constructs a message, sends the message to CSRSS.exe, and waits for CSRSS.exe to return. 3...
  • Blog Post: Genman32 – A tool to generate Sxs manifest for managed assembly for Registration Free COM/.Net Interop

    Attached to this article is GenMan32, a tool to generate sxs manifest for managed assembly to use in registration free COM/.Net Interop scenario. (For more information about registration free COM/.Net interop, please read http://blogs.msdn.com/junfeng/archive/2006/05/17/595140.aspx .) GenMan32...
  • Blog Post: How to tell if the current user is in administrators group programmatically

    You can use CheckTokenMembership ( http://msdn2.microsoft.com/en-us/library/aa376389.aspx ) to check whether a user is in administrators group. There is an example in the MSDN document. The example will not work in Windows Vista. In Windows Vista, even if the user is in administrators group, the OS...
  • Blog Post: Debugging LoadLibrary Failures

    LoadLibrary is one of the mostly used yet unbelieveably complex APIs in Windows, if not the one. Russ Osterlund has a full MSDN article discussing LoadLibrary , yet he only touches the surface of the problem (how it works under normal condition.) Mike Grier is one of the most talented developers I have...
  • Blog Post: Touch the exe, after you added a manifest for it, in Vista

    You are an enthusiastic and responsible developer. You love programming, and you love programming the right way. So you get the latest and greatest Windows Vista. You try your hard-worked amazing.exe application in Vista. Did not work. Apparently, amazing.exe needs admin privilege to do wonderful...
  • Blog Post: Application Shutdown Changes in Windows Vista

    MSDN documented the Windows Vista changes regarding application shutdown. http://windowssdk.msdn.microsoft.com/en-us/library/ms700677(VS.80).aspx
  • Blog Post: Programmatically determine if an application requires elevation in Windows Vista

    In Windows Vista, by default, application will execute without administrator privilege, even when the user launching the application is part of the administrators group. You can explicitly elevate the application with administrator privilege using the shell "Runas" verb. There are some cases the...
  • Blog Post: Run/RunOnce/RunOnceEx Registry Key

    Run\RunOnce\RunOnceEx are documented ways to automatically run certain tasks when system startup or a user logs in. Run\RunOnce keys are documented here: Run and RunOnce Registry Keys http://windowssdk.msdn.microsoft.com/en-us/library/ms723554.aspx RunOnceEx is documented here: Syntax for the RunOnceEx...
  • Blog Post: Windows XP may reboot when encounter certain manifest files

    If you are developing applications for Windows Vista using Visual Studio 2005, and you are adding Vista UAC manifest to your application, when your application runs on Windows XP with Service Pack 2 or Windows Server 2003 RTM (without SP1), Windows may reboot unexpectly. This is due to a bug in Sxs.dll...
  • Blog Post: COM activation change in Windows Vista

    In Windows Vista, COM will read HKLM\Software\Classes when the process has a integrity level > MEDIUM , and it will read the merged HKLM\HKCU hive otherwise. For information about integrity level, please read Steve Riley's article Mandatory Integrity Control in Windows Vista . This means, for services...
  • Blog Post: Detours

    Still on the topic on knowing what DllRegisterServer does without impacting the system. Before I found RegOverridePredefKey , I was thinking about hijacking all the registry APIs so that I can just record them without actually making any system change. Apparently, I need a way to safely detour those...
  • Blog Post: RegOverridePredefKey

    I was trying to find a way to figure out what changes a particular dll's DllRegisterServer make without actually changing the system. Then I found this: RegOverridePredefKey <quote> Remarks The RegOverridePredefKey function is intended for software installation programs. It allows them to remap...
  • Blog Post: Find out which application handles a certain file extension

    There are times you may wonder which application handles a certain file extension. In Windows there are really two concepts: File Extension and File Type. File extension can be associated to a file type. Applications work on file type, not directly on file extension. You can use assoc to find out...
  • Blog Post: System Services change in Windows Vista

    Every new Windows release introduces new features, which means new APIs. Vista is no different. As Vista is approaching RTM, documentation of new Vista APIs starts to show up on MSDN web site. The following is a short summary of changes in System Services in Windows Vista documented in Vista...
  • Blog Post: Registration Free COM/.Net interop

    In my last article , I briefly discussed how COM, Sxs and CLR work together to make registration free COM/.Net interop possible. Today, I want to dive a bit deeper into this feature. Specifically, I want to discuss 1. How activation works end to end. 2. How to generate manifests for managed assemblies...
  • Blog Post: Condition Variables

    The classic thread synchronization objects are Mutex, Semaphore, and Condition Variable. Windows always has Mutex and Semaphore. Now in Windows Vista, you can also use Condition Variable. Using Condition Variables http://msdn.microsoft.com/library/en-us/dllproc/base/using_condition_variables...
  • Blog Post: Private Object Namespace

    One of the most common Deny Of Service (DOS) attack in Windows is kernel object name squatting . For example, two processes want to access some shared resources. In order to keep the integrality of the shared resources, the two processes will cooperate by waiting on a named event object. The problem...
  • Blog Post: Sxs --- Activation Context, Binding, Policy and Probing

    Sxs’ runtime behavior is built on top of the concept of Activation Context. (For more details on Activation Context, please visit MSDN . I have published an article on it early.) You can use API CreateActCtx to create an activation context. CreateActCtx requires a source manifest. Optionally, you...
  • Blog Post: COM activation, Registration Free COM activation, COM/.Net Interop, Registration Free COM/.Net Interop

    COM is easily one of the most commonly used technologies in Microsoft Windows Platform. Many of Microsoft Windows’ capabilities are only exposed in COM. I do not claim to be a COM expert. But my work in Microsoft in the past and now do affect how people use COM in some way. In this article, I want...
Page 1 of 3 (54 items) 123