Sunday 9 August 2015

How to Debug a Spawned Process from Visual Studio?

Trick question, you can't!!  This is a requested feature. You may need to resort to Attach to Process. This might not work though if the process executes fast.

The Limits of Visual Studio

Visual Studio has its limits. But those limits will be pushed. To vote for which limit you want busted, vote on User Voice. Use your "User voice"!!

Is your Windows Laptop Working or Sleeping - G0 or G1?

Welcome to the World of the Hardware Software Interface on Windows. And how did we get here? How else, except through Device Manager.

Investigating your PC's Power Management Functions Via Device Manager

Anyone who has pulled up Device Manager on a laptop computer running Windows 98 or above, will have seen references to ACPI (Advanced Configuration Power Interface) which is the successor to APM. An example entry in Device Manager would be Computer defined as "ACPI x64 based PC".

The ACPI Specification and Involvement of Various Vendors

ACPI is a thousand page specification that allows Windows to communicate with the BIOS and instruct the BIOS to power down peripherals (the details of the specification are mainly of interest to Independent Hardware Vendors, or IHVs). 

ACPI is a joint effort between Hewlett Packard, Intel, Microsoft, Toshiba, and BIOS entrepreneur Phoenix Technologies Incorporated.

Four Basic States of a Component as Defined by ACPI

Working (G0), Sleeping (G1), Soft Off (G2) and Mechanical Off (G3). Within these global states are various sleep states.

Related Jargon like OSPM and AML

ACPI enables OSPM (Operating System-directed configuration and Power Management). AML is the machine language for ACPI.

The Riddle of the RAM - How Much RAM For Windows? Is 8GB Not Enough?

Let's say a starter computer comes with 8GB RAM, and a more high-end gaming PC comes with 16GB RAM. Windows 8 supports up to 128GB RAM. The more RAM you have, the less you rely on "Virtual Memory"- the magic utilization of hard disk which allows several "heavy memory" applications to run in memory at the same time. "Virtual Memory" is usually implemented as a file, such as pagefile.sys or swapfile.sys.

What causes "PInvokeStackImbalance was detected"?

You are happily debugging your C# code, perhaps forgetting it is interfacing with C libraries, when suddenly a most perplexing "StackImbalance" exception is detected. This is often due to signature mismatch between the DLL code and how it is being interpreted in the managed world. A good tip is to review the CallingConvention used. Common conventions include Cdecl and StdCall depending on whether the caller or callee cleans the stack.