Interpreting a Handle’s Access Mask

Monday, August 19, 2013

When opening a handle to a kernel object with some Open* Windows API function (e.g. OpenProcess, OpenThread, OpenEvent, …) an access mask must be specified, indicating the type of access requested from the resulting handle. Requiring too much access may cause the call to fail, so a best practice is to require the only access flags that are needed to get the job done.For example, suppose we want to know when a running process terminates. This requires obtaining a handle to the process in question and calling WaitForSingleObject on that handle. For this, only the SYNCHRONIZE access is required: HANDLE...

Windows 8 & Phone 8 UG August Meeting

Wednesday, August 29, 2012

Last evening we had a User Group meeting in Microsoft Offices in Ra’anana, with a lot of activity and fun. Thank you all for participating!In the first part, we discussed the Windows 8 Store from various angles, end user and developer.In the second part, we discussed Windows Phone 7.x and the upcoming 8, along with other sporadic topics - C++, WinRT, DirectX, COM, XNA, XAML… it was fun! And don’t forget the giveaways!Just as a gentle reminder, out next meeting is on September 13th, where we’ll have an interesting session on “Metro” User Experience and User Interface from an...

Windows Media Foundation: Controlling Camera Properties

Saturday, May 19, 2012

I have blogged about Media Foundation before; it’s the “next generation” of DirectShow, introduced in Windows Vista, enhanced in Windows 7 and further enhanced in Windows 8 (more on that in a future post). One of the tasks I encountered recently was to do a video capture from a camera. This is not too difficult to do (once you understand how Media Foundation works) and there’s even two sample in the SDK. But how do you control various camera properties, such as focus, zoom, white balance, etc.? It turns out Media Foundation does not define any specific interfaces for...

Windows 8: TopMost vs. TopMost

Wednesday, May 16, 2012

In Windows, a Window can be made topmost, by setting an extended style with the value WS_EX_TOPMOST (8), typically provided to CreateWindowEx. A topmost window is always on top of non-topmost windows. Among all topmost windows, the normal z-order rules apply. That is, until Windows 8. A Metro application is built with a topmost window – that makes perfect sense. What about desktop apps? Here’s an empty desktop snapped with a metro app (the desktop itself can be seen as a kind of metro app): Now let’s open Task Manager and make it topmost (Options / Always On...

Win32 and Metro–CreateFile(2)

Thursday, May 3, 2012

When a new Windows version comes out, I’m always curious about the new Windows API (Win32) functions that are added to the release. With Windows 8, things get a little more complicated, as there are desktop apps and there are metro apps. Now, for every Windows API function the documentation states whether this API is valid for desktop apps only or for desktop apps and metro apps. One classic function is CreateFile. This is one of the oldest functions – exists since the very first Windows NT version. In Windows 8, it’s marked for desktop apps only. This may...

GetShellWindow vs. GetDesktopWindow

Saturday, June 18, 2011

In his post about running a process as a standard user from an elevated process, Aaron Margosis uses a technique that gets the access token of the shell process (typically explorer.exe) and uses that token to launch the new process (Sasha Goldshtein also blogged about that). The first thing his code does is try to locate the shell process id. One way is to look for “explorer.exe” in the list of processes, but that’s a bit limiting, as there may be a different shell, or it may have been renamed for whatever reason. His code calls GetShellWindow to...
no comments

C++ 0x, Will you save C++?

Saturday, February 5, 2011

The emerging new standard of C++ (dubbed C++0X, where X was supposed to be a decimal digit, but now can be considered a hexadecimal digit) will probably be finalized and approved this year (probably to become “C++11”), and is supposed to march C++ into a new era of productivity. Will that actually happen? In recent years, I saw declining usage of C++ in “regular”, data driven applications, UI and graphic applications, in lie of other environments, namely .NET and Java. As I do a lot of training, the number of C++ or advanced C++ classes I’ve taught has...
18 comments

Visual Studio 2010 SP1 Beta: What’s new in MFC?

Saturday, December 25, 2010

The recently released Visual Studio 2010 SP1 Beta brings many enhancements and bug fixes found since the product’s launch, most of them in the managed world. However, there are new enhancements to the good(?) old MFC, namely wrapping of some of the Direct2D interfaces. Direct2D is a new layer in the DirectX world, sitting on top of Direct3D, providing high performance and flexible 2D graphics. It was introduced with Windows 7 and Windows 2008 R2, but it’s also possible to install it on Windows Vista. What’s wrong with Direct3D? Nothing, but doing 2D graphics is difficult using the...

Next Windows Platform Developers UG Meeting

Thursday, February 4, 2010

The next meeting will be held on March 23rd, at Microsoft Offices. This is the planned agenda: 17:00-17:30 Gathering 17:30-17:40 – MVP Summit impressions 17:40-18:55 Title: Developing connectivity based products (Bluetooth, Wireless-LAN and GPS) in complex environment – Alon Haze Project management and Software development for Bluetooth, Wireless-LAN and GPS for the handsets market is challenging. The environment is built from demanding cellular customers with strict requirements for low cost, low power, small size and highly integrated products. The development process requires multi-disciplinary...

64 bit process addresses

Sunday, April 12, 2009

native 64 bit processes get a huge address space of 8 TB (instead of the usual 2GB of 32 bit processes). However, to actually get this address space range, the executable image must be linked with the LARGEADDRESSAWARE flag. If it's not, only the lower 2GB will be available. Why is that? Why doesn't a native 64 bit process get automatically the larger address space? I'll leave you to think about this a bit - I'll answer in a few paragraphs. Here's a simple test program: int _tmain(int argc, _TCHAR* argv) {     void* p;     __int64 total...