Top
Best
New

Posted by snoofydude 18 hours ago

This game is a single 13 KiB file that runs on Windows, Linux and in the Browser(iczelia.net)
242 points | 65 commentspage 2
netsharc 15 hours ago|
Semi-related: Windows EXE files are runnable in DOS (at least when DOS was a thing, so for Windows 3.1x or 9x), but most of the time the DOS part just prints "This program requires Microsoft Windows." and exits. An exception is regedit.exe, that one can use to import registry values even in DOS. (Huh, although, how does it do that without using Windows API?)
chii 12 hours ago||
> Huh, although, how does it do that without using Windows API?

without knowing anything, i am going to guess that they could either directly import the same code that the windows api uses (either via knowing where the implementation code resides and load that), or even statically link the library! After all, regedit doesn't need to obey cleanliness rules that other non-first-party programs would need to - presumably, because if those registry editing api/format changes, regedit would get updated along with it!

b1temy 15 hours ago||
> An exception is regedit.exe

This might have changed at some point. I was curious about the latter part of your question on how it made changes without the Windows API (I assumed it used an older DOS API), but my `regedit.exe` _does_ have the `This program cannot be run in DOS mode.` DOS stub in it.

madduci 10 hours ago||
The binary relies on the runtime, so yes it is nice.

Forma instance, a static compiled and linked "hello world" in C on Linux is around ~785KB

oguz-ismail2 10 hours ago||
> a static compiled and linked "hello world" in C on Linux is around ~785KB

Huh?

    $ musl-gcc -xc -static -Wl,-z,norelro -Wl,-z,nosectionheader -Wl,-z,noseparate-code -s - <<eof
    #include <stdio.h>
    int
    main(void) {
            static const char s[] = "Hello, World!\n";
            fwrite(s, (sizeof s)-1, 1, stdout);
    }
    eof
    $ ./a.out
    Hello, World!
    $ ls -l a.out
    -rwxr-xr-x 1 oguz oguz 4976 Jan 12 09:38 a.out
And if that's not enough

    $ musl-gcc -xc -static -nostdlib -fcf-protection=none -fno-asynchronous-unwind-tables -fomit-frame-pointer -Wl,-z,norelro -Wl,-z,nosectionheader -Wl,-z,noseparate-code -s - -lc <<eof
    #include <unistd.h>
    void
    _start(void) {
            static const char s[] = "Hello, World!\n";
            write(1, s, (sizeof s)-1);
            _exit(0);
    }
    eof
    $ ./a.out
    Hello, World!
    $ ls -l a.out
    -rwxr-xr-x 1 oguz oguz 487 Jan 12 09:58 a.out
201984 4 hours ago|||
I'm sure that number is using glibc, not musl.
Sharlin 7 hours ago|||
Probably 785k unoptimized and unstripped with all debug info.
PhilipRoman 7 hours ago||
That's just because glibc is not designed for static linking. It works, but it doesn't exclude unused code, unlike with other libcs.
indigodaddy 17 hours ago||
Wonder why they don't give a demo/link to the browser version
nxrabl 16 hours ago|
It's the same file, you just rename it to end in '.html'
indigodaddy 16 hours ago||
sure but they have a blog and a webserver that's serving html. just put the .html version there so i dont have to download anything or mess about too much. just want to click and see it
esafarn 4 hours ago||
flagged as virus
hyperbrainer 13 hours ago||
Reminds me of the Cosmopolitan project: https://github.com/jart/cosmopolitan
bananaboy 10 hours ago|
That was mentioned at the top of the blog post.
beeflet 13 hours ago||
You don't need to rename it to an html file, just serve it with with the following header:

Content-Type: text/html

bananaboy 17 hours ago||
Very clever!
gaigalas 16 hours ago||
Quite cool.

You could distribute it as `.html` only, and use JS to offer a local download link to itself in the correct extension. A polyglot installer, of sorts.

For example, this gist is an HTML that, when opened, offers a download zip of its DOM in whatever state it currently is:

https://gist.github.com/alganet/c904acb57282402fc0bd724f1eeb...

I think you can use something similar to get the entire page contents as a blob, but I never tested with binary data in actual browsers. Perhaps even patch it to avoid the initial windows error.

David-jones 5 hours ago|
[dead]
More comments...