The Windows Source Code Revealed: Task Manager (E01)
ฝัง
- เผยแพร่เมื่อ 21 พ.ย. 2024
- The original author of Windows Task Manager takes you on an authorized tour of the Windows source code behind the XP Task Manager. For information on my book, Secrets of the Autistic Millionaire: amzn.to/45ZzcFW
Windows code provided courtesy of Microsoft Corporation; this code is NOT open source and it remains Microsoft copyrighted material, used with permission.
This is what I love about the internet. I was 9 years old when I got to use Task Manager for the first time in 1995 and here we are, almost 30 years later, watching the esteemed author of an application who came to my aid so many times, walking me through the code of the aforementioned application. Its also reassuring that I also name stuff after me in the code when subclassing.
In a modern company you'd just get a code review comment every time you did that.
I was being born when they shipped
subclassing lol
Omg thirty years, that hurted...
tragic windows now is just a massive data farm and not a good os ):
I wish I was tech-savvy enough to understand what is going on here, but I must salute your ability to explain technical stuff and bring it down to a layman's level. Thanks Dave
Some people may be a bit confused as to why minimized is referred to as being iconic. This goes back to Windows 3.1 and earlier. In those older versions of Windows there was no task bar. When you minimized a window an icon for the app was placed on the desktop which was not like today's desktop where you can place files, what went on the desktop back then was up to Windows.
They did change flag names to be minimized instead of iconic (for a while before phasing out the old you could use either names for the flag) but some SDK functions retained the old name for backwards compatibility where the old function just called the new function name until the old name was phased out.
To add to this, there was a WM_PAINTICON message which the system sends to the window to ask it to draw this icon. The default handler draws the class icon but it was also possible to override this and generate an icon on the fly.
I _think_ Windows 95 might send this message and if it detects custom processing then scale down the drawn image to fit the taskbar and title bar icons.
wxWidgets also calls it Iconized in several places. I never understood why, but just went with it. Thanks for history tidbit! Love learning about stuff like this
@@szymonwelgus7930 You are welcome 🙂
I think Dave really should have briefly, a minute or two, explained this instead of leaving it hanging like he did as it is an interesting side note to show how Windows evolved and how remnants of the old still stuck around for a while.
It's one of those things I'd not realized I'd forgotten. The task bar was a huge deal when it popped up.
In high school many years ago my computer science teacher told us that if anyone used a global variable in our code, he would put a red F on our printout with such force that the next three printouts below ours would lose credit. I still tremble when I really need a global variable today.
Great video as always. Thank you so much for this walk through for a program I have needed so many times.
I had a similar thing in college. It was a rule in my first C++ class to not have any global variables.
Don't remember globals being a big issue as much as using goto. If you used it...fail.
@@acacac557 Too true. The problem is that CS (and Computer Engineering) degrees never bother to teach what time is appropriate. My other main complaint is the data structures courses never bother to even tell students to just use a library. I've had to maintain "professional" applications made for the government with custom linked list implementations. With the application being written using C++ in 2015!
@@acacac557yes there is place to use them - right after "//"
And then you step out into the real world and realize code is not perfect and you will do things that you were advised against in college or any book/tutorial etc. Sometimes you just need to get stuff done and will twist "best practices" in order to achieve what you need.
Wonderful!
Yes, please, keep it coming...
I can't wait to watch the next part.
Thank you for taking the time to show this code.
It's literally like opening a time capsule!
And please pass my thanks to MSFT for allowing you to do it. Greatly appreciated!
no, noone will ever pass anything from you.
@@mykyta1235 why do you have to write this? Are you ok?
@@delian66Some people just can't refrain from being insufferable.
@@mykyta1235Peter Noone sucks anyways.
This is the first walk through of real Windows code I've seen. Excellent tutorial on all the details you need to handle when writing a stable application. I even learned about a few features of Task Manager that I hadn't heard about before. I would definitely watch the next part if you make one. 😊
Now I will reverse engineer Windows11's task manager to see the similarities from the Win32 calls.
"With Microsoft's permission"
"Windows XP version"
Yeah, we've seen it
lol troo
even though it's leaked, it's still illegal to distribute it without permission, because copyright (which this video is technically doing)
@@markusTegelane It's in the name, copyright, he didn't share a copy of the actual data that Microsoft owns, they shared a video, it's not the same binary data nor is streamed content copied to machines storage device.
This is really great, I love to see how core windows stuff works, especially because it seems like talented programmers were able to bake in so many features that needed so little resources. Please keep this series up.
This is great code but by no means « core Windows stuff » 😊
Small pro-tip: If you click a function (or method) call while pressing “Control” (or “Command” on Mac), you will go to their definition. This will avoid you right-clicking everything.
Amazing video!
Fantastic review and it's interesting to see behind code :) On another note the cam auto zoom was a bit too aggressive for me and caused some motion sickness.
Sad to see the camera zoom indeed! im a bit dizzy after a minute of watching closely
He turns it off at 9:32 😎
I was getting Wayne’s World vibes
@@at3o 🙏🏼
I came here at 4:43 to comment on this. Haha I am SO distracted by the zooming!
Charles Petzold, what a legend! My first of his books was 'Programming the OS/2 Presentation Manager', taught me a lot!
The more I try to keep up with the code, the more I realize that for many today, including myself, it would be hard to make so many functions and get so many resources without breaking something or a size requirement. Dave you are and will always be a computer hero!!!!
Eh, even Task Man wasn't written and compiled in one go. :-) Sometimes you have to rough in the guts, and then go back and include the error checking, i18n, and security checks you didn't remember the first time.
Dave, as a long time viewer/lurker of your channel, a Windows 3.1 MCP and currently working as a software engineer - this is one of my favorite videos that you have done. I've only written a few projects in Windows C (being lucky that I could leverage the benefits of C# for most of my professional career), but this was an amazing walk through the task manager code and I look forward to the follow up videos.
I appreciate how far C# has come from the early days of C#. I am happy to say its my favorite language.
Programmers like you are an inspiration. The fact that you come from a time when programmers had to study and understand complex concepts from books is awesome.
Had fun with this! In '95, I was a senior in college studying music composition as my major, but programming had always been a hobby for me. Read "Learn Windows Programming in 30 days", but it took me about 6 months. I have fond memories of writing windows programs talking directly to win32.
Really fascinating seeing actual source code of a program I have used for decades and which has brought system back from near death experiences. Looks like straight Win32, no MFC, or newer frameworks so far. I look forward to the next installment.
It's straight win32. Dave says so numerous times. Any dependencies outside itself simply lower reliability (eg if the problem is the framework itself).
straight win32 is the best
Thanks for locking the camera as it was doing my head in
I just want to say i know little about coding and whatever the heck else its called, but being able to bring up task manager when your computer is totally frozen and not working was a god sent blessing and i miss it very much. Came in clutch for me alot of times in the past. Thank u for your work bro
This is the type of content I love seeing as a computer science student and that I wish I saw in my classes. Your way of talking and explaining is so easy to digest, thank you.
"commit seppoku" I think Dave is incredibly... internet experienced. Thank you _so much_ for walking through this code with us Dave!
Whilst most (if not all) of this went clean over my head I still found it interesting, much of that interest came from the comments written within the code! My favourite comment being something about poking your eye with a sharp stick and we would still not be able to see wherever it was! Thank you for the chuckle!
As an aside, during my Btec in engineering my tutor told my best friend and me that we were “computer illiterate!” 🤣
I told him I didn’t need to program it, just use it and I then continued down the mechanical engineering path barely scraping a pass in “computing” ending up in toolmaking which I love.
I really enjoy your videos and find something of interest in most if not all of them.
Ps I hate the shorts, every short, not just yours!
Please make a part two! I'm working on improving our system performance logging and display, so it would extra cool to see how you accomplished that back in the day. Keep up the great work man!
What exactly is slowing you down? I'm sure we could do community code support seeing as most people watching this are devs 😂
Poking yourself in the eye with a sharp stick....had to that a few times😂
You are a legend, Dave. Thanks for posting this behind the scenes, mate 🖖
I'm glad seeing all of these from a professional including a bug in the code. Seeing how the pages and settings communicate with each is really cool. Lot of messaging going on. Looking forward to part 2.
I really appreciate the task kill shell commands you added back in the day. That is the kind of feature that can be built onto years later.
I work in civil engineering (not software), and being able to kill any Windows process via shell commands really helped me improve the reliability of a software service I developed that my department depends on for their daily work.
It probably seems dumb to software engineers, but for someone who just needs to get stuff done - it’s a big deal.
That feature means I can go on a vacation without having to physically log into a machine - personally - to reset a misbehaving program. I can automate it and the users have no idea what happened. It just works!
A sequel with the graphs and performance page would be great!
Videos like these are priceless, we get too see how critical programs we all used (and still use) were written and designed and *why* things were done a certain way! Please keep those going!!
Penguins need HUGS
its like an old song, that still holds up in current times. what a beast of a developer you are man
Definitely continue this series! It's rare to see actual performance hacks in internal code. The code may be old, but the tips and hints are transferable to modern code.
The code is great to see. It is causing long unused synapses to fire signals between "sleeping" neurons and low and behold I can actually recall partial understanding of the code. Seeing you named some functions with your name made me remember I used to get a kick out of using as part of a function name past girlfriend names or composers etc. Knowing in all likelihood I would be the only one to ever know these names were in the code. Early in my coding global variables were my best friends : )
The way you brush over the sharp stick and eyes comment is beautiful
Hi Dave, thank you for walking us through the code. I remember I was 19-20 browsing through my Petzold book and trying to understand how the WM_ messages all worked. Programming Windows was considerably more complex than MS-DOS stuff. It was a wonderful journey of discovery and fun. Thank you for bringing back those memories.
Hey. I see no comments telling how cool was Microsoft authorizing to show us the source. Thanks Dave!
I was blown away too, and am very appreciative... it was one of those long shots!
This is just simply amazing information to take in. Thank you Dave for always bringing the good stuff.
Very interesting video as usual Dave!
Some feedback though, I found the camera constantly zooming in and out somewhat distracting.
In my opinion, it would have been better to have the camera just be static.
Edit: Just got to the part of the video where you disable that lol.
@@glennchugg6015don’t let the door hit you on the way out.
Made me feel ill just trying to watch it. Shame, its interesting stuff.
Thanks for turning that tracking off on that gimbal camera. I would not have watched it to the end if you had left that on.
This is great stuff. I hope you'll look into the bugbug to see if it's actually a bug and to show us what it will look like, once fixed (if needed).
Also glad to see I'm not the only one who prefers cascaded "if (everything is okay) do the next init step" and at the end "if (this is initialized) tear it down" style of coding. I learned it while I was working at ASML where the main function of the program had so much initialization that it ran into a compiler bug, where the optimizer was changing all the branches to go to the bottom of the function, and the branch distance for the earliest "if (everything is okay)" ended up being too big to fit in the instruction. Good times! Apparently the writers of the compiler (or optimizer) didn't count on long lists of "if (everything is okay)" coding.
The priority setting reminded me of the meme when task manager hangs. "You were supposed to defeat them, not join them!" Fantastic review, thank you for the walk through.
I love how you're looking at this code on a Mac.
Explaining how the program uses SetPriorityClass answers a question I've had in my mind for like 20+ years. Thanks Dave!
Ah, Windows SDK programming. The big switch, a dog-eared copy of Petzold, MSDN on CD's and lots of coffee...those were the days. Then MFC, an abstraction that was easier to use but not as much fun. Thanks for this code walk-through. Please do continue, always interesting to see a competent developer's code.
Uff that auto cam zooming is extremely annoying and really distracting from the otherwise awesome video
Agree
9:19
Oh lighten up ya wuss @bas8036
@@midas6659it's valid feedback 🤔 not sure why that makes them a wuss. Maybe you should stop projecting your insecurities
Came here to say the same thing. Unwatchable
Love it. Keen to see the next task manager episodes! Great to see ms systems engineers approach to solving the problems and structuring the code
"Windows does some fancy focus management" while your camera is doing the wildest zoom management I've ever seen 🤣. Thanks for sharing some content that only you could Dave 👍.
This is one of my favorite code reviews & I've watching over half of all your videos - would love to see the rest when you have time - PS - loved the Highlander reference - "We are the only One" - "The one true task manager"
I liked XP , had a comfortable feel and just enough buttons and bells. Software of the time likewise had limited buttons which was much easier to remember. Did a lot of restoring old brown type photos. The deep emulsion use captured many details scanned at high resolution then broken into colors, each sharpened, reunited and bingo all the lost details background items . It was fun . Thanks Dave.
I love these code reviews, and especially since this is your own work almost 30 years ago!
Dave, I just wanted to say, there are some great lawyers on youtube, there are some great doctors, and there are some great scientists in many subjects.
Among computer scientists you are right up there with the best of your field. The platform is strong because of people like you. Videos from true experts in their fields are invaluable. TH-cam owes you people everything.
I think TH-cam owes 90% of their revenue to product reviewers (not the in depth ones, but the sponsored ones) and mainly lifestyle vlogging content. It’s a shame, but that’s how it is. Just log in to TH-cam from an incognito tab and see what crap is on the frontpage.
@@LuLeBe yeah i've checked in incognito before. it's scary what the mainstream watches lol
@@LuLeBeContent promoted on the main page , from not logged account: 90% fake people, showing their fake asses , boosting of their fake online existence? It hurts my eyes.
I enjoyed seeing how small, well written, clean, and well laid out code used to be written.
I love that he's using MacOS to show Windows source code.
It's so great to see a legend reviewing a legendary piece of code that we always saw and will see. Thanks....
With XP limited to 4GB (not counting the 64-bit version), and with the surprising number of times that "mature" and "up to date" programs "go 100%", Task Manager is my ever present co-pilot. Please keep the TM videos coming.
32-bit Windows XP actually works with more than 4GB of RAM by using PAE. I believe this was usable in the original release but then the use of extra memory was disabled in SP1 due to compatibility issues with drivers assuming 32-bit addresses. Server versions don't have this compatibility fix and will still work with more than 4GB of RAM.
@@eDoc2020 Try reading the threads on this. "Nightmare" and "can of worms" come to mind.
@@FloydMaxwell Like I said, compatibility issues. I wouldn't expect it to work with a random old system.
@@eDoc2020I remember using DOS Extenders to allow 80286/386 programs to access memory above 1MB. Those were the days...
This was more fun than it had any right to be, really brought me right back to my days coding Windows apps. Your code was very clean and easy to follow.
I can remember after running Windows for workgroups for about 5hrs we would start getting a low memory pop-up, telling us to close application's to continue. Even with no application's running 😂 task manager would still manage to run! It became department policy to shut down your pc at lunchtime so clear the memory leaks. We only ever needed to do this with Windows for workgroups!
I still like to play about in DOS for a bit of nostalgic fun. Keep the video's coming Dave as they remind me of the good old days 😊
Brilliant blast from the past of Petzold-era programming techniques for Windows. So many patterns I remember using from the late 80's and early 90's.
Truly enjoying this code review - any chance of spinning up XP and seeing it in action -- as a way to show the code and what it is actually handling -- As a long time VB dev - started with VB 1 and VB dos - rarely got down to this level in the Win 32 API and related code. Many thanks for the effort of getting source and MS permission to review -- speaks of changes at MS toward open source (sorta)
I wonder if, some day, we could get the activation lock turned off on XP? I know there's a potential threat that some people would then _use_ it, because it might still be useful enough to get away with doing that. But I just want to play with old computers.
@@nickwallette6201 The activation master key and algorithm have been decrypted, it is now possible to 'roll your own' telephone activation. Just a matter of looking in the right places
I love the random windows keyboard shortcuts I learn aside from all the other things I learn!
Also thank you for your book! I have to say it felt quite disturbing reading a diary I never wrote! Got a diagnosis and your book has helped me greatly in coming to terms with things not just being my quirky personality!
Wow, glad you found it useful!
Dave, I don't use Microsoft myself anymore, but I did at the time you were working there. I've enjoyed your channel. You're a bright guy and do a good job on your videos.
This is so amazingly well written code. It took me years to write code like this. Bravo.
This a master class in how you can build a lean and mean Windows project. Takes me back to the early 90s before all the bloated libraries when you had to handle the message loop yourself. Actually coded many things in OS/2 using similar techniques. Difference was, we did everything in C which was error prone when not careful about memory, device drivers etc.
This is great. Its insane how much i used this. Back in 95/98/2000/XP it became something I became very comfortable with and the amount of control itd give me was really nice.
Can we just take a min to thank Microsoft aswell here! Its incredible to me they've allowed him to do this and given him the actual code, yeah its 20 years old but still.
Great throwback, Dave. I'm still using nested parm checks, Hungarian notation and HRESULTs. And I have a strange attraction to Winddows Runtime Library. Guess that makes me a dinosaur.
It would be really neat to see a series recreating the task manager, showing all the changes you'd do differently these days vs what was written back then, and the actual development process, testing, debugging, and such.
Omg. Thank you for setting the priority high. I do remember that on some windows update it was removed, probably when the whole thing with xbox ui came in. I hated when that was taken away.
Thank you so much
I'm truly enjoying this code walk through. Please continue this series. 🙂
This has been an extremely enjoyable "Peek behind the curtain". Waiting with anticipation for future episodes on the Task Manager source.
Question: quite often during development I will think of something that wasn't in my original scope; but it makes a lot of sense to add. Sometimes it is just something to handle, or a way of handling something behind the scenes, sometimes it is user functionality or feedback to the user. Often I will be left wondering why this something wasn't obvious to me at the outset of the project. Is there a part of Task Manager's code or functionality which you added at some stage and which made you wonder why you hadn't thought to include it in the first revision?
Enjoyed the more laid-back/unscripted tone and attitude this video had. Hope to see more like this!
As an IT student who tends to suffer when it comes to programming i still find looking at source codes fascinating.
Despite understanding almost nothing
I used Task Manager so many times. Watching you go through this code is nostalgic. Takes me back to my days in the USAF and fixing computers. Usually killing processes or finding them. And usually they were malware or viruses that anti-virus missed. Those were the days.
That ‘HIGH_PRIORITY_CLASS’ was gold. I remember task manager having that.. I knew I wasn’t crazy!
Simple and Impressive as always Dave. Greetings from Asunción Paraguay.
Thanks Dave. I love your "What was Dave thinking when he wrote that" videos and insights they provide.
Just adding my comment to encourage future videos on the rest of the code. Thanks, Dave, and please keep them coming!
The only channel on yt that reeally explains my childhood, and love the code true work of art.
Wow. that little priority thing there. I've missed so much I often talk to my friends about back in the XP days. Task manager was actually useful for stopping frozen programs. That's so annoying that it would be such an easy fix. I always just assumed it was simply something complicated. I would gladly give up system resources knowing. task manager was powerful. I assumed somehow it had been programmed in over top of windows so it could work even when Windows was frozen. not just a priority thing.
yes but assigning task manager the highest process priority is not good because then if you use task manager to gauge the performance of the system, task manager itself is impacting the measurements. Also since a long time you can instead use Priority Boost and call SetProcessPriorityBoost for dynamic priority meaning your application doesn't have a fixed high priority but when you interact with the window it gets priority.
Whoever decided to change it needs a good talking to.
Wow! I've been catching up on your channel for a couple of weeks now. I was the author of "System Monitor" for the Commodore Amiga. A predecessor to Task Manager. I would love to chat some day!
Incredible Dave, you were performing at a high level during your time at Microsoft 🎉
Just LOVE these sessions! Nostalgia, learning, peeking inside stuff and get entertained all in one.
Generally speaking I had no idea what you were talking about. I still enjoyed the video though, and appreciated your company. So thank you.
This is extremely interesting! I always thought the Win32 UI api was very verbose and was very curios how people were building useful apps from scratch without Qt, XAML and the rest. It's very cool to see this code with the explanations of what it does and why. Can't wait for the next part!
I was using VB back then. It always frustrated me that you were walled out of so many things that Windows applications apparently _could_ do, like dragging the window from anywhere, or locking the minimum size, etc. There were WM controls you could drop in to subscribe to events, but then you were basically dropped into the deep end of the WinAPI, and had to be able to translate documentation written for C programmers to the types you had access to in VB.
So now, it's enlightening to see how those tricks were done. It all totally makes sense, and the verbosity highlights one of the reasons why VB didn't give you the rope to hang yourself.
Great stuff Dave! Had my Windows XP VM up with Task Manager running to follow along 🙂. Keen to see more!
This was very entertaining! I'd love to see more of the Taskmanager code. Especially the part where processes are terminated, and things like the protection to avoid that lsass.exe is terminated
I would love subsequent parts to this! I'm learning to program and being able to see the code and the thinking behind it is fascinating!
Thanks for acknowledging the camera! (~9:25) it was driving me nuts, your face stayed in place but the background was kinda zooming in and out.
Thank you very much for this walkthrough. The coding style/ readability is brilliant! I will start referring everyone I know to this, before they create pull requests I can review!
I got started with a windows 3.1 book, called : write programs in windows 3.1. the first program, wasn't a program! but just a simple hello world popup press ok box! ha..ha.. good times..
I didn't have a good enough dial-up, so I had 2 download the symbols & libraries. from my public library!! jeez! crazy times! great video Dave! yup! the zoom! ugh!
Thank you for taking me down memory lane. I was many years ago I was honored to work on MS Word 95 in support of this.
Hola, Dave. Te sigo desde España. Tu canal es el mejor sin duda en programación. Mi listening es muy malo y apenas comprendo lo que dices. Tengo mucha ilusión en los avances de la IA y espero ansioso el día en que TH-cam incluya la opción de doblaje de voz a otros idiomas. Algo que la IA ya ha conseguido y que me consta las plataformas podrán ofrecer en un futuro cercano. Cuando eso pase, voy a recorrer todos los vídeos de tu canal desde el más antiguo en adelante.
Gracias!
Mr Davo no habla el españolo
I remember when Task Manager came out. Seemed like sorcery. I am a software developer. I have to admit that, over the years, my mind has often wondered about the inner workings of Task Manager. Nice to know who made it, and nice to see inside.
I know very little of what you're talking about but the way you talk about it is riveting.
It was an enjoyable experience, you are very talented at explaining the code while keeping it interesting. Looking forward to part 2!
Amazing, you got a new subscriber. I love watching you guys who made that kind of stuff back in the day, it's so interesting to me to listen to you people and get an insight in what your thought processes and situations were back then 😊
great video
its like a time capsule, seeing your old code after so long
Absolutely interesting dive into the code there :)
And I did love the "Task manager killing Windows" gag, keep it up :)
This was a fun walk-thru. Interesting to hear your thought process in writing the code as you walked us through it.
I was interested in how commenting is added, plus the top down approach you seemed to use.
Thanks for sharing. Wish I had someone like you around when I was first learning good coding habits.
I love how you added comments everywhere.
Hey Dave! Thanks for going through this source code. As someone who hates User32/GDI32 libraries and anything included via windows.h (valid reasons such as legacy, naming, drawbacks of message handling, SetWindowLongPtr etc) with a passion and also someone who is making a windowing API akin to SDL2/GLFW, I really appreciate your code going over the messages; it reaffirms my frustration I've been having with the... weird messages that do weird things... that have been inherited up to windows 10.
Fascinating. You think you could do a rundown/review of the Resource Monitor some time soon?
Dave, I noticed a couple of verbal phrases that make me think you are Canadian, the number 1 being your sign off "In the mean time and in between time"
That was sign off of legendary Stampede Wrestling announcer Ed Whalen. "In the mean time, and in between time, that's it for another edition of Stampede Wrestling."
If you are, know that that phrase brings back fond memories of my childhood :)