points by voldacar 7 years ago

The ugliness of the windows API never ceases to amaze me. Functions with names like RtlDetermineDosPathNameType_U and return types like PCWSTR just make my eyes bleed.

colatkinson 7 years ago

My personal favorite is PCZZWSTR: a const pointer to a contiguous WCHAR array, where each substring is NUL-terminated, and the array itself is also terminated by a NUL. Thus (I assume) the ZZ--zero zero. I've only ever seen it used in the SHFILEOPSTRUCTW struct.

  • voldacar 7 years ago

    >SHFILEOPSTRUCTW

    now that takes the cake

    • whoopdedo 7 years ago

      Nah. That would be INITCOMMONCONTROLSEX. And the related LVM_SORTITEMSEX, DDSCAPSEX, and of course MPR_CREDENTIALSEX_0.

      • saagarjha 7 years ago

        With Microsoft's use of ALLCAPS and using an "Ex" prefix, this was all but guaranteed…

    • msclrhd 7 years ago

      How about SHITEMID in the shlwapi DLL? That's supposed to be SH-ITEM-ID.

    • Barrin92 7 years ago

      if someone ever figures out the meaning of that phrase it's probably going to summon some cosmic horror that will be the end of us all

  • therein 7 years ago

    I've had some interesting experiences with SHFileOperationA on Wine. Star Citizen's updater wasn't working properly at one point due to it.

  • alxmdev 7 years ago

    Multi-strings are also pretty common in the registry, see REG_MULTI_SZ.

  • asveikau 7 years ago

    I feel like that construct, sometimes called "double-null terminated", is often inaccurately described.

    I prefer to think of it as a contiguous block of null terminated strings terminated by an empty string. (Just as '\0' terminates a C string, the empty string terminates such a list.)

Const-me 7 years ago

That's not an API. The article talks about some ntdll function, not supported by MS, and not documented by MS.

The ugliness might be deliberate, to make developers conclude "that must be some Windows internal BS, probably undocumented" when they see it in debugger, profiler or other places.

  • asveikau 7 years ago

    > The ugliness might be deliberate, to make developers conclude "that must be some Windows internal BS, probably undocumented" when they see it in debugger, profiler or other places.

    Not at all. It is consistently named with internal NT APIs that are used like that intentionally. The people working at that layer follow such naming conventions without irony.

    • Const-me 7 years ago

      > consistently named with internal NT APIs

      I know, but these are mostly not part of WinAPI either. The public API surface has very good names, WriteFile or CreateDirectory is IMO better than POSIX write or mkdir.

      • wvenable 7 years ago

        My favorite Unix function has to be "creat". It doesn't even make sense given the limitations of the systems at the time.

      • rossy 7 years ago

        I don't know if they're good. WriteFile and CreateDirectory are fine, but when I think of the Windows API, I think of much longer function names. I had to use ConvertStringSecurityDescriptorToSecurityDescriptorA() once (and yeah, I had to use the ANSI version explicitly.) Another C/C++ developer might have called that function sec_sddl_to_desc(), which is much better IMO.

        • breakingcups 7 years ago

          I know I'm probably in the minority, but I vastly prefer the long-form name in your example. Modern IDE's (especially Visual Studio with its Intellisense) can be incredible with their autocomplete, superseding the need for short-form obtuse acronym-laden function names that you need to remember.

          So let's assume there's no time difference between writing the long or short form of that function. There's only one other direction to consider, which is reading.

          Try to approach the following question without personal bias. If you have never worked with either API, which function name would be more self-explanatory for you? ConvertStringSecurityDescriptorToSecurityDescriptorA or sec_sddl_to_desc?

        • asveikau 7 years ago

          One problem is that there is no one Windows style. The style guidelines, if you can call them that, depend on a few things like age and provenance of the component (some examples of pieces with distinct styles: filesystem, registry, GDI, NT API, COM). And sometimes you see a mix of these, or a component come along with its own variation. (SDDL and other security APIs is a good example of a unique style.)

          But sometimes people confuse unfamiliarity with ugliness, being bad or wrong, and having worked with a lot of these stuff I feel this is often a mischaracterization. Unfamiliarity doesn't always make it bad.