HNHacker News
TopNewBestAskShowJobs

MarekKnapek

42 karma · joined July 26, 2016

submissionscomments
MarekKnapek··on Docker is weird
Yes, Docker is weird. We already have a process management thing - it is called an operating system. But processes are misbehaved sometimes. They are not configurable enough, what if two processes want to listen on port 80? What if two processes want to save stuff at /var/abc.txt? And so on. In this case Docker might have a point. Otherwise it is just saysadmin's lazyness.
MarekKnapek··on A new Intel Itanium (IA-64) emulator that boots Windows
Wasn't there a problem with Alpha, that it had too weak memory model or something? Think of atomic instructions with multi CPU system. Or do I remember something wrong?
MarekKnapek··on Rumors of my death are slightly exaggerated
Yes! I need a glass Klein bottle video!
MarekKnapek··on How to Implement an FPS Counter
My idea is: 1) Determine how frequently you want to update the number on screen. Every frame is too often, once per second is too infrequent. Maybe 4× per second is OK. 2) Determine how much time to average over. One or two seconds seems fine. 3) From those two numbers, compute number of buckets. For example update 4× per second, average over 2 seconds, gives you 8 buckets. 4) Every time a frame is drawn, based on current time, you either a) increment the counter in the last bucket or b) shift all buckets over one position and increment the new last bucket from zero to one. 5) Average the sum of frames drawn over that time period you decided earlier. 6) Don't display fraction of a FPS. 7) Done. It costs you 8 integers, plus maybe one more for a timestamp of the last bucket, plus maybe one more to implement ring buffer instead of shifting all those integers over. Less than a single CPU cache line.
MarekKnapek··on UUID package coming to Go standard library
Is there a way to have benefits of both? Version 7 for better database clustering. And version 4 for complete randomness? So users can not inference nothing from the id? I have an idea: Use version 7 internally, then scramble it before sending to the user. Scrambling could be done by the database or by the server application. It could be as simple as XOR with some 128bit constant, or as resilient as AES encryption. Of course you also need to do unscrambling of IDs coming from users.
MarekKnapek··on Building Your Own Efficient uint128 in C++
On division: There is a paper about a division algorithm. If you split your 128bit integer into four 32bit integers, you can use a 64bit CPU built-in instruction to do the 128bit division. If you are on 32bit CPU that doesn't have the 32bit division operation, then split your 128bit number into 8 16bit integers and leverage the 32bit CPU built-in operation. https://surface.syr.edu/eecs_techreports/166/
MarekKnapek··on Show HN: Doom (1993) in a PDF
As PDF supports DEFLATE compression, it should be possible to shrink the size of the PDF document considerably.
MarekKnapek··on WinDepends – A Rewrite of the Dependency Walker
There is also this one, but it is no longer maintained. https://github.com/MarekKnapek/DependencyViewer
MarekKnapek··on OpenBSD: Removing syscall(2) from libc and kernel
No, Windows has stable API and ABI named Win32 API. This comes from times of 16bit Windows and works also in x64 / ARM / ARM64, previously it worked in Alpha / MIPS / IA64. This API is implemented in kernel.dll user.dll gdi.dll advapi.dll and similar, it does some stuff, but mostly forwards to the NT API. Beware, kernel.dll is user space component despite its name (historical reasons). NT API is undocumented and not meant to be used by user programs, it is not stable, it lives in ntdll.dll, it does syscalls to the kernel: ntoskrnl.exe. Windows doesn't have a libc (for user programs, it has private one for its own programs), Visual Studio has a libc. Each version of Visual Studio (roughly) has its own libc named msvcrt.dll msvrt100.dll msvcrt140.dll and similar, it hosts the C and C++ libc, it could be linked statically for various benefits and drawbacks.
MarekKnapek··on Chrome: Heap buffer overflow in WebP
> memory allocation can occur here and there

What about HW decoders? Of video formats (that are much more complex than image decoders)? Such as MPEG, H.264, H.265, VP9, AV1 and similar. If memory allocation is needed here and there, I guess there is always known maximum size of such allocation in advance. Written in the spec. Think of at chip design time, or at software decoder compile time. How else would HW decoders be even possible?

Also: Hey Google, do you even fuzz-test? Your own stuff?

