Wallpaper Expansion & Crash Exploits

This month is about wallpapers. In this post I talk about my experience in creating a dynamic wallpaper engine.

Sept 1st - JS? Why Not Lua?


I tried with the chromium concept, that didn’t work out. I figured I could make my own mini browser. I don’t need elements, only a canvas - this means I can ditch CSS, HTML, and everything else related.

All I really need, is a rendering engine, and a dynamic scripting language. JavaScript of course is the natural first choice…Right? I already have OpenGL integrated, this is easy.

That was 36 hours ago.

I did not successfully implement JavaScript. I had it working, many times, but I could not, for the life of me - get it to compile and work without issues in the release build.

Here’s the spinning wheel of JS failure, brought to you by me.

Some assets used are not created by me, and will not be in the final game, this is developer footage only

It works in development perfectly fine, but it’s time to call it. At a certain point there’s just no point in trying to force it to work. My build system is complicated, and for whatever reason I couldn’t get it to swap over for the JS building.

It dawned on me, after several hours of failed attempts. That I don’t actually want JavaScript. I never wanted JavaScript. I simply wanted a dynamic language that can execute in the runtime - in the release build.

This sounds a lot like Lua… I completely forgot about Lua while being hyped focused on getting JS to work. Lua already exists in the game, and is fully functional in the release build.

Within 30 minutes I had the prototype working in the release build. And I like writing Lua a lot more than JS for the wallpaper API I’ve written.

Sept 3rd - LiveLua


I call it LiveLua - the idea is it can load execute Lua code, similar to how a browser executes JavaScript. LiveLua will eventually interop with the underlying Lua API for the whole OS. For now it’ll have it’s own specific API though for rendering directly to GL.

Some assets used are not created by me, and will not be in the final game, this is developer footage only

The process is a bit of a let down for the wallpaper implementation, it’s not nearly as cool as I had imagined in my head. (Pointing an html file with an iframe to a YouTube video was cool when I had it working in the prototype build.) - But the reality is, it’s fully functional. Lua code renders onto OpenGL which allows for fast scene drawing, then those scenes are displayed on the background of your desktop.

The process could be standalone and implemented into the actual host OS Windows explorer process, similar to WallPaper Engine. I don’t have any plans to do this, but if it’s something the community would want, maybe I could throw it together post release.

This final version is the latest of my attempts at implementing dynamic wallpapers. The first one dates back to 2023, when I first embedded chromium. The build process was different as I wasn’t targeting x64 windows exclusively, I was trying to target all platforms so I wasn’t doing AOT compilation.

This meant I could easily implement libraries such as chromium, so it was pretty trivial to get going. In 2023-2024 I swapped over the build process, which meant dropping a few “extensions”. (That was my internal name for projects that extended the core OS codebase by adding new features, now I just shove everything in the core OS and call it a day, much easier!)

An error mode, displayed when the wallpaper and theme cannot be found. xJJHzwBkhO 1 Some assets used are not created by me, and will not be in the final game, this is developer footage only

Sept 16th - Command Prompt


I spent the past couple days working on the command prompt. It’s now fully finished, these are goals I’ve had for ages, but never dedicated the time to it. I use the command prompt regularly just for general development, so I felt this was a long time coming.

The command prompt is now tied into the Lua scripting framework. The same API that powers the chat-app, and wallpapers is now fully accessible from within the command line.

There are three ways to access Lua from the command line:

  1. You can run the command lua pass a filepath argument - LUA /scripts/lua/cmd/example.lua
  2. Or you can enter REPL mode - type lua and anything typed will be executed.
  3. Or anything provided as an argument will be interpreted and executed as Lua code - lua print("hello world")

You can now paste into the command prompt. Currently I’m supporting CTRL + C and CTRL + V. But CTRL + C also kills the current script being ran. So make sure you have text selected before you use CTRL + C. Or, text unselected, depending on the action you want preformed. CTRL + X also acts as stop, regardless of text selection status.

