OS/2, eCS & ArcaOS - Technical > Programming
native mainframe mini-clone
Rich Walsh:
--- Quote from: kerravon on September 12, 2025, 05:54:21 pm ---can I have a normal executable (.exe), running at the OS/2 fullscreen prompt, that has the privilege required to disable interrupts and switch from PM32 to LM64?
--- End quote ---
Can a Ring 3 executable execute a Ring 0 priveleged instruction that could blow up the entire system? Hell no!
--- Quote ---If so, what do I need to do to get such privilege on OS/2?
--- End quote ---
You would need a device driver which operates at Ring 0. In the UEFI version of ArcaOS, the bootloader stub which remains after the OS is running will switch to long-mode to read the machine's NVRAM variables, then will switch back. While doing so, all of OS/2 must stop because it is 100% *incompatible* with long-mode. Why? Because the kernel and device drivers are all 16-bit code, and the flag that signals "16-bit code" on an x86 signals "64-bit code" when long-mode is enabled. You can have 16/32 code or 32/64 code but not 16/32/64.
kerravon:
--- Quote from: Rich Walsh on September 13, 2025, 01:15:54 am ---You would need a device driver which operates at Ring 0.
--- End quote ---
Ok, in that case, I guess I am after the minimum device driver that's sole duty is to switch from ring 3 to ring 0 - callable from any ordinary app.
That would be enough to prove the concept of allowing me to create my own mini-Win64 that purely uses memory above 4 GiB.
Note that I am only interested in executing non-buggy programs, so I don't mind OS/2 crashing the same way that MSDOS crashed if you run a buggy program.
I simply debug the application.
Running everything privileged has worked fine for me for decades. I'm not trying to make a commercial quality product. Fleshing that out is left as an exercise for the reader or whoever sees a commercial opportunity for something more robust.
Dave Yeo:
There's some sample drivers at http://hobbesarchive.com/?path=%2fpub%2fos2%2fdev%2fsamples%2fdrivers Perhaps the fastio driver, http://hobbesarchive.com/Home/Download?path=/Hobbes/pub/os2/dev/samples/drivers/FastIO_A1-0.zip can be modified. From the blurb,
--- Code: ---FastioA$ Device Driver for direct port I/O. Based on Holger Veits EDM/2 fastio driver. Modified for use with watcom. Includes watcom project files and example program. (FastIOA1.0.zip)
--- End code ---
kerravon:
--- Quote from: Dave Yeo on September 13, 2025, 06:02:46 pm ---Perhaps the fastio driver
--- End quote ---
Thanks - looking at that, there is something I didn't think of.
It does a far call into the I/O driver, which gives an opportunity for the cs to change, and I'm guessing that while in the driver, it has a privileged cs, but on return to the caller, the original cs is restored to an unprivileged cs. ie it's not that easy to simply say "go privileged".
I guess I can modify the GDT table to make the original cs privileged though. Not sure if ds needs a change too.
Lars:
You might want to have a look at:
https://hobbesarchive.com/Home/Download?path=/Hobbes/pub/os2/system/drivers/misc/SysCall_3-0.wpi
That is a package that I have written to run code in Ring 0.
It comes with full source code. Which would allow you to adapt/extend it to your needs.
The idea was to have an interfacing DLL to be used by an application. That DLL will return to the caller an entry point that will allow the caller to execute user functions in Ring 0.
It uses the syscall/sysret instructions as the fastest way to enter Ring 0.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version