MarekKnapek··on GPS (2022)
The article says that GLONASS time counts days from zero to 1461, then resets back to zero. This is 4 years if we think leap year is once 4 years. But it is not. Leap year is once 4 years, but each 100 years it is not, except each 400 years it is. This is on average 365.2425 days per year not 365.25 days per year. Is GLONASS not long term thinking ahead enough?
MarekKnapek··on In Erlang/OTP 27, +0.0 will no longer be exactly equal to -0.0
What about NaN? Does Erlang have NaN? How does Erlang compare two variables containing a NaN (or expressions evaluating to a NaN)? There are (2^24)-2 different NaNs in a 32bit IEEE 754 float, and there are (2^53)-2 different NaNs in a 64bit IEEE 754 double. The IEEE 754 standard says, that a NaN value should compare to any other number (including any other NaN) as not equal. Yes, the expression `x == x` could return `false`.
MarekKnapek··on Deceiving Windows Defender: The Big Stack Bypass
If you are administrator, you can create and launch new scheduled tasks ... as NT\SYSTEM from that you can ... anything. Get TCB privilege, get Trusted Installer account, install kernel level drivers ... god mode.
MarekKnapek··on Rolling your own crypto: Everything you need to build AES from scratch
Implementing AES from scratch is easy and fun, just read the spec and implement it 1:1, until ... you encounter GCM mode and its Galois Field "weird" math. Very. Not. Fun.
MarekKnapek··on How I cut GTA Online loading times by 70%
Please don't compute speed-up like that.

Old time: 6 minutes (360 seconds). New time: 1 minute and 50 seconds (110 seconds). Speed-up calculated by article author: 1-110/360=0.694 (69.4% saved). Speed-up calculated by me: 360/110=3.27 (3 times faster).

Please calculate it the other way around. It makes great difference when you say you made something 10× faster than when you say you saved 90% of work even if both mean exactly the same thing.

Bruce Dawson has great article about this: https://randomascii.wordpress.com/2018/02/04/what-we-talk-ab...

MarekKnapek··on Arranging Invisible Icons in Quadratic Time
Yes. At previous job where we were making a desktop Win32 application we experienced this. Our automatic pipeline is: Build server compiles all the .EXEs and .DLLs, creates an .EXE installer and sends it for testing. Test agent grabs the installer, installs the product and runs various test scenarios (pokes buttons, menu items, etc). One of those scenarios is HTML help (.CHM file) displayed inside Windows built-in help viewer that started to time-out. The solution was to go to Control Panel, Internet options, Clear Cookies. Also the product's check-for-updates-in-background feature on this machine was very slow because cookies. Both features are using Windows' (or IE's) high level HTTP library containing functions such as fetch-this-url-and-figure-out-TLS-and-redirects-automatigally.
MarekKnapek··on Analyzing the compromised DLL file that started the Solorigate attack
Did SolarWinds' CA (certificate authority) reworked their code signing certificate?
MarekKnapek··on No Cookie for You
Few years back I created some HelloWorld application on Google's AppEngine (requires Java, Python or Go) and was positively surprised about its statistics on theirs dashboard.
MarekKnapek··on Kazakhstan government is intercepting HTTPS traffic in its capital (again)
So this certificate will be added to "not trusted" of all the certificate storages (Windows, Firefox, Chrome, Java, and all others) ... riiight?
MarekKnapek··on The friends who drove a bus behind the Iron Curtain
James Webb will prove nobody nothing. Search Twitter thread by Foone who discussed there how many wonderful things humanity managed to pull off while waiting for James Webb to launch.
MarekKnapek··on The mystery of why one ant species goes after larger foes (2018)
Most likely we would cuddle more. As explained in Minute Earth's video: https://youtube.com/watch?v=c6Ko0Hzi47U
MarekKnapek··on Information on the revocation of WinRAR 5.91 digital certificate
At my previous job we released updates to our Windows desktop application about 3-4 times per year. We had about 20'000 customers (but many of them not installing updates). We checked final build of our product on Virus Total before release and e-mail the various anti virus companies about the false positives. Thankfully, I wasn't the guy doing this work.
MarekKnapek··on C will never stop you from making mistakes

    int* a, b;  /* wrong */
    int *a, *b; /* also wrong */


    /* correct */
    int* a;
    int* b;
MarekKnapek··on Why Apple ditched PowerPC, and what it says about Apple ditching Intel
Yes, Moore's law is hitting its limits: For example 5nm distance equals like about 25 silicon atoms. That's like: Quantum electron tunnelling will ruin your life.

So if we want increase our chip's performance any further, we need a fundamental change in our technology. And since silicon atom is 210 pm big and carbon atom (graphene is made from carbon) is 170 pm big, we need to change our architecture as shrinking transistors will not be possible anymore. I mean CISC/RISC, drop x86 support and so on.

MarekKnapek··on The Definitive Guide on Win32 to NT Path Conversion (2016)
> Fortunately this doesn’t seem to work in the Explorer shell, but it does work when passed to native APIs such as CreateFile.

CreateFile is Win32 API, not Native API. NtCreateFile would be Native API.

MarekKnapek··on But why is a sphere's surface area four times its shadow? [video]
Search for Eugene Khutoryansky on YouTube.
MarekKnapek··on Show HN: Windows 95 in an Electron App
Yes, English version was on 15 (or 13 specially formatted) 3½ discettes. Localized into my language was on 28 3½ discettes.