Windows Junction Detection and Processing Windows Junction Detection and Processing

from ctypes import *
from ctypes.wintypes import *

kernel32 = WinDLL('kernel32')
UCHAR = c_ubyte

GetFileAttributesW = kernel32.GetFileAttributesW
GetFileAttributesW.restype = DWORD
GetFileAttributesW.argtypes = (LPCWSTR,) #lpFileName In


CreateFileW = kernel32.CreateFileW
CreateFileW.restype = HANDLE
CreateFileW.argtypes = (LPCWSTR, #lpFileName In
                        DWORD,   #dwDesiredAccess In
                        DWORD,   #dwShareMode In
                        LPVOID,  #lpSecurityAttributes In_opt
                        DWORD,   #dwCreationDisposition In  
                        DWORD,   #dwFlagsAndAttributes In
                        HANDLE)  #hTemplateFile In_opt

CloseHandle = kernel32.CloseHandle
CloseHandle.restype = BOOL
CloseHandle.argtypes = (HANDLE,) #hObject In


DeviceIoControl = kernel32.DeviceIoControl
DeviceIoControl.restype = BOOL
DeviceIoControl.argtypes = (HANDLE,  #hDevice In
                            DWORD,   #dwIoControlCode In
                            LPVOID,  #lpInBuffer In_opt
                            DWORD,   #nInBufferSize In
                            LPVOID,  #lpOutBuffer Out_opt
                            DWORD,   #nOutBufferSize In
                            LPDWORD, #lpBytesReturned Out_opt
                            LPVOID)  #lpOverlapped Inout_opt


    _fields_ = (('DataBuffer', UCHAR * 1),)

    _fields_ = (('SubstituteNameOffset', USHORT),
                ('SubstituteNameLength', USHORT),
                ('PrintNameOffset', USHORT),
                ('PrintNameLength', USHORT),
                ('Flags', ULONG),
                ('PathBuffer', WCHAR * 1))
    def PrintName(self):
        arrayt = WCHAR * (self.PrintNameLength // 2)
        offset = type(self).PathBuffer.offset + self.PrintNameOffset
        return arrayt.from_address(addressof(self) + offset).value

    _fields_ = (('SubstituteNameOffset', USHORT),
                ('SubstituteNameLength', USHORT),
                ('PrintNameOffset', USHORT),
                ('PrintNameLength', USHORT),
                ('PathBuffer', WCHAR * 1))
    def PrintName(self):
        arrayt = WCHAR * (self.PrintNameLength // 2)
        offset = type(self).PathBuffer.offset + self.PrintNameOffset
        return arrayt.from_address(addressof(self) + offset).value

class REPARSE_DATA_BUFFER(Structure):
    class REPARSE_BUFFER(Union):
        _fields_ = (('SymbolicLinkReparseBuffer', 
    _fields_ = (('ReparseTag', ULONG),
                ('ReparseDataLength', USHORT),
                ('Reserved', USHORT),
                ('ReparseBuffer', REPARSE_BUFFER))
    _anonymous_ = ('ReparseBuffer',)

def islink(path):
    result = GetFileAttributesW(path)
        raise WinError()
    return bool(result & FILE_ATTRIBUTE_REPARSE_POINT)

def readlink(path):
    reparse_point_handle = CreateFileW(path, 
                                       FILE_FLAG_OPEN_REPARSE_POINT |
    if reparse_point_handle == INVALID_HANDLE_VALUE:
        raise WinError()
    target_buffer = c_buffer(MAXIMUM_REPARSE_DATA_BUFFER_SIZE)
    n_bytes_returned = DWORD()
    io_result = DeviceIoControl(reparse_point_handle, 
                                None, 0,
                                target_buffer, len(target_buffer),
    if not io_result:
        raise WinError()
    rdb = REPARSE_DATA_BUFFER.from_buffer(target_buffer)        
    if rdb.ReparseTag == IO_REPARSE_TAG_SYMLINK:
        return rdb.SymbolicLinkReparseBuffer.PrintName
    elif rdb.ReparseTag == IO_REPARSE_TAG_MOUNT_POINT:
        return rdb.MountPointReparseBuffer.PrintName
    raise ValueError("not a link") Jordan Sissel Jordan Sissel

My name is Jordan Sissel, and I’m a geek.

In short one paragraph: I’m a hacker. My hack projects don’t always deal with computing. I tinker, I fiddle, I break, and I build. Doctors call it Attention Deficit Hyperactivity Disorder. I call it life.. My style is a bit of charisma, a bit of dork, a bit of shy, and a bit of spontaneity held together with duct tape and super glue and sprinkled with a healthy dose of uncertainty.

How did I get here? (aka, the path to geek)
Before I went to RIT (college), I knew precisely squat about Unix, Linux, Open Source, Free Software, the whole shebang. That all changed when I came to Computer Science House. I quickly was flooded with various buzz words; people trying to sway my tender, fragile, Windows-weenie mind towards someone’s favorite *nix. I ended up becoming fond of FreeBSD over the alternatives Linux had to offer. Turns out that everything sucks, it is only to which degree a particular item sucks that determines it’s value. I tend to use the thing that sucks least for a particular task.

Throughout my time at RIT, I’ve learned more about computing outside of class than I did in class. I’ve found that structured academia is a poor substitute for self-guided exploration.

So what now? I spent my first two years out of college working at Google, which was awesome and full of learning. I also write thousands of lines of code and play with lots of software in my own pursuit of knowledge. Most of my productive and research efforts can be found on this website in the form of articles, projects, code snippets, oneliners, and other research.

However, when I’m not entrenched writing code or doing random research, I’ll be spending my time with my very loving girlfriend fiancée wife and our doggy. Beyond those interests, I like biking, swimming, playing ice hockey, rollerblading, skateboarding, and rocking out (whatever that entails).

About this site’s name:
To fully encompass my dorkiness, I made perl help me pick a domain name. Read about how I picked it here. The fact that ‘semicomplete’ is a valid sed(1) expression further illustrates my dorkiness.

About this site:
I figured ‘semicomplete’ is a fairly good description of me and my pursuits. Most of my personal projects never get finished because the goals were achieved long before completion of the project, and my search for knowledge (mostly in computing) is also never-ending. Anything I learn will be shared on this site, given the opportunity. Examining the effects of birth order on personality Examining the effects of birth order on personality

Julia M. Rohrer /a/,
Boris Egloff /b/, and
Stefan C. Schmukle /a/

/a/ Department of Psychology, University of Leipzig, 04109 Leipzig, Germany;
/b/ Department of Psychology, Johannes Gutenberg University of Mainz, 55099 Mainz, Germany

This study examined the long-standing question of whether a person’s position among siblings has a lasting impact on that person’s life course. Empirical research on the relation between birth order and intelligence has convincingly documented that performances on psychometric intelligence tests decline slightly from firstborns to later-borns. By contrast, the search for birth-order effects on personality has not yet resulted in conclusive findings. We used data from three large national panels from the United States (n = 5,240), Great Britain (n = 4,489), and Germany (n = 10,457) to resolve this open research question. This database allowed us to identify even very small effects of birth order on personality with sufficiently high statistical power and to investigate whether effects emerge across different samples. We furthermore used two different analytical strategies by comparing siblings with different birth-order positions (i) within the same family (within-family design) and (ii) between different families (between-family design). In our analyses, we confirmed the expected birth-order effect on intelligence. We also observed a significant decline of a 10th of a SD in self-reported intellect with increasing birth-order position, and this effect persisted after controlling for objectively measured intelligence. Most important, however, we consistently found no birth-order effects on extraversion, emotional stability, agreeableness, conscientiousness, or imagination. On the basis of the high statistical power and the consistent results across samples and analytical designs, we must conclude that birth order does not have a lasting effect on broad personality traits outside of the intellectual domain. Java call stack – from HTTP upto JDBC as a picture Java call stack – from HTTP upto JDBC as a picture

Created this by pasting together a few screenshots from a NetBeans profiler session – of a Spring + Hibernate web-app running within JBoss. Quite interesting to see how the business logic is just a tiny part of it all.

Java EE is a lot about abstractions which I have grown to appreciate over the years. However, I find this very difficult to explain to my colleague who sits just across the room – he is a Mainframe veteran with tons of experience 🙂 in fact I have not shown this to him yet!

You can download a better PDF version of this which you can expand and zoom to your hearts content. Dennis Ritchie Day Dennis Ritchie Day

Sunday, October 16 was declared Steve Jobs Day by California’s Governor Brown. I admire Brown for taking a step to recognize Jobs’ extraordinary contributions, but I couldn’t help be struck by Rob Pike’s comments on the death of Dennis Ritchie a few weeks after Steve Jobs. Pike wrote:

I was warmly surprised to see how many people responded to my Google+ post about Dennis Ritchie’s untimely passing. His influence on the technical community was vast, and it’s gratifying to see it recognized. When Steve Jobs died there was a wide lament — and well-deserved it was — but it’s worth noting that the resurgence of Apple depended a great deal on Dennis’ work with C and Unix.

The C programming language is quite old now, but still active and still very much in use. The Unix and Linux (and Mac OS X and I think even Windows) kernels are all C programs. The web browsers and major web servers are all in C or C++, and almost all of the rest of the Internet ecosystem is in C or a C-derived language (C++, Java), or a language whose implementation is in C or a C-derived language (Python, Ruby, etc.). C is also a common implementation language for network firmware. And on and on.

And that’s just C.

Dennis was also half of the team that created Unix (the other half being Ken Thompson), which in some form or other (I include Linux) runs all the machines at Google’s data centers and probably at most other server farms. Most web servers run above Unix kernels; most non-Microsoft web browsers run above Unix kernels in some form, even in many phones.

And speaking of phones, the software that runs the phone network is largely written in C.

But wait, there’s more.

In the late 1970s, Dennis joined with Steve Johnson to port Unix to the Interdata. From this remove it’s hard to see how radical the idea of a portable operating system was; back then OSes were mostly written in assembly language and were tightly coupled, both technically and by marketing, to specific computer brands. Unix, in the unusual (although not unique) position of being written in a “high-level language,” could be made to run on a machine other than the PDP-11. Dennis and Steve seized the opportunity, and by the early 1980s, Unix had been ported by the not-yet-so-called open source community to essentially every mini-computer out there. That meant that if I wrote my program in C, it could run on almost every mini-computer out there. All of a sudden, the coupling between hardware and operating system was broken. Unix was the great equalizer, the driving force of the Nerd Spring that liberated programming from the grip of hardware manufacturers.

The hardware didn’t matter any more, since it all ran Unix. And since it didn’t matter, hardware fought with other hardware for dominance; the software was a given. Windows obviously played a role in the rise of the x86, but the Unix folks just capitalized on that. Cheap hardware meant cheap Unix installations; we all won. All that network development that started in the mid-80s happened on Unix, because that was the environment where the stuff that really mattered was done. If Unix hadn’t been ported to the Interdata, the Internet, if it even existed, would be a very different place today.

I read in an obituary of Steve Jobs that Tim Berners-Lee did the first WWW development on a NeXT box, created by Jobs’ company at the time. Well, you know what operating system ran on NeXT’s, and what language.

For myself, I can attest that there would be no O’Reilly Media without Ritchie’s work. It was Unix that created the fertile ground for our early publishing activities; it was Unix’s culture of collaborative development and architecture of participation that was the deepest tap root of what became the open source software movement, and not coincidentally, much of the architecture of the Internet as well. These are the technologies I built my business around. Anyone who has built their software or business with knowledge from O’Reilly books or conferences can trace their heritage back to Ritchie and his compatriots.

I don’t have the convening power of a Governor Brown, but for those of us around the world who care, I hereby declare this Sunday, October 30 to be Dennis Ritchie Day! Let’s remember the contributions of this computing pioneer.

P.S. Help spread the word. Use the hashtag #DennisRitchieDay on Twitter and Google+ Yegor Bugayenko, a programmer, a founder and an investor Yegor Bugayenko, a programmer, a founder and an investor

I’m Yegor Bugayenko, a programmer, a founder and an investor.

As a programmer I write mostly in Java, but also in Ruby, PHP and JavaScript. I’m a founder and a lead architect of,,,,, and I’m using IntelliJ products (my settings.jar for Java). Here are my favorite books about software engineering. I’m an Oracle Certified Master, Java EE 6 Enterprise Architect (OCMEA). Besides that, I’m a proud holder of ZCE, ZFCE, and OCUP.

As a founder and CTO at, a software development company with an absolutely unique methodology called XDSD, I’m an author of a few patent applications, including Puzzle Driven Development (PDD) Method and Software and Method for Software Cost Estimating Using Scope Champions. I’m a certified Project Management Professional (PMP®). Besides that, I’m a proud holder of RUP, PRINCE2 Foundation, MCP and COSMIC certificates.

As an investor at I have no results yet 🙂

Once in a month I send a summary email of my writing activity. If you’re interested to know what’s going on here, I can add you to my mailing list. Just give me your email address and briefly explain who are you and why you’re interested (I’m trying to avoid anonymous subscribers in my list).

Keywords: XDSD (eXtremely Distributed Software Development), office, Java, object-orientation