Patches
© nemo 1999-2023
Here are various patches for bits of RISC OS that particularly needed fixing
Settle down at the back, it’s your own time you’re wasting
Settle 0.01 (21 Feb 2023) [32bit] BETA
This is a BETA TEST version. It has been smoke-tested on RO4 & RO5, but as with anything that sits on vectors it could crash your system so save your buffers the first time you try it.
It has been observed that for some RISC OS emulators running under some Linux hosts, filing system operations via HostFS take longer in the HostOS than in the emulated RISC OS, resulting in Filer updating its windows while the Host is still in the process of fiddling with inodes, resulting in multiple versions of the same file appearing. This is an emulator bug.
This module will be of no benefit unless you have experienced that fault.
This work-around module adds a configurable delay between FileSwitch modifying the filing system and Filer updating its windows. Naturally it doesn’t do this by freezing the machine – multitasking continues, but the Filer will update after a configurable delay, which defaults to a quarter of a second.
Double-click Settle to try it with its default ¼s delay. Type *RmReinit Settle 100 to change it to a one second delay, and so on. When you’re happy it does something useful, you can double-click !Install to install it in your PreDesk, and you can update the delay in that Obey file if necessary.
Bon chance Vince!
I didn’t mean to press Ctrl-Break
BreakAche 0.01 (16 Jan 2023) [32bit] BETA
This is a BETA TEST version. Use at your own risk.
BreakAche looks out for Break key combinations that would reset the machine, and instead does three things:
Suppresses the keypress
Beeps in an alarming way
Begins a 1½ second countdown during which the Break key behaves normally
In this way you will be saved from resetting your machine unintentionally (at the cost of about a day of your life if you find this beep as alarming as I do), but can still reset it if you need to.
BTW Some versions of RO5 will require the MOSVarFix module below... unless ROOL have restored what they inadvertently broke. So, yeah, I guess that means you’ll need the module.
It is a good idea when writing a Break-modifying module to remember that Windows emulators don’t support Ctrl-Break at all, for reasons of laziness I think. Grrr.
OS_GBPB,8-12 don’t work the way you think – a test module
HeebyGeeby 0.02 (16 Jan 2023) [32bit]
GBPB 8-12 are used to read leafnames from a directory. There has been much confusion over the interpretation of the return parameters R3 and R4. This is partly because the documentation has been wrong, and partly because authors have read what they wanted to read.
This module obfuscates one of the registers in a way that will make no difference to well-written code. It provides no other functionality or benefit.
The included !ReadMe describes the directory reading APIs correctly, which is a novelty for GBPB,8, and also describes why GBPB,11 doesn’t work on ResourceFS. Which it flaming well ought to.
NEW FOR 0.02 The module now scribbles all over the supplied buffer (which is assumed to be 11*R3 for GBPB,8) to ensure you don’t rely on buffer contents beyond the returned objects.
OS_File,255 (12,14,16) are very dangerous – save us, SaferOSFile
SaferOSFile 1.01 (15 Jan 2023) [32bit]
OS_File,255 and its brethren load a file – usually into a supplied buffer (they can be used to get FileSwitch to work out how to load the file, but we’ll say no more about that, it’s not affected).
The problem with this call, which dates back to the BBC Micro, is that there’s no buffer length. The usual programmer’s pattern is to find the file length with OS_File,5; allocate a buffer; then load it with OS_File,255. This was just about defensible on a stand-alone Archimedes, but in a networked or multi-user environment (such as an emulated RISC OS under a real operating system) the file can change length between the two OS_File calls.
This is bad. It leads to crashes, data loss, and even remote code execution. Very bad. But it’s a familiar pattern, and certainly one I’ve used many times.
SaferOsFile adds a new flag to OS_File,255, 12, 14 and 16 – bit 30 of R3. If set (and bits 0-7 are clear) then R5 becomes the expected file length – i.e. the length of the buffer you are loading the file into. If the file is not exactly that length, you get a Buffer Overflow error, and no memory corruption. Much better! You can use this API even if the module isn’t present, because FileSwitch itself ignores that bit and R5 (but you’ll get no protection in that case, naturally).
UPDATE January 2023: Version 1.01 is even more pedantic about flag preservation, which you probably don’t care about in RO5.
France got broken, quel dommage!
AlphaRéparer 0.01 (05 Mar 2022) [32bit] installs in !Boot...Choices.Boot.PreDesk
The Alphabet used for the French and French-Canadian (Canada1) Country/Territories has been Latin1 since 1987’s International ROM for the BBC Master... but that didn’t stop ROOL unilaterally changing it in RO5, simultaneously corrupting every French localisation and ALL THE FILES OF ANY FRENCH-SPEAKING USER WHO HAPPENED TO USE THE EURO (what are the chances of that??) FRACTIONS (what’s that, like ½ or ¼ of them??) OR Œ LIGATURES.
It’s this kind of thing that really tries my patience with people who claim to be improving things.
This module is only required for RO5. Its install script will politely refuse to install elsewhere but it is entirely benign if loaded anyway.
OS_Byte 166 got broken
MOSVarFix 1.02 (28 May 2020) [32bit] installs in !Boot...Choices.Boot.PreDesk
OS_Byte 166 has returned the base address of the MOS variables (OS_Bytes &A8-&FF) in all versions of the OS since the original BBC Micro. Somebody broke it in high-vector versions of RO5. This module ensures OS_Byte 166 (and 167) return the correct values in all versions of RISC OS, and also write-protects the value as it is informational, not functional.
All OS versions
Draw_ProcessPath is not 32b compatible (before 1.17)
DrawFix32 1.00 (05 Oct 2019) [32bit]
Draw_ProcessPath takes a flag in b31 of R7, which is otherwise an (aligned) address. This is not compatible with 32bit OSes nor even high-address Dynamic Areas on older OSes. A new API was introduced from Draw 1.17 that uses b25 & 26 of R1 instead. This module provides that API for older modules, such as the one supplied with RO4.37. If a Draw module 1.17+ is available, this module silently kills itself, so it is always safe to load it without having to RMEnsure anything.
If R1 b26 is set then the new API is in use, and the “Output Bounding Box” flag is in R1 b25 instead of R7 b31. Note that this does not change the Draw module itself, so attempting to output a bounding box to a high-bit address will fail with “Invalid address”.
*Shut considered dangerous, CLOSE#0 too
!CloseHook 1.01 (13 Aug 2019) [32bit]
Closing files that don’t belong to you is a terrible idea. Handles get reused immediately, so there is a high probability that a program that was previously writing to its own file will suddenly find itself writing to a completely unrelated file. So *Shut is a bad idea, but difficult to invoke accidentally.
However, CLOSE#0 is very easy to do unintentionally. As OS_Find can return a file handle of zero if it fails to open the requested file, a badly written program can end up doing CLOSE#0 by mistake.
Either way, it is to be avoided if you want to escape file corruption. !CloseHook is a solution. Whether in the Desktop, in a TaskWindow, or at the command line or a single-tasking program, CloseHook provides a confirmation before allowing *Shut or CLOSE#0 to proceed. If permission is not given, the program carries on none the wiser. Stick it in your Boot sequence and forget about it... until it saves your bacon. Many thanks to Martin Avison for the idea.
The patches below are currently “being tested”
i.e. I’ve forgotten about them, so hassle me if you need them.
WindowManager Wimp_CreateIcon crash
All versions of the WindowManager since RO3.5 suffer a catastrophic fatal crash if iconbar icons are created with certain priorities. This patch fixes the following OS versions:
4.02, 4.24, 4.33, 4.37, 4.39, 6.20
This ROMPatch installs in !Boot.Utils.RO4Patches
TaskWindow
Every version of TaskWindow ever will explode in consternation if you happen to send OS_WriteC a large negative value, such as SYS"OS_WriteC",1<<31. This patch fixes that for the built-in module in the following OS versions:
4.02, 4.24, 4.33, 4.37, 4.39, 6.20
This ROMPatch installs in !Boot.Utils.RO4Patches
WindowManager Back Icon
Adjust-click on the back icon ought to bring the window to the front. Here’s a patch that makes sure it does, in the following OS versions:
4.02, 4.24, 4.33, 4.37, 4.39, 6.20
This ROMPatch installs in !Boot.Utils.RO4Patches