Posted by snoofydude 18 hours ago
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!
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.
Forma instance, 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.outContent-Type: text/html
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.