Acropalypse: Windows Save File API is defective by design
twitter.com
twitter.com
That got me a bit worried, since desktop Linux is going somewhat in the same direction with sandboxed applications. So I did a quick search for the file chooser portal API, and if I understood what I found correctly (https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.free... and https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.free...), it does not return an already opened file handle; instead, the file is made available in a FUSE mountpoint within the sandbox (/run/user/$UID/doc/), and the call returns a URI pointing to that file. So, if I understood it correctly, developers can keep using the same traditional POSIX APIs they're already used to, with the same semantics they always had outside the sandbox.
I doubt people working in the Linux space would be so brazen.
Have you heard about this little project called Gnome yet?
I really doubt they'd try to literally destroy open(2). Sandboxing is different from this.
Not sure if it is different under the hood.
Win32: "Once more, yet another challenger falls before me. Who's next?"
That new shiny thing that Microsoft always pushed on me back when I was using .NET Framework 2.0 with C# is now deprecated before I gave it a try.
I had to turn of Windows Ink so that Macromedia Freehand/MX would work.
I need to find a web browser where the stylus selects text, as it has since Windows for Pen Computing, rather than scroll (why is this desirable? Can't one just scroll w/ touch?).
Then you go into the details of your power plan, through the old control panel they plan to remove, and you see that the hibernation settings is set to 120 minutes, and is not exposed in any way in the settings menu.
What is even the point of allowing me to disable sleep ? I know sleep and hibernate are two different things on a technical and power usage level, but the end user really doesn't care, what he means is "don't turn the computer off".
There are so many things in that same vein that have gone wrong after windows 7, and by the way the windows 11 start menu and right click contextual menu are as bad as people describe them, thank god third party tools easily exists to remove them.
Microsoft lost the phone battle so now they want my laptop to behave like a phone, this is ridiculous.
When the PC is either fully off or hibernates under Linux, it never ever turns on on its own. Wake on LAN and bios timers are all disabled.
I've already complained about this on some other thread, and a poster talked about some kind of timer that windows activates. I think there's some merit to that because it always turns on at night, I don't remember it turning on during the day.
I never went looking for details, since this is only a gaming PC, so it's not that much of a hassle to just turn it off. I'm not confident that an update won't reverse the change.
I've jumped through the obvious hoops of disabling sleep and automatic update installs. If I put my PC to sleep, I want it to stay asleep, I don't want the OS to second-guess me, especially if it's unable to plan for its own configuration that may prevent it from doing what it's doing.
To me, this just reeks of a half-assed attempt at copying apple's "power nap" feature. "Yah, let met check your mail while the pc sleeps (who the hell cares?!) or apply random updates". Except that on macOS, you can disable this with an obvious checkbox in an obvious place. Having to sift through event viewer (which for some reason is unbearably slow even on an 8-core Xeon with an NVMe drive) and going spelunking in the registry looking for undocumented settings is so user hostile.
I’ve never seen what you are describing with hibernation, because it just shuts off the PC. But I have little to none experience with Windows 11.
[0]https://www.softwareok.com/?page=Windows/10/Power-Options/11
On mine it wouldn't sit on the BitLocker screen forever. It would reboot after a little bit which would cause the fans to spin to max for a second. It's like having someone revving a car all night, but with the added anxiety of knowing it's wearing out your stuff.
Microsoft owes me some sleep.
I'm not sure how you're supposed to discover this though. And it's only available on laptops. Somehow windows is starting to divide people into camps of "everything is turning to crap" and "everything is fine, just follow these arcane steps" where previous versions just worked
Things were obviously not as well thought out, Windows 8 was, IMHO, a panicked reaction to the rise of tablet sales at the time.
This might explain why they often change the mood.
Interesting gotcha nevertheless.
(or just pad the rest with zeros worse case)
[1] https://learn.microsoft.com/en-us/windows/win32/fileio/when-...
https://learn.microsoft.com/en-us/windows/win32/fileio/about...
Given that this notice seems to exist since at least 2012, and neither Windows 10 nor 11 deprecated it, the TxF API will probably outlive whatever software you're writing today.
It's deprecated in all but name only.
O_TRUNC is not default: https://man7.org/linux/man-pages/man2/openat.2.html
The thing that hurts all copy-on-write systems is something like SQLite/Postgres/etc that mutates the file here and there; explicitly not overwriting it. chattr +C is the standard convention to opt out of copy-on-write, for those.
/me glares at "per-monitor v2" API awareness. I hate spreading rumours, but the one I heard about this was that nobody within Microsoft itself had tried converting any of their first-party GUI apps to per-monitor DPI. Once they started to do so, they finally realized how bad their offering was and came up with v2.
The example in the link in the tweet uses .PickSaveFileAsync(). The documentation for that function is https://learn.microsoft.com/en-us/uwp/api/windows.storage.pi... which says:
>The file name, extension, and location of this storageFile match those specified by the user, but the file has no content.
(Emphasis mine.)
And it's not a recent change. It was written in 2017. https://github.com/MicrosoftDocs/winrt-api/blame/docs/window...
So it may just be a bug rather than the intention. Though given that the SO question is from 2016, it seems nobody verified the intention was actually implemented since the very beginning.
In the System.IO namespace we can explicitly specify a FileMode to indicate whether we're appending or overwriting. If the UWP equivalent doesn't exist (and you need to explicitly set the file length to 0 to truncate), why would anyone just assume it does one or the other?
"The API is crap" is still not an excuse for using it wrong. Am I missing something?
The Win32 API also requires you to specify that you want to truncate the existing files.
How the fuck else would it work ? An additional OpenFileButTruncateExisting() API ?
A SaveFileAndOverwriteExisting() API ?
You can argue for those, but this thread is idiotic. He tries to furiously backpedal towards the end, but if he doesn't know the difference between a picker dialog and actually writing a file, I am not sure why I'd pay him any attention.
https://www.da.vidbuchanan.co.uk/blog/exploiting-acropalypse...
- https://twitter.com/David3141593/status/1638222624084951040
If you try to show the file picker while your app is snapped the file picker will not be shown and an exception will be thrown. You can avoid this by making sure your app is not snapped or by unsnapping it before you call the file picker. The code examples in FileSavePicker and the File picker sample show you how.
The example on the linked FileSavePicker[2] page "shows you how" by presenting a sample excerpt that calls an "EnsureUnsnapped" method that is neither a part of any documented API nor defined in any version of the sample I can find in GitHub.
Wasting considerable time, I managed to dig up an older version of the sample[3], ca. March 2013, that matches the doc excerpt. As it turns out, "EnsureUnsnapped" is defined in terms of a "TryUnsnap" method[4] that is deprecated because "window snapping" in the sense used here apparently only applies to store apps running on Windows 8.1 and earlier — notably, this includes the still-supported Windows Server 2012 R2 — and must not be confused with the current feature also officially known as window snapping.
From this I assume this warning only applies to apps that need to work correctly on obsolete or nearly-obsolete versions of Windows, and it only took me the better part of an hour to figure this out.
One of my biggest gripes with Microsoft is their somewhat recent tendency to memory-hole online-exclusive documentation and related materials for older versions of Windows that some of us, by hook or crook, are required to at least occasionally support, because telling an important customer to fuck off because their otherwise functional, fully security-patched OS is no longer under "mainstream" Microsoft support is a great way to lose said customer.
Is either providing offline documentation or maintaining an online archive of older documentation really too much to ask? Given the time and effort Microsoft has clearly invested in redesigning their developer documentation site every few years, the effort required to do the latter seems like a drop in the bucket.
To provide an illustrative counterexample: I can still find pinouts for the ports on my 128K Macintosh[5] or helpful tips to ensure my desk accessory is compatible with Font/DA Mover[6] if I need them, even if the relevant pages haven't been restyled since the late '90s.
[1] https://learn.microsoft.com/en-us/uwp/api/windows.storage.pi...
[2] https://learn.microsoft.com/en-us/uwp/api/windows.storage.pi...
[3] https://web.archive.org/web/20130403000823/http://code.msdn....
[4] https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewman...
[5] https://developer.apple.com/library/archive/technotes/hw/hw_...
[6] https://developer.apple.com/library/archive/technotes/pt/pt_...