Category Archives: Work

(Русский) Очень знакомо

Sorry, this entry is only available in Russian.

(Русский) Селфи!

Sorry, this entry is only available in Russian.

Peephole security camera from old Android phone


This post is about how to properly recycle your old Android smartphone. By “recycling” I mean not tossing it in the bin at your local electronic store, but giving it a proper new use. It’s been only a few years since explosive expansion of smartphones began, but already a lot of us have one or two “old” models lying around gathering dust. If you give it a bit of thought, you realize that it’s a highly capable supercomputer you have there doing absolutely nothing! People have been flown to the Moon and back using less computing power that your old pocket companion has! I think these old-ish smartphones are great platform for something very useful. For instance, even older ones have quite a decent camera, support several network standards and, when connected to a power source, have a battery-backed power that will allow them to run for hours. It’s a great platform for highly autonomous and powerful surveillance system! Ladies and gentleman, I am proud to present you  the “Peephole Security Camera” application for Android. Get it on Google Play, enter your e-mail in settings and you get yourself an automatic assistant that can be left watching your house when you are out. Unlike most video-surveillance systems that accumulate hours of mostly static video you’ll never watch, it works in a lot smarter way. It analyzes video feed from device’s camera to detect motion in a picture. When something moves, you get an instant e-mail with a few images in it, and it will keep taking pictures and sending you updates until motion stops. And that’s all most people ever need from remove surveillance system.

Use cases

Peephole camera

That was the original intention for this app. It requires no modification to your peephole or your door, just get a pack of these highly versatile Velcro strips with adhesive layer. Attach them to the back of the phone IMG_9685 Read more »

(Русский) Пользуясь случаем, хочу пожелать ынженерам HP щасливаго Рождества

Read more »

(Русский) Проклятье C++ программиста

Sorry, this entry is only available in Russian.

(Русский) Время кидаться пальцами

(Русский) Докатился…

boost::context and SEH

I have been using boost::context library to implement coroutines in my project since this library was officially released with boost 1.52. We desperately needed an option to replace win32 fibers (there is always at least a couple of points to justify such move), and boost::context came in just right.

It all worked fine until lately, when we discovered a very odd thing that was happening only on Windows Server 2008. If an exception was raised from within the context, the application was immideately closed by the OS. Even though that exception was handled in place.

As it turned, Windows Server 2008 has so-called SEH overwrite protection mechanism enabled by default. In shirt, every time exception is raised, the OS first checks that nobody messed with exception registration pointers. Each thread, or, broadly speaking, each parallel stack has its own exception registration information (pointer to which appears to be on the top of the thread info block or at FS:[0]). That registration record contains a pointer to exception handler and a pointer to the previous record in a chain (so, you can have a list of exception handlers). When user code wants to raise an exception, SEHOP protection mechanism of Windows Server 2008 walks back this list to make sure it always ends with a handler provided by the OS itself.

And here is the problem – with boost::context library you end up with parallel execution stacks, each of which having different thread information blocks (TIBs). And, while this library correctly initialized the TIB, in version 1.52 it didn’t bother replicating list of handlers from the original thread. Basically, it’s prev pointer was pointing somewere but definitely not where OS would expect it to point. It does not like it at all, and bang, your process is shot.

This SEHOP mechanism is explained in details on technet, and a lot of useful infomration about SEH could be found on microsoft website.

Apparently, a number of people implementing custom coroutine mechanism run into this issue before. Boost 1.53 has updated and fixed version of boost::context library that addresses exactly this problem.

BTW, SEHOP is included in Vista and Windows 7, is disabled by default, but can be enabled. List of known issues is quite impressive though:

After you enable SEHOP, existing versions of Cygwin, Skype, and Armadillo-protected applications may not work correctly.

First one!

My first published Android app

Get it on Google Play

It’s actually a small part of larger application I was working on lately.

(Русский) Программерское

0 visitors online now
0 guests, 0 bots, 0 members