Tuesday, January 27, 2026

Zig basic Windows application using win32 API

Zig basic Windows application using win32 API

Info:
OS: Windows 10 IoT LTSC 2021
Zig: 0.15.2

Sample application using zigwin32, Windows API to create basic window that does nothing. It calls the following win32 API functions:
- LoadCursorW
- RegisterClassW
- GetLastError
- CreateWindowExW
- ShowWindow
- GetMessageW
- TranslateMessage
- DispatchMessageW
- DefWindowProcw
And windows WindoProc function for pumping messages.

Create a Zig application, like:
PS C:\prj\> mkdir hellowindow
PS C:\prj\> cd hellowindow
PS C:\prj\hellowindow> zig init
Modify build.zig to add zigwin32. See lines 86-91 in gist below. Update src/main.zig to look like below. Checkout zigwin32 into the root of the project
PS C:\prj\hellowindow> git clone https://github.com/marlersoft/zigwin32 libs/zigwin32
Now do a build:
PS C:\prj\hellowindow> zig build
Or do a release build that produces the smallest binary:
PS C:\prj\hellowindow> zig build -Doptimize=ReleaseSmall

Demo how to use zigwin32 in your zig application

Demo how to use zigwin32 in your zig application

Create a Zig application, like:
PS C:\prj\zigwin32test> zig init
Modify build.zig to add zigwin32. See lines 68-72 in gist below. Update src/main.zig to look like below. Checkout zigwin32 into the root of the project
PS C:\prj\zigwin32test> git clone https://github.com/marlersoft/zigwin32 libs/zigwin32
Now do a build:
PS C:\prj\zigwin32test> zig build run
Reference:
https://github.com/myZig/zigwin32test

Thursday, January 01, 2026

Fedora 42 Workstation installation screen capture

Just an itch, wanted to see how Fedora 42 Workstation looks like. For other versions see here

Error opening directory '/media/sf_C_DRIVE': Permission denied

I tried to share a folder from Windows 10 host to Kali 2020.1 Linux guest using VirtualBox but I am getting the following error message:

Error opening directory '/media/sf_C_DRIVE': Permission denied

To fix, do:
$: sudo adduser $USER vboxsf
Then log-off then log back in. If this does not work, reboot the VM

Getting similar issue using Fedora 33 on VirtualBox 7.0.12 (tested up to Fedora 41 [VBox 7.2.4]) , below is the error message
This location could not be displayed You do not have the permissions necessary to view the contents of "sf_D_DRIVE"
To fix do the following and reboot the VM.
$: sudo usermod -a -G vboxsf $USER
Refs:
https://stackoverflow.com/questions/26740113/virtualbox-shared-folder-permissions

Thursday, December 25, 2025

Rust and WebAssembly quick start guide 2025

Rust and WebAssembly quick start guide 2025

As of December 2025, Rust and WebAssembly is reorganizing. Documentation is currently out of date and not working. This is my notes on getting started using Rust WebAssembly. Most of the documentation still works - below is distilled version.

Install Rust toolchain
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Below shows my Rust toolchain versions
q@x1m9:~/tmp$ cargo --version
cargo 1.92.0 (344c4567c 2025-10-21)
q@x1m9:~/tmp$ rustc --version
rustc 1.92.0 (ded5c06cf 2025-12-08)


Install wasm-pack - your one-stop shop for building, testing, and publishing Rust-generated WebAssembly.
$ sudo apt install build-essential
$ cargo install wasm-pack
wasm-pack version
q@x1m9:~/tmp$ wasm-pack --version
wasm-pack 0.13.1


Install cargo-generate - helps you get up and running quickly with a new Rust project by leveraging a pre-existing git repository as a template.
$ sudo apt install libssl-dev
$ sudo apt install pkg-config
$ cargo install cargo-generate
cargo-generate version
q@x1m9:~/tmp$ cargo-generate --version
cargo generate 0.23.7


Install npm

Install node version manager - nvm
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
nvm version
q@x1m9:~/tmp$ nvm --version
0.40.3


Now install latest version of node
$ nvm install node
node version
q@x1m9:~/tmp$ node --version
v25.2.1


Clone project template
$ cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name wasm-game-of-life
$ cd wasm-game-of-life


Build the project
$ wasm-pack build


Putting it into a webpage, run in project root
$ sudo apt install git
$ npm init wasm-app www


Install dependencies
$ cd ~/p/wasm-game-of-life/www
$ npm install


Edit ~/p/wasm-game-of-life/www/package.json
$ nvim ~/p/wasm-game-of-life/www/package.json 


Add wasm-game-of-life to dependencies section of package.json and also note that devDependencies is updated.
{
  "name": "create-wasm-app",
  "version": "0.1.0",
  "description": "create an app to consume rust-generated wasm packages",
  "main": "index.js",
  "bin": {
    "create-wasm-app": ".bin/create-wasm-app.js"
  },
  "scripts": {
    "build": "webpack --config webpack.config.js",
    "start": "webpack-dev-server"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/rustwasm/create-wasm-app.git"
  },
  "keywords": [
    "webassembly",
    "wasm",
    "rust",
    "webpack"
  ],
  "author": "Ashley Williams ",
  "license": "(MIT OR Apache-2.0)",
  "bugs": {
    "url": "https://github.com/rustwasm/create-wasm-app/issues"
  },
  "homepage": "https://github.com/rustwasm/create-wasm-app#readme",
  "devDependencies": {
    "webpack": "^5.0.0",
    "webpack-cli": "^5.0.0",
    "webpack-dev-server": "^4.0.0",
    "copy-webpack-plugin": "^11.0.0",
    "hello-wasm-pack": "^0.1.0"
  },
  "dependencies": {
    "wasm-game-of-life": "file:../pkg"
  }
}


Edit ~/p/wasm-game-of-life/www/index.js
$ nvim ~/p/wasm-game-of-life/www/index.js


Add wasm-game-of-life package to index.js
import * as wasm from "wasm-game-of-life";

wasm.greet();


Install wasm-game-of-life package and force clean as we have upgraded devDependencies
$ cd ~/p/wasm-game-of-life/www
$ rm -rf node_modules package-lock.json
$ npm install


Fix ~/p/wasm-game-of-life/www/webpack.config.js
$ nvim ~/p/wasm-game-of-life/www/webpack.config.js


Observe we have changed CopyWebpackPlugin and added asyncWebAssembly
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require('path');

module.exports = {
  entry: "./bootstrap.js",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bootstrap.js",
  },
  mode: "development",
  plugins: [
    new CopyWebpackPlugin({
      patterns: [
        { from: "index.html" },
      ],
    })
  ],
  experiments: {
    asyncWebAssembly: true,
  },
};


Now run it
$ npm run start


Open http://localhost:8080

Fedora install screen chronicle

Fedora install screen chronicle Below are links to Fedora installation screens. It is interesting to see how it has evolved over time. Fed...