Y064MJ4M9t

Sept 17th - OS Beta Is Done


I finished the global OS debug console and the error console sister app. These two applications are used to manage system level errors and outputs inside of the OS itself. Not useful for users but it’s something I had working from the day 1 implementation of the GUI, and then broke maybe 3-6 months in due to the way I had implemented everything.

After I finished these two applications, I had this weird realized. I’m done.

I’m not actually done the main game, there are hundreds of tasks I need to complete still.

But in terms of my internal, nagging, “I wish it could have this” mentality. It’s gone, Poof. Vanished. I spent the past 10 months working on this project full time. Those thoughts trailed my head everywhere I went. They were always there, showing me what could be, what this should be.

And we’re here. Every single actual concept that I wanted, I had written down, so I’m sure there are handful that I don’t remember - but everything that I remember, is done.

This feels oddly empty. I always had goals, and I balanced those goals with practical concepts, at least I thought.

But I took a break, and realized this OS needs a lot more OS love, beyond the game itself.

I’ve given it that love, and I’ve basically completed everything I wanted to implement.

Like I said, there are a handful of bugs I need to iron out, and a bunch of smaller things that will probably last ages to finish. The story isn’t done, so the game isn’t done, but the OS feels like it’s no longer in a beta / testing state.

Words cannot describe this feeling as it’s two parts wonder one part sadness. I am excited for what this OS can now do, and what the future will be.

Sept 18th - Crash Exploits


I always knew the minute I added the ability for players to write their own code - crashing and “viruses” would be something I need to keep in mind. The OS has very minimal protection, it has a sandbox to ensure your files are not touched. Outside of that it doesn’t do much. This means CPU and RAM hogging is possible. Network is currently disabled, but if that’s ever turned on, that’s another vector of attack.

it would ruin the experience if someone can trick you to paste a command into your terminal, and it literally rm -rf /’s the game data. Or worse, fork bombs you. So I’m still working on a way to solve that - one idea is there is no full delete. Recycle bin only. But the registry can be overridden, and that is where critical data is as well. No clear solution yet unless I have a permissions system, like android. But I felt that was always so annoying - everyone clicks ‘yes’ anyways, just like Windows admin prompt.

I’ll show you two examples of code exploits that I had to fix, I consider this the start of my battle for security. Previously, I had security limited to just to the File System, as I never imagined allowing third party code execution. Now that it’s officially supported, I need to be smart and patch exploits like this.

Full OS Crash


This will take down the actual windows PC running the game. When I encountered this bug, there was no thread protection - which meant Lua could spawn an unlimited amount of threads, draining the computer and literally forcing the user to do a reboot to gain control of their pc.

lua while true do os.execute("cmd lua while true do print(1) end") end

Solution


Limit the amount of threads that can be active at once, and just deny the command outright.

Isolated Game Crash


This crash isn’t as bad, we’re not spawning another Lua thread, instead we’re hogging the windowing and paint thread by making it do an incredible amount of work.

lua while true do os.execute("cmd") end

Solution


Limit the total amount of applications that can be opened at once.

Both of these are patched as of writing. But I know there will be hundreds more like this - to the point where it will be impossible to fix all of them.

Sept 20th - CMD Styling


A couple years ago I created a text styler that worked for IRC color codes, I thought I could extend the protocol, and port the code over to the command prompt.

qLzX7MXhGW 1

This works similar to how IRC color codes work, but its extended to support hex colors instead of only 32 predefined colors.

Sept 30th - Drag N Drop


I’ve been planning on doing drag n drop for a while, but I didn’t have an exact plan on how I would do it. The rough idea is you should be able to drag files from explorer, and drop them into my game OS. Then from the game you should be able to drag n drop the files in-game to your actual computers explorer instance.

lNuA04ZE1r 1 Some assets used are not created by me, and will not be in the final game, this is developer footage only

So far it’s working great, I need to fix a couple visual bugs like padding, but it’s working more or less good enough for now.