99 pointsby signa114 days ago3 comments
  • userbinator4 hours ago
    As someone who has worked on Windows for a long time, the title was entirely unsurprising. Widening or narrowing always uses the current codepage.

    If a name contains values beyond ASCII — technically out of spec

    I'm not sure what spec it's referring to, but this is normal and expected for files in non-English systems.

    Such tools often incorrectly assume UTF-8, which is what motivated this article.

    Those tools are likely to be from the *nix world, where UTF-8 is far more common for the multibyte encoding --- but even there, you can have different codepages; and I have worked on Linux systems using CP1252 and 932 before.

    • numpad02 minutes ago
      [delayed]
    • mananaysiemprean hour ago
      > I'm not sure what spec [the prohibition on non-ASCII names is] referring to, but this is normal and expected for files in non-English systems.

      The description of import directories[1,2] in the PE/COFF spec explicitly (if somewhat glibly) restricts imported DLLs to being referenced using ASCII only:

      > Name RVA - The address of an ASCII string that contains the name of the DLL.

      [1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-for... (current, unversioned)

      [2] https://github.com/tpn/pdfs/blob/master/Microsoft%20Portable... §6.4.1 (version 6.0, 1999)

      • userbinator36 minutes ago
        That is, for lack of a better term, a "Microsoft-ism"; in MS documentation, "ASCII" consistently means "single-byte or MBCS" and is interpreted relative to the current codepage, as opposed to "Unicode" which means "UCS-2 or UTF-16". You can also see examples of "Unicode" in the docs you link to.
    • Dweditan hour ago
      It's the import table of an EXE/DLL where non-ascii is out of spec. Meanwhile LoadLibraryW is happy to load any filename. (But don't you dare try to call LoadLibraryW from within DLLMain, that's under loader lock)
  • enriquto9 hours ago
    This is a neat hack, and very well written. I felt a bit of nostalgia looking at the (classical) cpp flex to avoid repeating an identifier

       #define X(s) #s
       #define S(s) X(s)
    • shawnz8 hours ago
      For the unfamiliar, what does this pattern do exactly?
      • enriquto8 hours ago
        In that case it's just to convert the value of a macro into a string constant

           cat > a.c
           #define X(s) #s
           #define S(s) X(s)
           char *f(void) return { S(A); }
           ^D
        
           cc -E a.c
           char *f(void) return { "A"; }
           
           cc -DA=B -E a.c
           char *f(void) return { "B"; }
        
        
        More interestingly, you can use this trick to create code where some user-specified word appears as a string and as the name of the function. Exercice: write a macro M(x) such that compiling the code

            M(foo)
            M(bar)
        
        results in

            void print_foo(void) { puts("foo"); }
            voir print_bar(void) { puts("bar"); }
        • delta_p_delta_x6 hours ago
          > you can use this trick to create code where some user-specified word appears as a string and as the name of the function

          Ah, the poor man's introspection and reflection with C macros.

          shudder

      • ahartmetz8 hours ago
        It turns a macro argument into a string of that argument. Let's say you have a mydebug(expression) macro that should print both "expression" and the value of expression.
      • jjnoakes8 hours ago
        The macro X turns its argument into a string, but using it on its own means you can't turn other macro values into strings, only macro names.

            #define F 42
            #define X(s) #s
            X(5)  //  Expands to "5" (as a string literal)
            X(F)  //  Expands to "F" not "42"
        
        If you add one level of recursive macro expansion, though, that expands the macro argument as well as the macro definition:

            #define F 42
            #define X(s) #s
            #define S(s) X(s)
            S(5) // "5" as expected
            S(F) // "42" because S(F) expands to X(42) expands to "42"
  • jiggawatts9 hours ago
    I got the chance to evaluate vendors for a huge enterprise because I was assisting their CTO. I vividly remember the sales guy who flew from Redmond to pitch the shiny new Hyper-V virtual machine platform Microsoft had just developed to compete head-to-head with VMware.

    “I tried the beta and it couldn’t install successfully if I set my regional options to en-AU.”

    “Umm… that’s just a cosmetic issue.”

    “It’s a hypervisor kernel, it is going to host tens of thousands of our most critical applications and it crashes if I change one of only three things it asks during setup. My confidence is not super high right now.”

    Etc…

    I got the impression that Microsoft is used to selling to PHBs based on the look of shock on the guy’s face when I told him that I not only installed the product, but benchmarked it too for good measure.

    • n_plus_1_acc7 hours ago
      MS still makes they same mistake. Date format in Teams is just broken. https://learn.microsoft.com/en-us/answers/questions/1403096/...
      • magicalhippo6 hours ago
        I absolutely hate that they've reduced it to a single "regional settings". Just because I don't want Norwegian text everywhere does not mean I want dates and time to be displayed in some weird way. However I also utterly despise the Norwegian official way of writing decimal numbers with , rather than . as the decimal separator.

        We've had fine-grained control over this for ages, apps can handle it fine, just let us get it the way we want it.

        • jiggawatts5 hours ago
          This is configurable in Windows. Your location, keyboard(s), display language, and date/numeric formats are all separate settings.

          You can even use emoji as date separators if you please.

          • shakna3 hours ago
            I'd rather that be configurable per-app. Because not all programs are used for all workflows.
      • 834575 hours ago
        They don’t have a time filed in Forms.
    • galkk7 hours ago

          “I tried the beta and it couldn’t complete the installer if I set my regional options to en-AU.”
      
          “Umm… that’s just a cosmetic issue.”
      
          “It’s a hypervisor kernel, it is going to host tens of thousands of our most critical applications and it crashes if I change one of only three things it asks during setup. My confidence is not super high right now.”
      
      No offense, but to me, the way it written, it shines bad light rather on you. Obviously rep wouldn't answer you something like:

      "Well, it said it is beta, didn't it? The quality of the installer of a BETA hasn't anything to do with the quality of hypervisor itself. "

      • jiggawatts6 hours ago
        It was a month from release and it’s a product that’s “even more critical than the OS kernel” for reliability and availability. A failed hypervisor can take out dozens of servers at once.

        I also managed to crash or lock it up several times, I just mentioned the keyboard thing as an insane bug. What possible dependency could a stripped down kernel with hardly any user space have on a keyboard layout that’s identical! It is different from en-US in name only.

        It’s not about the specifics of the issue, but about the overall impression of sloppiness. They didn’t make a hypervisor that’s purpose-designed for the requirements, they just stripped down Windows and deleted stuff haphazardly so that they were missing the keyboard but still had the installer option.

        For reference, I did run it at scale a few years later and my misgivings were confirmed… and then some. It was much less stable than ESXi and the cluster operations were a disaster. Read only operations could cause deadlocks that only a full cluster reboot could resolve. In-place upgrades weren’t available for several major versions! Meanwhile ESXi clusters could be live-upgraded including disk format changes!

        After enough decades of experience you get a sixth sense for these things. A single sentence or just one word can trigger an alarm bell in your brain.