So what if several functions that use less than 4KB each call each other before using the stack variables in a way that the first access skips over one page?
st_goliath 58 minutes ago [-]
A function call causes the return address to be pushed onto the stack, thus accessing the stack below the adjusted stack pointer address.
On compiler generated x86 code, the base pointer register will quickly follow when entering the target function.
pjmlp 3 hours ago [-]
One of those functions that isn't really implementable in standard C, requiring either compiler support, or being written in straight Assembly for stack registers manipulation, one of those "micro runtime" features for C.
From UNIX 7th edition all the way up to C99, when VLAs where introduced, only to be made optional in C11, and the C23 update still doesn't support automatic VLAs, only for function parameters, thus the point stands.
One thing that scares me a little is whether there are younger developers, say, 25-40, who can and want to pick up the mantle of Windows internals gurus.
I mean, Chen has decades of winternals in his head. Microsoft has been gutting their staff for years now. When the Petzold/Chen generation hang up their spurs, does Microsoft still have a critical mass of people who understand Windows from the metal up?
delta_p_delta_x 35 minutes ago [-]
As someone who moved back to Windows for development and entertainment, I find systems programming on Windows more fun and engaging than on competition OSs. Oddly enough the open-source nature of the latter kind of takes away some of the thrill. Eerything is just... there, whereas with Windows there's always quite a bit of digging involved. Or maybe this is Stockholm syndrome; I dunno.
pjmlp 4 hours ago [-]
Why do you think Windows is currently such a mess?
Microsoft new blood has been educated on Macs and ChromeOS, even if they do games it is most likely consoles.
On WinUI community calls you usually would get puzzled faces when the Q&A touched when would WinUI be able to do "insert basic Win32/Forms/WPF" feature.
Management apparently doesn't care they actually understand Windows, or get the required trainings to meet the quality of their predecessors.
That is how you get Webview2 all over the place.
wolfi1 3 hours ago [-]
i fear the times when the chip makers change their architectures and the OS makers have to change the inner working of their OSes but then again, I guess there is an equivalent in the chip-making industry as well
AdieuToLogic 8 hours ago [-]
> One thing that scares me a little is whether there are younger developers, say, 25-40, who can and want to pick up the mantle of Windows internals gurus.
A similar "brain drain" has occurred in macOS (formerly known as OS-X) over the years, as evident in man page documentation for "newer" daemons shipped. An easy way to verify this is to run:
And compare the man pages for the daemons running with the man page for `launchd`.
While this exercise is illuminating, it is also depressing IMHO.
masklinn 3 hours ago [-]
> formerly known as OS-X
It was never OS-X, it was OS X, and originally Mac OS X, as in the one after Mac OS 9. The Mac prefix was dropped with Lion (10.7). The Mac OS lingo having itself been introduced with 7.6, before that the OS core was called System.
pjmlp 4 hours ago [-]
And the documentation, now it is mostly generated, the famous Apple books are now gone, at least the archive is still available.
LatencyKills 9 hours ago [-]
I was a dev on the Visual Studio and Windows teams in the 90s. I’m retired but mentor CS students at two local universities.
I haven’t had a student in two years that was even remotely interested in ring-0, internals, or really understanding a debugger.
I’m not being critical; they are just focused on higher level abstractions.
aleph_minus_one 35 minutes ago [-]
> I’m retired but mentor CS students at two local universities.
> I haven’t had a student in two years that was even remotely interested in ring-0, internals, or really understanding a debugger.
I know quite a lot of such people (even in student age) who are interested in such topics. I really have a feeling that you chose the wrong students at the wrong universities.
Evidence for my point: rather recently, No Starch Press published quite a lot of about such topics - I am rather certain that a publisher knows quite well which kinds of books do or don't sell well at a given time:
Any ideas how this compares with Kerrisk's The Linux Programming Interface? I've only so much time to read one 1000+ page book...
stevenwoo 8 hours ago [-]
It’s fun to understand just for intellectual curiosity’s sake but the number of people who get to work on shipping code where ring-0 knowledge is useful has to be minuscule as a percentage. It feels like a minor miracle I got to work on device drivers in my career. I imagine students might be more worried about completing assignments and good grades than the ins and outs of debuggers, too, though understanding those is important for problems one is more likely to come across in work projects versus smaller school assignments.
Agentlien 6 hours ago [-]
> the number of people who get to work on shipping code where ring-0 knowledge is useful has to be minuscule as a percentage
I wonder if it it is more that the percentage of people who choose to dedicate themselves to that type of work is miniscule. I work in graphics and performance, and it seems similar.
Few people really work on it specifically at any given company, and I've heard people warn others that there are few jobs in it.
But video game companies really want people for those roles and will pay well because they're hard to find. Still, few programmers show any interest in specializing in those skills. If you're passionate about it and willing to learn the details you'll eventually find a lot of job opportunities. I know people who want to work with this and do so - I know many more who have specifically said they want to stay away from it. I don't know anyone who wants to and can't.
movpasd 4 hours ago [-]
How would one start learning about it?
Agentlien 3 hours ago [-]
Before listing resources, let me state that the single most important thing is to learn by doing. Write a lot of rendering code, experiment a lot with your own ideas and variations on each exercise. Once you move past the basics don't be afraid to spend several evenings in a row failing to fix what in hindsight seems like an embarrassingly simple math error. That is how you go from having read and sort of understood something to really knowing it. Also, the best approach is usually to devour as much content as you can from several sources to get a wider perspective.
There are a lot of great resources out there. The best modern beginner friendly resource I am aware of is Scratchapixel[0]. Back when I was first learning 3D I used to follow tutorials on places like NeHe Productions[1], which is probably a bit dated these days.
For more comprehensive information on all kinds of techniques, with examples from big games for each technique, the absolutely best resource is the book Real-Time Rendering[2].
If you're interested in ray-tracing rather than rasterization (i.e. more film than video games) a lot of people recommend "Ray Tracing in One Weekend"[3]. If you want to learn state of the art ray-tracing in depth, with all the math and and theory, the best resource is "Physically Based Rendering: From Theory to Implementation"[4], which is freely available online.
If you want to learn more about how computers work I would recommend the following:
- The OS Dev wiki
- Open Source Firmware Conference
— TKey (shameless plug)
- Tiny Tapeout
- wafer.space
In rough hierarchical order from software to metal.
arjvik 8 hours ago [-]
Arguably the lower level abstractions are more interesting too! how exactly Windows does ring-0 is less interesting than writing your own ring-0! And unless you care about writing driver-level software for Windows or contributing to the kernel, learning this is also less useful.
I'm essentially arguing that unless you work at MSFT, there's next to no reason to learn that specific abstraction layer.
AdieuToLogic 8 hours ago [-]
Speaking of debuggers...
I still twitch whenever someone says "use ddd" and they are not referring to Evans' seminal work.
:-D
dataflow 9 hours ago [-]
> who can
Probably enough to keep Windows going, at least.
> and want to
Not if the pay or location is uncompetitive.
charcircuit 6 hours ago [-]
Why do you think that is not already happening within Microsoft?
majorchord 10 hours ago [-]
Maybe they'll just train Copilot on their code to help them.
im3w1l 9 hours ago [-]
One trend to watch is AI cheat devices. Instead of running detectable software they have a fully separate device that uses AI for object detection and aimbotting. If cheaters move to using those, then the argument for kernel mode anticheat weakens. And that is the cornerstone keeping gamers on windows.
matheusmoreira 4 hours ago [-]
Now I'm looking forward to these AI cheat devices. It's going to be hilarious if the kernel anticheat malware finally gets killed by AI aimbots of all things.
not_a9 8 hours ago [-]
While I’m not sure if this is a bot (where did vidya enter the convo?), game hacking on both cheat and anticheat side has genuinely deep Windows internals knowledge (admittedly somewhat lopsided, but deep nonetheless)
im3w1l 6 hours ago [-]
Producer and consumer sides are tied. If there is strong demand for windows development then there will be money sloshing around which will attract devs. I predict demand will decrease, at least for this particular niche.
To go even further off topic, being called a bot is certainly a wake up call for me that the internet is dying, and I'm not ready for it, and need to reposition myself asap somehow.
pjc50 44 minutes ago [-]
Windows demand is overwhelmingly corporate. Just like Nvidia is barely bothering with gamers at the moment, Windows is not being kept alive for games.
mrheosuper 8 hours ago [-]
Obviously it's Copilot /s
rramadass 3 hours ago [-]
Related to the above, two important concepts to know w.r.t a stack are "Red Zone" and "Guard Pages".
I wonder how Linux manages without explicit _chkstk? In my experience, it feels like MAP_GROWSDOWN regions have way more than 1 guard page below its start — I can poke like a megabyte lower than its start, and the kernel will grow the memory region into there just fine.
inigyou 3 hours ago [-]
It doesn't. This causes the StackClash vulnerability.
This is great. I'm learning Rust myself and your son's article contributed to my knowledge.
I'm also very impressed by part 2. I have my own lisp but I haven't managed to implement a compiler or code generation yet. Really enjoyed reading about the hashmap too. The textbook solution to collisions is probing and comparison. It never occurred to me that I could just resize the underlying array until the collisions disappear altogether.
jjice 7 hours ago [-]
17? You should be very proud. This is good work for anyone, but especially at his age!
anitil 5 hours ago [-]
Very impressive for a 17yo!
ferrow 8 hours ago [-]
[flagged]
Rendered at 10:14:34 GMT+0000 (Coordinated Universal Time) with Vercel.
On compiler generated x86 code, the base pointer register will quickly follow when entering the target function.
From UNIX 7th edition all the way up to C99, when VLAs where introduced, only to be made optional in C11, and the C23 update still doesn't support automatic VLAs, only for function parameters, thus the point stands.
I mean, Chen has decades of winternals in his head. Microsoft has been gutting their staff for years now. When the Petzold/Chen generation hang up their spurs, does Microsoft still have a critical mass of people who understand Windows from the metal up?
Microsoft new blood has been educated on Macs and ChromeOS, even if they do games it is most likely consoles.
On WinUI community calls you usually would get puzzled faces when the Q&A touched when would WinUI be able to do "insert basic Win32/Forms/WPF" feature.
Management apparently doesn't care they actually understand Windows, or get the required trainings to meet the quality of their predecessors.
That is how you get Webview2 all over the place.
A similar "brain drain" has occurred in macOS (formerly known as OS-X) over the years, as evident in man page documentation for "newer" daemons shipped. An easy way to verify this is to run:
And compare the man pages for the daemons running with the man page for `launchd`.While this exercise is illuminating, it is also depressing IMHO.
It was never OS-X, it was OS X, and originally Mac OS X, as in the one after Mac OS 9. The Mac prefix was dropped with Lion (10.7). The Mac OS lingo having itself been introduced with 7.6, before that the OS core was called System.
I haven’t had a student in two years that was even remotely interested in ring-0, internals, or really understanding a debugger.
I’m not being critical; they are just focused on higher level abstractions.
> I haven’t had a student in two years that was even remotely interested in ring-0, internals, or really understanding a debugger.
I know quite a lot of such people (even in student age) who are interested in such topics. I really have a feeling that you chose the wrong students at the wrong universities.
Evidence for my point: rather recently, No Starch Press published quite a lot of about such topics - I am rather certain that a publisher knows quite well which kinds of books do or don't sell well at a given time:
- The Book of Debugging https://nostarch.com/book-of-debugging
- The Linux Memory Manager https://nostarch.com/linux-memory-manager
- The Art of 64-Bit Assembly, Volume 2 https://nostarch.com/art-64-bit-assembly-v2
- The Ghidra Book, 2nd Edition https://nostarch.com/ghidra-book-2e
- Building a Debugger https://nostarch.com/building-a-debugger
- Microcontroller Exploits https://nostarch.com/microcontroller-exploits
- System Programming in Linux https://nostarch.com/system-programming-linux
- The Art of ARM Assembly, Volume 1 https://nostarch.com/art-arm-assembly-volume-1
- Getting Started with FPGAs https://nostarch.com/gettingstartedwithfpgas
- The Book of I²C https://nostarch.com/book-i%C2%B2c
Any ideas how this compares with Kerrisk's The Linux Programming Interface? I've only so much time to read one 1000+ page book...
I wonder if it it is more that the percentage of people who choose to dedicate themselves to that type of work is miniscule. I work in graphics and performance, and it seems similar.
Few people really work on it specifically at any given company, and I've heard people warn others that there are few jobs in it.
But video game companies really want people for those roles and will pay well because they're hard to find. Still, few programmers show any interest in specializing in those skills. If you're passionate about it and willing to learn the details you'll eventually find a lot of job opportunities. I know people who want to work with this and do so - I know many more who have specifically said they want to stay away from it. I don't know anyone who wants to and can't.
There are a lot of great resources out there. The best modern beginner friendly resource I am aware of is Scratchapixel[0]. Back when I was first learning 3D I used to follow tutorials on places like NeHe Productions[1], which is probably a bit dated these days.
For more comprehensive information on all kinds of techniques, with examples from big games for each technique, the absolutely best resource is the book Real-Time Rendering[2].
If you're interested in ray-tracing rather than rasterization (i.e. more film than video games) a lot of people recommend "Ray Tracing in One Weekend"[3]. If you want to learn state of the art ray-tracing in depth, with all the math and and theory, the best resource is "Physically Based Rendering: From Theory to Implementation"[4], which is freely available online.
[0] https://www.scratchapixel.com/
[1] https://nehe.gamedev.net/
[2] https://www.realtimerendering.com/
[3] https://raytracing.github.io/
[4] https://www.pbrt.org/
- The OS Dev wiki - Open Source Firmware Conference — TKey (shameless plug) - Tiny Tapeout - wafer.space
In rough hierarchical order from software to metal.
I'm essentially arguing that unless you work at MSFT, there's next to no reason to learn that specific abstraction layer.
I still twitch whenever someone says "use ddd" and they are not referring to Evans' seminal work.
:-D
Probably enough to keep Windows going, at least.
> and want to
Not if the pay or location is uncompetitive.
To go even further off topic, being called a bot is certainly a wake up call for me that the internet is dying, and I'm not ready for it, and need to reposition myself asap somehow.
Raymond Chen again;
Why do we even need to define a red zone? Can’t I just use my stack for anything? - https://devblogs.microsoft.com/oldnewthing/20190111-00/?p=10...
A closer look at the stack guard page - https://devblogs.microsoft.com/oldnewthing/20220203-00/?p=10...
According to this article, allocation in page sizes with implicit probing is used;
Stack clash mitigation in GCC, Part 3 (-fstack-clash-protection option) - https://developers.redhat.com/blog/2020/05/22/stack-clash-mi...
https://ogghostjelly.github.io/slog/alloca.html
I'm also very impressed by part 2. I have my own lisp but I haven't managed to implement a compiler or code generation yet. Really enjoyed reading about the hashmap too. The textbook solution to collisions is probing and comparison. It never occurred to me that I could just resize the underlying array until the collisions disappear altogether.