Latest / CyberSecurity Summary / Windows 10 System Programming, Part 1
Transcript
- 0:00Speaker 1: Welcome to the deep dive. Today. We're really peeling back
- 0:03Speaker 1: the layers of your Windows ten computer.
- 0:06Speaker 2: Yeah, going straight to the core.
- 0:07Speaker 1: Exactly how software actually interacts with the operating system. One
- 0:12Speaker 1: of you asked for a deeper look, and well, here.
- 0:14Speaker 2: We are, absolutely and we've got a really good technical
- 0:17Speaker 2: book to guide us. We'll be digging into the key
- 0:20Speaker 2: insights on the fundamental stuff.
- 0:22Speaker 1: Like processes, threads.
- 0:23Speaker 2: Right, memory management, and that crucial world of IO input
- 0:27Speaker 2: output operations.
- 0:29Speaker 1: Our mission then for this deep dive is to get
- 0:32Speaker 1: right to the heart of how Windows actually juggles all
- 0:35Speaker 1: the programs you run and the resources they all need.
- 0:38Speaker 2: We're aiming for those moments where it just clicks.
- 0:40Speaker 1: Yeah, those aha moments where you think, oh, that's why
- 0:43Speaker 1: my system does that. So let's start at the very
- 0:45Speaker 1: beginning processes.
- 0:47Speaker 2: Okay, so book right away makes this really important point.
- 0:50Speaker 2: It might even surprise you. We usually think of a
- 0:53Speaker 2: process as the thing that's running, but it's actually more
- 0:57Speaker 2: accurate to think of it as a management object, a container. Basically,
- 1:01Speaker 2: I contain yeah, the actual work, the code execution that's
- 1:05Speaker 2: done by threads within the process.
- 1:07Speaker 1: Okay, So processes are like maybe office buildings, and threads
- 1:11Speaker 1: are the workers inside.
- 1:13Speaker 2: That's a great analogy. Exactly one can't really function without
- 1:16Speaker 2: the other, but they definitely have distinct roles.
- 1:18Speaker 1: Interesting, So if the process isn't the runner, what does
- 1:22Speaker 1: it actually own what's inside this office building?
- 1:25Speaker 2: Well, a process is responsible for some critical things. First,
- 1:28Speaker 2: it gets its own private address space. Think of it
- 1:31Speaker 2: like its own dedicated chunk of memory, its floor plan. Okay.
- 1:35Speaker 2: Then it holds one or more threads, the workers. It
- 1:38Speaker 2: also keeps a handle table.
- 1:39Speaker 1: A handle table like an inventory list short of.
- 1:42Speaker 2: Yeah, yeah, an inventory of all the system resources it's using.
- 1:45Speaker 2: And critically, it's assigned a unique process ID.
- 1:48Speaker 1: Or PID PIDs. Right, we see those in task Manager
- 1:51Speaker 1: all the time. Now, the book says they're unique but
- 1:53Speaker 1: also reusable. How does that work? I sort of assumed
- 1:56Speaker 1: a PID was like permanent.
- 1:58Speaker 2: Yeah, that's common thought. But the key thing is a
- 2:01Speaker 2: PID uniquely identifies a currently running process.
- 2:04Speaker 1: Ah only while it's active.
- 2:06Speaker 2: Exactly as long as that kernel object representing the process exists,
- 2:10Speaker 2: the PID is its tag. But once the process finishes,
- 2:14Speaker 2: poof that kernel object is gone.
- 2:16Speaker 1: And the number can be used again.
- 2:17Speaker 2: Later, right for a completely different new process it's like
- 2:21Speaker 2: reusing raffle ticket numbers for different draws.
- 2:23Speaker 1: That makes total sense, and it's a good reminder. Then,
- 2:25Speaker 1: when we see say multiple Chrome Windows Open or Word instances,
- 2:30Speaker 1: each one is its own distinct process, with its own PID,
- 2:33Speaker 1: its own resources, even though they all started from the
- 2:36Speaker 1: same program file.
- 2:37Speaker 2: Precisely, the dot exc file is the blueprint, but each
- 2:40Speaker 2: running instance gets its own private stuff. Now about that
- 2:44Speaker 2: address space, the private memory. Yeah, the book lays out
- 2:47Speaker 2: some different sizes. It depends on whether it's a sixty
- 2:49Speaker 2: four bit or a thirty two bit process.
- 2:51Speaker 1: Right. For sixty four bit processes on sixty four bit Windows,
- 2:55Speaker 1: we're talking massive amounts of space, right, like eight terabytes
- 2:58Speaker 1: or even one hundred and twenty eight.
- 2:59Speaker 2: Terrabyte, Yes, staggering numbers. Eight terabytes on Windows eight and earlier,
- 3:03Speaker 2: and then one hundred and twenty eight terabytes from Windows
- 3:05Speaker 2: eight point one onwards. It's like having an almost infinite
- 3:07Speaker 2: address book.
- 3:08Speaker 1: Okay, but what about those older thirty two bit programs,
- 3:12Speaker 1: the one still running on our modern sixty four bit systems.
- 3:15Speaker 2: Ah Okay, that's where it gets a bit more nuanced.
- 3:19Speaker 2: By default, a thirty two bit process only gets a
- 3:22Speaker 2: two gigabyte address.
- 3:23Speaker 1: Space only two gigs.
- 3:25Speaker 2: But if the program was built with a special flag,
- 3:28Speaker 2: a setting called large address aware.
- 3:30Speaker 1: Large address aware.
- 3:31Speaker 2: Yeah, if it has that flag, it can actually access
- 3:34Speaker 2: up to four gigabytes on a sixty four bit system.
- 3:36Speaker 1: So it doubles its potential memory pretty much.
- 3:39Speaker 2: Think of the flag as the thirty two bit program
- 3:41Speaker 2: telling the sixty four bit system, Hey, I know how
- 3:44Speaker 2: to handle more memory addresses than usual.
- 3:46Speaker 1: Okay, so that flag signals it's ready for more space. Now.
- 3:49Speaker 1: Another key piece here seems to be these dynamic link
- 3:51Speaker 1: libraries DLLs.
- 3:54Speaker 2: They're everywhere we really are. Dls are essentially packages. They
- 3:58Speaker 2: contain codeta resources things a program might need, and they
- 4:02Speaker 2: get loaded into a process dynamic or dynamically, meaning either
- 4:06Speaker 2: when the process starts up that's called static linking even
- 4:08Speaker 2: though it sounds contradictory, or later on when the process
- 4:11Speaker 2: explicitly asks for it, which is true dynamic linking.
- 4:13Speaker 1: The book mentions you can't just run a DLL directly,
- 4:16Speaker 1: right because they don't have that main entry point like
- 4:19Speaker 1: an executable.
- 4:20Speaker 2: Correct, no main function. But the really interesting part and
- 4:24Speaker 2: a big efficiency thing is the memory sharing.
- 4:26Speaker 1: Ah, yes, tell me about that.
- 4:29Speaker 2: So when multiple processes are using the same DLL, especially
- 4:32Speaker 2: those common Windows DLLs in the system thirty two folder.
- 4:35Speaker 1: Like kernel thirty two dot dll.
- 4:37Speaker 2: Exactly or User thirty two dot DLL. The actual code
- 4:40Speaker 2: from the DLL can be shared in physical.
- 4:42Speaker 1: RAM, so you don't have multiple copies loaded, right.
- 4:45Speaker 2: It avoids wasting precious RAM. It's a huge win.
- 4:48Speaker 1: And these particular DLLs, the subsystem ones, they're the ones
- 4:51Speaker 1: that actually implement the core Windows API. Aren't they the
- 4:54Speaker 1: functions that applications call to talk to the OS.
- 4:57Speaker 2: That's precisely it. They're the gateway for norm user mode
- 5:00Speaker 2: applications to access the underlying power of the Windows kernel.
- 5:04Speaker 2: And this focus is really what the book is all.
- 5:06Speaker 1: About, which leads us nicely into the broader Windows architecture
- 5:09Speaker 1: user mode versus kernel mode.
- 5:12Speaker 2: User mode is where our everyday apps live, Notepad, your
- 5:15Speaker 2: browser games, plus those subsystem DLLs we just talked about,
- 5:20Speaker 2: and also something called win.
- 5:21Speaker 1: RT and kernel mode is the deeper layer, the engine room.
- 5:24Speaker 2: Correct, that's the privileged part of the OS where the
- 5:27Speaker 2: core components run, managing hardware security, that kind of thing.
- 5:30Speaker 1: So user processes, subsystem DLLs and win RT, what's.
- 5:34Speaker 2: That win RT or Windows run Time is a newer
- 5:38Speaker 2: API layer. It came in with Windows eight, mainly for
- 5:41Speaker 2: those Universal Windows Platform apps UWP apps.
- 5:44Speaker 1: The ones from the Microsoft Store mostly.
- 5:46Speaker 2: Yeah, it's built on an older technology called comm Component
- 5:49Speaker 2: Object Model, which is all about software components talking to
- 5:52Speaker 2: each other. And win RT supports multiple programming languages.
- 5:55Speaker 1: Interesting, and it's not just for UWP apps. No.
- 5:58Speaker 2: Recently a subset of win rts is actually available for
- 6:00Speaker 2: traditional desktop applications too. Seems like Microsoft is trying to
- 6:04Speaker 2: bridge the gap between those two worlds.
- 6:06Speaker 1: Makes sense now for anyone listening who's thinking about actually
- 6:08Speaker 1: doing some Windows system programming. The book mentions Duols Visual
- 6:12Speaker 1: Studio primarily.
- 6:13Speaker 2: Yeah, Visual Studio is the main integrated development environment the ID.
- 6:18Speaker 2: The book emphasizes just getting your development set up right
- 6:21Speaker 2: from the start.
- 6:22Speaker 1: And it mentions that even doing a basic Hello World
- 6:25Speaker 1: application can teach you something.
- 6:27Speaker 2: Absolutely. Just compiling it shows you the process and you
- 6:30Speaker 2: might notice subtle differences depending on whether you build it
- 6:33Speaker 2: for a thirty two bit system that's by eighty six
- 6:36Speaker 2: or a sixty four bit system by sixty four.
- 6:38Speaker 1: Okay, And following on from that, character encoding Unicode this
- 6:43Speaker 1: sounds important.
- 6:43Speaker 2: It's crucial, especially for software that needs to work globally.
- 6:47Speaker 2: There's a Unicode setting usually set by default and visual
- 6:50Speaker 2: studio when you.
- 6:50Speaker 1: Compile, and that affects how strings are handled.
- 6:53Speaker 2: Yes, yes, it determines whether a type like lpctstr in
- 6:57Speaker 2: the code represents text using UTFS sixteen, which can handle
- 7:01Speaker 2: pretty much any character from any language, or the much
- 7:04Speaker 2: more limited ASCI standard.
- 7:05Speaker 1: So UTS sixteen is generally preferred definitely, and.
- 7:09Speaker 2: You see this directly in the Windows API functions themselves.
- 7:12Speaker 2: A function like creep mutex, for example, isn't really one function. Well,
- 7:15Speaker 2: it's like a macro. The compiler expands it to either
- 7:18Speaker 2: create mutex WZ the WS for wide characters UTF sixteen,
- 7:22Speaker 2: or create mutexa A for ANSI or ASCI ah.
- 7:27Speaker 1: Okay, So using Unicode means you automatically get the w versions,
- 7:31Speaker 1: which prevents your text getting garbled if it contains non
- 7:33Speaker 1: English characters.
- 7:34Speaker 2: Exactly. It voids data loss and makes your software work
- 7:37Speaker 2: correctly with international text, absolutely vital these days.
- 7:41Speaker 1: The book also flags safer ways to handle strings right
- 7:44Speaker 1: like wccswise.
- 7:46Speaker 2: Yes and functions from the struceay dot EA CHEDDAR. It's
- 7:50Speaker 2: quick reminder that the old C style string functions can
- 7:52Speaker 2: be risky, you know, buffer overflows and security issues. These
- 7:55Speaker 2: newer functions are designed to be much safer.
- 7:57Speaker 1: Good practice to use them and for the code example.
- 8:00Speaker 1: In the book, it mentions helper libraries WISHL and WTL.
- 8:03Speaker 2: Yeah, the Windows Implementation Library WIL and Windows Template Library WTL.
- 8:08Speaker 2: They basically provide convenience C plus plus wrappers around the
- 8:12Speaker 2: raw Windows API.
- 8:13Speaker 1: Makes things less tedious pretty.
- 8:15Speaker 2: Much save if you write in a lot of boilerplate code.
- 8:17Speaker 2: Makes development quicker and less error prone. The book also
- 8:20Speaker 2: touches on Hungarian notation.
- 8:22Speaker 1: Oh yeah, that naming convention like hend for a window
- 8:24Speaker 1: handle exactly.
- 8:26Speaker 2: Or else dir for a pointer to a string. It's
- 8:29Speaker 2: an older style you'll see in the Windows API documentation.
- 8:32Speaker 2: In older code, it embeds the variable type.
- 8:35Speaker 1: In the name, A bit of a historical thing. You
- 8:37Speaker 1: don't have to use it in new code.
- 8:38Speaker 2: No, not really, It's just good to recognize you when
- 8:40Speaker 2: you see it. Okay, So moving on. No system programming
- 8:46Speaker 2: discussion is complete without error handling. What happens when things
- 8:49Speaker 2: go wrong?
- 8:51Speaker 1: Right? How does the Windows API tell you something failed?
- 8:54Speaker 2: There are a few common patterns you'll see. Functions return
- 8:57Speaker 2: a bool. Generally, non zero means success es.
- 9:00Speaker 1: Zero means failure, but don't check for exactly true.
- 9:03Speaker 2: Right The book warms about that success might be one,
- 9:06Speaker 2: or might be two or something else non zero, Just
- 9:08Speaker 2: check if it's zero or not. Think you have types
- 9:10Speaker 2: like l status or long. With those, zero usually means success.
- 9:15Speaker 2: The constant error success is actually zero. Any positive value
- 9:18Speaker 2: indicates a specific.
- 9:20Speaker 1: Error code, an h result.
- 9:21Speaker 2: A result is common two, especially with Calm and Newer
- 9:25Speaker 2: APIs zero or positive generally means success as okay is
- 9:30Speaker 2: zero and negative values signal different errors.
- 9:33Speaker 1: So when a function does fail, how do you find
- 9:35Speaker 1: out why?
- 9:37Speaker 2: The main way is to immediately call to get last
- 9:39Speaker 2: air function immediately Yes, because the next API call might
- 9:43Speaker 2: overwrite the error code and critically get laster gives you
- 9:47Speaker 2: the error code for the current thread.
- 9:49Speaker 1: Ah, So each thread has its own last error value precisely.
- 9:52Speaker 2: If you have multiple threads, you can assume one thread's
- 9:55Speaker 2: error relates to another's failure. It's threads specific.
- 9:58Speaker 1: Got it? Okay? What about finding out Windows version? The
- 10:01Speaker 1: book says the old way get version X is kind
- 10:03Speaker 1: of deprecated now.
- 10:04Speaker 2: Yeah, it's not recommended for various reasons related to compatibility settings.
- 10:08Speaker 2: The modern approach is better, which is there's a header
- 10:11Speaker 2: file version all PRIs dot age with a bunch of
- 10:13Speaker 2: simple functions like is Windows expra, greater, is Windows ten
- 10:16Speaker 2: or greater is when a server and so on.
- 10:18Speaker 1: They just return true or false.
- 10:20Speaker 2: Exactly, much cleaner for most common version checks. Under the
- 10:23Speaker 2: hood they use a more fundamental function called verify version info.
- 10:27Speaker 2: Usually the helpers are all unique.
- 10:29Speaker 1: Okay, nice and simple, right, let's ship gears. Objects and handles.
- 10:34Speaker 1: These sound absolutely central to Windows.
- 10:36Speaker 2: They are fundamental. Handles are everywhere. The book describes them
- 10:40Speaker 2: as basically identifiers for kernel objects.
- 10:42Speaker 1: Kernel objects being what kinds of things.
- 10:45Speaker 2: These are the core resources managed by the Windows kernel itself,
- 10:48Speaker 2: things like files you open, processes that are running threads
- 10:53Speaker 2: doing work, synchronization tools like Mutex's events, all the basic building.
- 10:58Speaker 1: Blocks, okay, And the handle is how our program.
- 11:01Speaker 2: Refers to them, exactly. It's an abstract token, like a
- 11:03Speaker 2: ticket or a claim check. Your user mode program uses
- 11:07Speaker 2: the handle to tell the kernel which object it wants to.
- 11:09Speaker 1: Interact with, so it provides a layer of abstraction and security.
- 11:12Speaker 2: Yes, you don't get direct access to the kernel's internal
- 11:15Speaker 2: data structures. You operate through the handle.
- 11:18Speaker 1: So when we call say, create mutechs to make a
- 11:21Speaker 1: synchronization object.
- 11:22Speaker 2: If it works, you get back a handle value, a
- 11:25Speaker 2: number basically that represents that mutex object living down in
- 11:29Speaker 2: the kernel. And if it fails, the return values usually
- 11:32Speaker 2: zero or null. And then there's open mutex, which is
- 11:36Speaker 2: specifically for getting a handle to a mutex that already
- 11:39Speaker 2: exists and has a name.
- 11:41Speaker 1: Right. Create mutex is interesting because if you give it
- 11:44Speaker 1: a name, it can either create a new named mutex
- 11:49Speaker 1: or it can open an existing one with that name.
- 11:51Speaker 2: How do you know what happened?
- 11:53Speaker 1: Even if create mutex succeeds in opening an existing one,
- 11:56Speaker 1: if you call get last ray after, it will return
- 11:58Speaker 1: error already.
- 11:59Speaker 2: Exists, ah okay, whereas open mutex just fails if the
- 12:02Speaker 2: name mutex.
- 12:03Speaker 1: Isn't there, correct, it won't create one for you.
- 12:05Speaker 2: Now, the book breaks down what's sort of conceptually in
- 12:08Speaker 2: a handle, A pointer to the object and access mask
- 12:11Speaker 2: and flags.
- 12:12Speaker 1: Yeah, that's a simplified view. The access mask is super important.
- 12:15Speaker 1: It defines what operations you're actually allowed to perform using
- 12:18Speaker 1: that specific handle, like permissions exactly. For instance, if you
- 12:22Speaker 1: want to terminate another process. You first need a handle
- 12:24Speaker 1: to it. You get that using open.
- 12:26Speaker 2: Process, but when you call open process you have to
- 12:29Speaker 2: explicitly request the process terminate access right. If the handle
- 12:34Speaker 2: you get back doesn't have that right in its access mask,
- 12:36Speaker 2: then calling terminate process with that handle will just fail.
- 12:39Speaker 1: So the handle encodes the permissions. What about the flags
- 12:43Speaker 1: inheritance Protection from close.
- 12:45Speaker 2: Inheritance means whether a child process created by this process
- 12:49Speaker 2: automatically gets a copy of the handle. Protection from close
- 12:53Speaker 2: handle flag protects from close is a safety feature makes
- 12:56Speaker 2: it harder to accidentally close a really important handle.
- 12:58Speaker 1: Can you change these flags?
- 13:00Speaker 2: Yes, using set handle information and get handle information. And
- 13:04Speaker 2: if you really want to see all the handles a
- 13:05Speaker 2: process has.
- 13:06Speaker 1: Open process explorer.
- 13:08Speaker 2: Process Explorer from cysinternals is the tool. It's invaluable. It
- 13:12Speaker 2: shows the handle value, the type of object, file, thread,
- 13:15Speaker 2: mutex its name if it has one, the object's address
- 13:17Speaker 2: in kernel memory, the raw access mask, and even a
- 13:20Speaker 2: decoded human readable version of the access rights like looking
- 13:23Speaker 2: at the process's internal toolkit.
- 13:25Speaker 1: Definitely a must have tool. Now, managing these handles in code,
- 13:29Speaker 1: especially C plus plus plus A, seems error prone. The
- 13:33Speaker 1: book introduces a smart handle wrapper class.
- 13:36Speaker 2: Yes, it demonstrates a concept called r AII. R AI
- 13:40Speaker 2: resource acquisition is initialization. It basically means the handle resource
- 13:45Speaker 2: is acquired when the C plus plus wrapper object is created,
- 13:49Speaker 2: and crucially, it's automatically released. The handle is closed when
- 13:53Speaker 2: the wrapper object goes out of scope or is destroyed.
- 13:56Speaker 1: Ah, so it cleans up after itself. Prevents handle leaks exactly.
- 14:00Speaker 2: It makes handle management much safer and easier. The example
- 14:03Speaker 2: class also prevents axidel copying of handles, but allows transferring
- 14:08Speaker 2: ownership using something called move semantics. Very useful C plus
- 14:11Speaker 2: plus features neat.
- 14:12Speaker 1: Okay, What about object naming and sessions? Names aren't always
- 14:16Speaker 1: global usually?
- 14:17Speaker 2: Know when your regular user application creates a named object
- 14:21Speaker 2: like a name mutex, that name is typically only visible
- 14:24Speaker 2: within your current user login session.
- 14:26Speaker 1: So another user logged in wouldn't see it.
- 14:27Speaker 2: Correct unless you specifically create it in the global name space.
- 14:30Speaker 1: How do you do that?
- 14:31Speaker 2: You prefix the name with global like global mouse, shared, mutechs.
- 14:36Speaker 2: These live in a special base named objects directory in
- 14:39Speaker 2: the kernel's object manager name space.
- 14:42Speaker 1: Can any application do this?
- 14:44Speaker 2: Well, there's a catch. Modern sandbox apps called app containers
- 14:48Speaker 2: usually don't have the permissions to create objects in the
- 14:50Speaker 2: global name space. It's mainly for services or older desktop
- 14:54Speaker 2: apps needing system wide coordination.
- 14:56Speaker 1: So if you have two separate programs, maybe even started
- 14:59Speaker 1: by different users, they could use these global named objects
- 15:02Speaker 1: to communicate or synchronize.
- 15:04Speaker 2: Yes, that's a primary use case. One process creates the
- 15:07Speaker 2: named object, create mutex with the global name, and another
- 15:10Speaker 2: process can open it using the same name, open mutext,
- 15:13Speaker 2: or even create utechs. Again, the name acts is the
- 15:15Speaker 2: rendezvous point.
- 15:17Speaker 1: Interesting. Another mechanism mentioned is handle duplication using duplicate handle.
- 15:22Speaker 1: What's that about?
- 15:22Speaker 2: This lets you take a handle you have in your
- 15:24Speaker 2: process and create a new handle, potentially in a different
- 15:27Speaker 2: process that refers to the exact same underlying kernel object.
- 15:31Speaker 1: Why would you do that?
- 15:32Speaker 2: A common reason is when a parent process starts a
- 15:35Speaker 2: child process, the parent might want to give the child
- 15:38Speaker 2: access to one of its own open handles, like maybe
- 15:42Speaker 2: it's standard input or output pipe, So.
- 15:44Speaker 1: You duplicate the parent's handle into the child's process space.
- 15:47Speaker 2: Exactly, you need a handle to the target process with
- 15:49Speaker 2: the process you panel permission to do this. You can
- 15:52Speaker 2: even duplicate a handle within the same process if you
- 15:55Speaker 2: need another handle to the same objects, maybe with different
- 15:58Speaker 2: access rights.
- 15:59Speaker 1: Okay. The book then briefly mentions user objects Windows menus
- 16:03Speaker 1: and GDI objects bitmaps, fonts. They're handled a bit differently.
- 16:07Speaker 2: Yeah. User objects like Windows don't use reference counting in
- 16:11Speaker 2: the same way kernel objects do. The first process to
- 16:14Speaker 2: destroy one affects everyone sharing it and their handles their
- 16:18Speaker 2: scope to something called a Windows station, which also manages
- 16:21Speaker 2: things like the clipboard for applications on.
- 16:23Speaker 1: The same desktop, and GDI objects.
- 16:25Speaker 2: Managed by the GDI subsystem, a separate part of Windows.
- 16:27Speaker 1: This is giving us a really solid grounding. Now the
- 16:29Speaker 1: book starts talking about different types of processes. Protective processes
- 16:33Speaker 1: light PPL sounds like a security thing.
- 16:35Speaker 2: It is introduced in Windows eight point one. PPL provides
- 16:40Speaker 2: enhanced protection, making these processes much harder to tamper with
- 16:44Speaker 2: or terminate, even for administrators like antivirus software. That's a
- 16:48Speaker 2: key example. Yes, anti malware services often run as PPLs
- 16:52Speaker 2: to protect themselves from malicious software trying to shut them down.
- 16:55Speaker 2: There are different protection levels within PPL.
- 16:57Speaker 1: Then there are minimal processes Windows ten features. These sound
- 17:00Speaker 1: really stripped down.
- 17:01Speaker 2: They are. They start with a completely empty address space,
- 17:04Speaker 2: no executable no DLLs initially mapped, super lightweight.
- 17:08Speaker 1: What uses them?
- 17:09Speaker 2: The registry process is one example. Another key one is
- 17:11Speaker 2: the memory compression process, which works behind the scenes to
- 17:14Speaker 2: optimize RAM usage.
- 17:16Speaker 1: Memory compression I might not see that in task manager.
- 17:19Speaker 2: Sometimes it is hidden or aggregated, but Process Explorer will
- 17:22Speaker 2: definitely show it. These minimal processes are typically created directly
- 17:26Speaker 2: by the kernel itself.
- 17:27Speaker 1: Fascinating how processes are evolving. The book also clarifies that
- 17:31Speaker 1: PIDs are just special handle values internally, and it covers
- 17:34Speaker 1: the statuses running suspended and not responding. Not responding is
- 17:39Speaker 1: just for GUI apps, right correct.
- 17:42Speaker 2: It happens when the main UI thread gets stuck and
- 17:45Speaker 2: doesn't process window messages for about five seconds or more.
- 17:49Speaker 2: Command line apps never show not responding, okay.
- 17:53Speaker 1: The book then mentions PE files portable executable, the format
- 17:57Speaker 1: for dot exe and dot dll files, and how they
- 17:59Speaker 1: list their dependencies the other DLLs they.
- 18:01Speaker 2: Need right in the import table. And when you launch
- 18:04Speaker 2: a program, the Windows loader has a specific search path
- 18:07Speaker 2: that follows to find those needed DLLs.
- 18:10Speaker 1: What's the order it checks known.
- 18:12Speaker 2: DLLs first, special system ones, then the application's own directory,
- 18:16Speaker 2: then the current directory, then the main system directory System
- 18:19Speaker 2: thirty two or siswas sixty four, and finally all the
- 18:22Speaker 2: directories in the system's path.
- 18:24Speaker 1: Environment variable and if it can't find one, you get.
- 18:27Speaker 2: That dreaded air message box and the process usually fails
- 18:29Speaker 2: to start. Dependency loading is critical.
- 18:32Speaker 1: Then we get to actually starting processes create process. Wow.
- 18:35Speaker 1: Look at all those parameters.
- 18:36Speaker 2: It's like the master control panel for launching applications. You
- 18:39Speaker 2: specify the command line security settings, whether handles are inherited,
- 18:43Speaker 2: creation flags.
- 18:44Speaker 1: Creation flags like creating new console or create suspended exactly.
- 18:48Speaker 2: Also the environment variables, the starting directory, the startup INNEFO
- 18:51Speaker 2: structure which controls the window appearance, and you get back
- 18:53Speaker 2: the handles and IDs in the process information structure. Huge
- 18:57Speaker 2: amount of control.
- 18:57Speaker 1: And process priority classes affecting thread priorities.
- 19:01Speaker 2: Yes, ranging from idle up to real time. Most apps
- 19:05Speaker 2: run at normal setting. Real time usually needs admin rights
- 19:08Speaker 2: because it can really impact system responsiveness if misused.
- 19:12Speaker 1: That startup infos structure too, controls window size position, whether
- 19:16Speaker 1: it's shown, minimize, maximized, even redirecting standard input out pewter.
- 19:22Speaker 2: It's how a parent process shapes the initial state of
- 19:24Speaker 2: its child. The book also gives a nod to a
- 19:27Speaker 2: useful visual studio extension for debugging child processes and reminds
- 19:31Speaker 2: us again you can't just launch UWP apps like normal executables.
- 19:34Speaker 1: Right, They need that special activation mechanism, which brings us
- 19:38Speaker 1: back to PPL again briefly.
- 19:39Speaker 2: Just reinforcing that they have different signer levels, restricting access
- 19:42Speaker 2: even preventing termination by admins. You can see the protection
- 19:46Speaker 2: level and process explorer. The book shows. Trying to launch
- 19:49Speaker 2: calculator fails if you just copy its command line.
- 19:51Speaker 1: Because it's a UWP app needs the proper.
- 19:54Speaker 2: Launch exactly, which involves using those Windows run Time win
- 19:58Speaker 2: rt API. As we mentioned, the I Application Activation Manager
- 20:01Speaker 2: interface is key. Using methods like activate application, you often
- 20:05Speaker 2: need the app's full package name.
- 20:07Speaker 1: Okay. Then a quick mention of minimal and PICO processes. Again,
- 20:11Speaker 1: minimal are kernel created. PICO processes are for things like
- 20:14Speaker 1: the Windows subsystem for Linux WSL translating Linux calls.
- 20:18Speaker 2: Right, but not the main focus here?
- 20:20Speaker 1: Then, how processes end three ways? All threads exit exit
- 20:24Speaker 1: processes call or termain it process from outside.
- 20:26Speaker 2: Pretty much even when your main function returns. In CC
- 20:29Speaker 2: plus plus two, the runtime library calls exit process from
- 20:33Speaker 2: the kernel's view the process ends when its last thread terminates.
- 20:36Speaker 1: And getting info about a running process, get exit code process,
- 20:40Speaker 1: get process times for CPU usage.
- 20:42Speaker 2: Query full process image name. To get the executable path,
- 20:45Speaker 2: you need to allocate a buffer for that one.
- 20:47Speaker 1: And listing all processes. The tool help thirty two snapshot functions.
- 20:51Speaker 2: Create tool help thirty two snapshot process thirty two first,
- 20:54Speaker 2: process thirty two next. That gives you the basics like
- 20:56Speaker 2: PID in name for everything running.
- 20:58Speaker 1: But to do more like terminate or get detailed info,
- 21:02Speaker 1: you need open process first.
- 21:04Speaker 2: Yes, and you need to request the right access permissions.
- 21:07Speaker 2: It might fail for protected system processes. Air five is
- 21:10Speaker 2: access denied. AIR eighty seven often means invalid parameter. Maybe
- 21:14Speaker 2: the PID doesn't exist anymore.
- 21:16Speaker 1: Debug privilege helps.
- 21:18Speaker 2: Sometimes yes, it lets you open more processes running elevated
- 21:22Speaker 2: and visual Studio often grants it implicitly. For even more detail,
- 21:26Speaker 2: there's WTS enumerate process X.
- 21:28Speaker 1: What does that give you things like.
- 21:30Speaker 2: The username, session id, detailed CPU times, handle counts, threadcounts,
- 21:35Speaker 2: or rich review.
- 21:36Speaker 1: Okay, that's a lot on processes. Let's talk about jobs,
- 21:38Speaker 1: grouping processes exactly.
- 21:40Speaker 2: Job objects let you manage a set of processes as
- 21:42Speaker 2: a single unit Process Explorer actually shows if a process
- 21:45Speaker 2: is in a job, how do you use them? Create
- 21:47Speaker 2: one with the separate job object, then add processes to
- 21:50Speaker 2: it using assigned process to job object. You can even
- 21:52Speaker 2: have hierarchies of jobs.
- 21:54Speaker 1: But the real power is restrictions.
- 21:55Speaker 2: Definitely. Using set information job object, you can set limits
- 21:59Speaker 2: on the entire group of processes in the job, things
- 22:02Speaker 2: like total CPU time, total memory commitment.
- 22:04Speaker 1: You can limit UI interactions too, like blocking clipboard access.
- 22:08Speaker 2: Yes, there are UI restrictions you can apply the book
- 22:11Speaker 2: mentions a sample app job monitor that lets you play
- 22:15Speaker 2: with this, like limiting notepad CPU or blocking certain actions.
- 22:19Speaker 1: CPU rate control is newer Windows eight plus.
- 22:22Speaker 2: Reret Right, let's you set a hard percentage limit on
- 22:25Speaker 2: the CPU usage for all processes in the job combined.
- 22:29Speaker 2: Very useful for resource management and sandboxing.
- 22:31Speaker 1: Okay, super useful concept. Now let's dive into threads. We
- 22:35Speaker 1: said these are the actual workers inside a process.
- 22:38Speaker 2: Yes, the independent paths of execution. They allow a single
- 22:41Speaker 2: process to do multiple things concurrently, potentially using multiple CPU cores.
- 22:46Speaker 1: You create them with create thread. Need to give it
- 22:48Speaker 1: a starting function, right.
- 22:49Speaker 2: The threads entry point function plus an optional parameter to
- 22:52Speaker 2: pass to it, stack size settings, creation flags like create
- 22:55Speaker 2: suspended if you don't want to run immediately and you
- 22:57Speaker 2: get back a handle and a thread ID.
- 22:59Speaker 1: Tids are unique system wide like PIDs.
- 23:03Speaker 2: Yes. The book also mentions HyperThreading as MT, where one
- 23:07Speaker 2: physical core looks like multiple logical processors to the OS.
- 23:10Speaker 1: Can boost performance, but potential cache issues can be.
- 23:14Speaker 2: Yeah, threads on the same physical core might compete for cash.
- 23:17Speaker 2: You see logical processors and task manager usually can disable
- 23:20Speaker 2: SMT in the bios if needed.
- 23:22Speaker 1: Now, terminating threads termat thread sounds.
- 23:25Speaker 2: Bad, very bad. Generally it's abrupt. Kills the thread instantly
- 23:29Speaker 2: without cleanup can lead to resource leaks, deadlocks, corrupted data.
- 23:33Speaker 2: Much better to signal the thread to exit gracefully itself. Okay.
- 23:36Speaker 1: Threads have stacks for local variables and handles like processes.
- 23:41Speaker 1: You get one from create thread or open thread right.
- 23:44Speaker 2: Open thread is like open process needs a TID in permissions. Interestingly,
- 23:48Speaker 2: threads don't have a built in name property in the kernel.
- 23:50Speaker 1: But there's a trick for debugging.
- 23:52Speaker 2: Yeah. Using structured exceptions to set a pseudoname helps identify
- 23:55Speaker 2: threads in the debugger, and.
- 23:57Speaker 1: Choosing between c plus plus plus standard library threats and
- 24:00Speaker 1: the Windows API.
- 24:01Speaker 2: Standard librarystd dot thread et cetera. Is cross platform, which
- 24:05Speaker 2: is great, but the Windows API Create thread gives you
- 24:08Speaker 2: much finer control over things like priority, affinity, stack size,
- 24:13Speaker 2: which leads us to scheduling.
- 24:14Speaker 1: Right, How does Windows decide which thread runs when the
- 24:17Speaker 1: scheduler and.
- 24:18Speaker 2: The key thing. Most threads are usually waiting, waiting for IO,
- 24:22Speaker 2: waiting for a lock, et cetera. The scheduler focuses on
- 24:25Speaker 2: threads in the ready state. It's priority based.
- 24:27Speaker 1: Higher priority runs first. Windows has levels from real time
- 24:31Speaker 1: down to idle.
- 24:32Speaker 2: Correct. A thread's actual priority comes from its processes priority
- 24:36Speaker 2: class plus its own relative priority within that.
- 24:39Speaker 1: Process and the quantum the time slice.
- 24:42Speaker 2: Yeah, how long a thread gets to run before the
- 24:43Speaker 2: scheduler might switch. Yeah, It can vary client versus server
- 24:46Speaker 2: tuning and the four ground apps. Threads often get longer quantums.
- 24:51Speaker 2: Quantum stretching for responsiveness.
- 24:53Speaker 1: Can be tweaked in the registry WIN thirty two priority separation.
- 24:57Speaker 2: It can. Yeah. You can also control which ars a
- 25:00Speaker 2: thread runs on process or affinity set thread affinity mask
- 25:03Speaker 2: is the basic way set thread group affinity for systems
- 25:05Speaker 2: with sixty four.
- 25:06Speaker 1: Processors and CPU sets a newer way to group processor Yes.
- 25:10Speaker 2: Windows ten introduce them more abstract way to manage affinity
- 25:13Speaker 2: using functions like set thread.
- 25:15Speaker 1: THEEP sets now priority boosts. This sounds important for keeping
- 25:18Speaker 1: things smooth.
- 25:19Speaker 2: Very the system temporarily boosts a threads priority after certain
- 25:23Speaker 2: events like IO completing or a window needing. Attention prevents
- 25:28Speaker 2: the UI freezing.
- 25:29Speaker 1: It decays back down afterwards.
- 25:31Speaker 2: Yes, after the thread runs for a bit four ground
- 25:33Speaker 2: threads get a bigger boost when they wake up from
- 25:35Speaker 2: a weight. It's all about perceived responsiveness.
- 25:38Speaker 1: Suspending and resuming threads. Suspend thread, ReSm thread Still a
- 25:42Speaker 1: bad idea.
- 25:43Speaker 2: Generally, Yes, very easy to cause deadlocks. Better to use
- 25:47Speaker 2: proper signaling. There are also ways for threads to yield voluntarily.
- 25:51Speaker 2: Sleep baze gives up the rest of its time slice
- 25:54Speaker 2: to another ready thread of the same priority.
- 25:56Speaker 1: Switch to thread yields more aggestively yes to any.
- 25:59Speaker 2: Other ready thread, and sleep infinite just waits forever until
- 26:03Speaker 2: woken up.
- 26:04Speaker 1: It's amazing how much orchestration is going on. Okay, synchronization
- 26:07Speaker 1: within a process. Why do we need it?
- 26:09Speaker 2: Because if multiple threads in the same process access shared
- 26:12Speaker 2: data without coordination, chaos, race conditions, corrupted data, weird bugs.
- 26:17Speaker 1: The simple counter example shows this clearly.
- 26:19Speaker 2: Yeah, the final count is unpredictable for simple increments decrements,
- 26:23Speaker 2: there are interlock operations.
- 26:25Speaker 1: Like interlocked increment. These are atomic, yes.
- 26:28Speaker 2: Hardware guaranteed atomic. The whole read, modify write happens as
- 26:32Speaker 2: one indivisible step, save for simple updates.
- 26:35Speaker 1: For more complex stuff, protecting blocks of code.
- 26:38Speaker 2: Critical sections of the workhorse for that, within a process
- 26:41Speaker 2: initialized critical section X, enter critical section to lock it,
- 26:45Speaker 2: leave critical section to unlock. Only one thread can be
- 26:48Speaker 2: inside the critical section at a time, and delete critical
- 26:52Speaker 2: section when done.
- 26:52Speaker 1: Mutual exclusion. The hashcatch example uses one to protect.
- 26:55Speaker 2: A map exactly std dot unordered map isn't thread safe,
- 26:59Speaker 2: so the critic section ensures safe access from multiple threads.
- 27:03Speaker 2: The book also mentions ETW event tracing.
- 27:06Speaker 1: For Windows for diagnostics.
- 27:07Speaker 2: Yeah, powerful kernel level tracing can see image loads, context switches,
- 27:11Speaker 2: tons of stuff, useful for deep analysis.
- 27:13Speaker 1: Okay, what about SRW locks slim reader.
- 27:17Speaker 2: Writer These are often more efficient if you have lots
- 27:19Speaker 2: of threads reading share data but only occasional rights. They
- 27:22Speaker 2: allow multiple readers or one writer acquires RW lock shared
- 27:26Speaker 2: acquires our wots exclusive, et cetera.
- 27:28Speaker 1: Got it and condition variables used.
- 27:30Speaker 2: With a lock always with a critical section or an
- 27:33Speaker 2: SRW lock. They let threads wait efficiently for some condition
- 27:38Speaker 2: to become true. You call sleep condition variable CS or
- 27:42Speaker 2: sleep condition variable SRW.
- 27:44Speaker 1: This atomically releases the lock while waiting yes.
- 27:47Speaker 2: And reacquires it upon waking. Other threads use weight condition
- 27:51Speaker 2: variable or wake all condition variable to signal crucially, you
- 27:54Speaker 2: must recheck the condition in a loop after waking because
- 27:57Speaker 2: of spurious wakeups.
- 27:58Speaker 1: Spurious wakeups, they can and wake up even if the
- 28:00Speaker 1: condition isn't met sometimes.
- 28:02Speaker 2: Yes, so you always loop while sleep condition variable. The
- 28:06Speaker 2: producer consumer example demonstrates this pattern well with a shared
- 28:10Speaker 2: queue right.
- 28:11Speaker 3: Newer primitives, too, wait and address very efficient way to
- 28:14Speaker 3: wait for a specific memory location to change value, often
- 28:17Speaker 3: without needing a separate lock and synchronization barriers like a
- 28:20Speaker 3: Runov point exactly enter synchronization barrier. Threads wait there until
- 28:24Speaker 3: a specified number of threads arrive. Then they all proceed
- 28:27Speaker 3: together and C.
- 28:28Speaker 1: Plus plus standard library has its own versions std dot
- 28:31Speaker 1: mutex std dot condition variable Yes.
- 28:35Speaker 2: Good for cross platform code, but often less control or
- 28:38Speaker 2: potentially different performance characteristics than the native Windows APIs. Finally,
- 28:43Speaker 2: the basic weight functions wait for single object, wait for multiple.
- 28:47Speaker 1: Objects, need the synchronize right for the object.
- 28:50Speaker 2: Handle yes, and you specify a timeout. They tell you
- 28:53Speaker 2: if the objects signaled, if you kimbed out, or if
- 28:56Speaker 2: there was an error.
- 28:57Speaker 1: Okay, that covers coordinating threads inside one process. What about
- 29:01Speaker 1: between different processes?
- 29:02Speaker 2: For that, you need kernel objects with system wide visibility,
- 29:05Speaker 2: usually achieved using named.
- 29:07Speaker 1: Objects like a named mutex.
- 29:09Speaker 2: Exactly create it with create viewtex and give it a name,
- 29:13Speaker 2: maybe global prefix for system wide. Another process can use
- 29:17Speaker 2: open mutex with the same name to get a handle
- 29:19Speaker 2: to the same mutex. Then they use weight for single
- 29:22Speaker 2: object and release mutechs to coordinate.
- 29:24Speaker 1: Process Explorer can show these named mutexes.
- 29:26Speaker 2: Yep and whether they're currently held. Semaphors work similarly.
- 29:30Speaker 1: Somemophors control access to a limited number of resources.
- 29:33Speaker 2: Right create with create semaphore, give it an initial max
- 29:36Speaker 2: account and a name. Wait for single object, tries to
- 29:40Speaker 2: decrement the count, release semaphor increments it. Good for managing
- 29:44Speaker 2: pools of resources across processes.
- 29:46Speaker 1: Weaightable timers can also be named yes.
- 29:48Speaker 2: Create weightable timer with a name, set weightable timer to
- 29:52Speaker 2: schedule it once or periodically. Other processes can open weightable
- 29:56Speaker 2: timer and wait for single object. Can even trigger APCs
- 29:59Speaker 2: and events.
- 30:01Speaker 1: Named events also possible.
- 30:02Speaker 2: Create event with a name, manual or auto reset, open
- 30:05Speaker 2: event by name, use set event, reset event, wait for
- 30:08Speaker 2: single object. Simple signaling between processes.
- 30:11Speaker 1: Interprocess APCs are less common.
- 30:14Speaker 2: Much less common and trickier named objects the usual way.
- 30:17Speaker 2: The book also mentions weight for impuddle.
- 30:19Speaker 1: Waits for a GUI app to be ready.
- 30:21Speaker 2: Yeah waits until it's finished initializing and is waiting for input.
- 30:24Speaker 2: Useful after create process and signal object and weight atomically
- 30:28Speaker 2: signals one object and weights on another, avoiding certain race conditions.
- 30:32Speaker 1: Lots of tools for interprocess coordination. Let's move to thread pools,
- 30:35Speaker 1: a managed way to handle threads.
- 30:37Speaker 2: Yeah, Windows provides a sophisticated threadpool big advantages, reuses threads,
- 30:42Speaker 2: less overhead, manages resources, better limits concurrency automatically.
- 30:46Speaker 1: What do you use it? Simplest way?
- 30:48Speaker 2: Try submit threadpool callback, give it a function to run,
- 30:51Speaker 2: and the pool schedules it on one of its worker
- 30:53Speaker 2: threads eventually.
- 30:54Speaker 1: That it can do more weight callbacks yes.
- 30:57Speaker 2: Instead of blocking your own thread waiting for an object,
- 31:00Speaker 2: tell the thread pool to weight, create threadpool weight, set
- 31:04Speaker 2: thread pool weight. When the object signals, the pool runs
- 31:07Speaker 2: your callback function. Much more efficient. Timer callbacks too, yep,
- 31:11Speaker 2: create threadpool timer, set thread pool timer schedule callbacks ceriodically
- 31:15Speaker 2: or one shot handled by the.
- 31:16Speaker 1: Pool and io callbacks rising operations.
- 31:19Speaker 2: Right to create thread poolio start thread Polio integrates acinc
- 31:22Speaker 2: iiocompletion with the threadpool.
- 31:24Speaker 1: Can you create your own private pools?
- 31:25Speaker 2: You can create threadpool allows customization minmax threads, stack sizes,
- 31:32Speaker 2: set threadpool thread maximum, et cetera. Need to close thread
- 31:35Speaker 2: pool when done.
- 31:36Speaker 1: Callback environments, cleanup groups.
- 31:38Speaker 2: More advanced features environments, TP callback environ let you set priority, affinity, etc.
- 31:44Speaker 2: For callbacks. Clean up groups help manage the lifetime of
- 31:47Speaker 2: related pool objects. Together.
- 31:49Speaker 1: Thread pools seem very powerful, okay. Advance threading topics. Thread
- 31:54Speaker 1: local storage TLS.
- 31:55Speaker 2: G LS gives each thread its own private coffee of
- 31:58Speaker 2: some data. Use to get an index, then tlset value,
- 32:02Speaker 2: TELS get value, operate on the calling threads specific slot
- 32:05Speaker 2: for that index. No sink needed because it's thread private.
- 32:08Speaker 2: TLS free releases the index.
- 32:09Speaker 1: C plus plus s thread local two Yes t lous.
- 32:12Speaker 2: Pec thread older and thread locals entered. C plus plus
- 32:15Speaker 2: provide language level support for static TLS variables.
- 32:18Speaker 1: How do list threads again, tool help thirty two YEP.
- 32:20Speaker 2: Create tool help thirty two snapshot with th h three
- 32:22Speaker 2: two CSS snap thread then thread thirty two first next
- 32:26Speaker 2: gives TIDPID priority, CPU times.
- 32:28Speaker 1: Cash awareness, False.
- 32:30Speaker 2: Sharing important performance consideration. False sharing is when threads modified
- 32:34Speaker 2: different variables that happen to be in the same CPU
- 32:36Speaker 2: cache line, causing unnecessary cash and validations. Padding data structures
- 32:40Speaker 2: can help avoid it.
- 32:40Speaker 1: Weight change reversal WCT for.
- 32:43Speaker 2: Dead's locks yes an API open thread weightchain, session get
- 32:47Speaker 2: thread weight chain to analyze what locks and objects threads
- 32:50Speaker 2: are waiting on. Can help diagnose deadlocks by showing circular weights.
- 32:53Speaker 1: And the concurrency run time. High level C plus plus library.
- 32:57Speaker 2: For Microsoft Ya provides tasks parallel loops agents simplifies many
- 33:02Speaker 2: common parallel programming patterns.
- 33:04Speaker 1: Okay, nearly there. File and device io Create file and
- 33:07Speaker 1: create file two are key absolutely fundamental for opening creating files, devices, pipes,
- 33:12Speaker 1: tons of parameters, path access rights, read write, share mode
- 33:17Speaker 1: creation disposition like creating new open existing flags and attributes.
- 33:21Speaker 2: File flag overlapped is crucial for ACNC io.
- 33:23Speaker 1: Yes, and paths can include for devices or things like
- 33:26Speaker 1: symbolic links. Drive letters themselves are often similark.
- 33:29Speaker 2: Getting file info size.
- 33:31Speaker 1: Attributes, get file size x sixty four bit size, get
- 33:33Speaker 1: file attributesx, get file information by handle for more details,
- 33:37Speaker 1: set file information by handle. Can even modify some things reading.
- 33:40Speaker 2: And writing read file, write file, sync or async both.
- 33:44Speaker 2: ACNC requires the file flag overlapped flag during create file
- 33:48Speaker 2: and using an overlap structure. APCs are one way to
- 33:51Speaker 2: handle ACNC completion, but iocompletion ports IOCP are more scalable.
- 33:57Speaker 1: IOCP involves create iocompletion port associating hands than worker threads,
- 34:01Speaker 1: calling get cubed completion status.
- 34:03Speaker 2: Exactly highly efficient for servers handling many concurrent acinc io operations.
- 34:08Speaker 2: Threadpool io create thread poolio is a simpler wrapper around
- 34:11Speaker 2: similar concepts.
- 34:12Speaker 1: Canceling IO, conciliox yes, cancilo.
- 34:15Speaker 2: X for ACNC cancel synchronusio exist but isn't guaranteed to work.
- 34:19Speaker 1: Device io uses create file with device paths like physical
- 34:23Speaker 1: drive YEP.
- 34:24Speaker 2: Then device iiO control since commands directly to the driver
- 34:26Speaker 2: using control codes.
- 34:28Speaker 1: Finding devices, the set up DAPI right.
- 34:30Speaker 2: Set of digit class, DEEVS setup dynam device info. Setup
- 34:34Speaker 2: DIET Device interface detail lets you find devices by type
- 34:37Speaker 2: and get their paths.
- 34:38Speaker 1: Interprocess communication again pipes anonymous and named.
- 34:41Speaker 2: Create pipe for simple parent child anonymous pipes, create name
- 34:44Speaker 2: pipe for more powerful. Name pipes can be duplex workover network.
- 34:47Speaker 2: Clients connect using create.
- 34:48Speaker 1: File mail slots one way.
- 34:50Speaker 2: Yes, connectionless, create mail slot for server, Create fil rite
- 34:54Speaker 2: file for client Yeah less common now also file finding
- 34:58Speaker 2: find first file etcter and system info.
- 35:00Speaker 1: Get system info okay, last major topic. Memory management fundamentals
- 35:05Speaker 1: Virtual memory.
- 35:06Speaker 2: The big abstraction. Each process gets its own private address
- 35:09Speaker 2: s base managed by the virtual memory and manager. VMM
- 35:12Speaker 2: uses paging to swap memory between RAM and the disc
- 35:15Speaker 2: page file.
- 35:16Speaker 1: Memory states free, reserved, committed, free is unused.
- 35:20Speaker 2: Reserved allocates address range but no storage. Committed allocates storage
- 35:24Speaker 2: RAM or page file commit, charge and task Manager is
- 35:26Speaker 2: the system wide total committed.
- 35:28Speaker 1: Memory for a process commits size, private bytes is key,
- 35:31Speaker 1: working set is RAM usage generally.
- 35:33Speaker 2: Yes, virtual size includes reserved, working set is physical. RAM.
- 35:37Speaker 2: Process Explorer shows these well.
- 35:38Speaker 1: Process memory map shows layout code, DLL stack keep, Get
- 35:42Speaker 1: process memory info, gives detailed stats.
- 35:45Speaker 2: Page faults working set size, pool usage, page file usage,
- 35:48Speaker 2: and page protection. Read write execute is critical set by
- 35:51Speaker 2: virtual ALC, change by virtual protect access violation if you break.
- 35:54Speaker 1: The rules virtual virtual query X lets you walk the
- 35:58Speaker 1: address space.
- 35:59Speaker 2: Yes, gives in memory based information about regions, base size,
- 36:04Speaker 2: state protection type. Let's you see the map programmatically.
- 36:08Speaker 1: And finally, WAWW sixty four for running thirty two bit
- 36:11Speaker 1: apps on sixty four bit Windows file system redirection system
- 36:15Speaker 1: thirty two versus siswell sixty four.
- 36:17Speaker 2: Exactly the emulation layer that makes it mostly seamless. Wow
- 36:20Speaker 2: sixty four disabled whole sixty four f's redirection can turn
- 36:24Speaker 2: off the file redirection temporarily if needed.
- 36:26Speaker 1: Wow. Okay, that was genuinely a deep dive. We covered
- 36:30Speaker 1: so much ground.
- 36:30Speaker 2: We really did, from processes as containers, threads as the workers,
- 36:34Speaker 2: through handles, synchronization nightmares huh.
- 36:37Speaker 1: And io memory basics.
- 36:39Speaker 2: It's a lot, it is. You know, one thing that
- 36:40Speaker 2: always strikes me is that PID thing just being a
- 36:42Speaker 2: handle value and those minimal processes completely empty to start with.
- 36:47Speaker 2: That's pretty wild.
- 36:47Speaker 1: Yeah. And the whole dance of threads scheduling the boosts.
- 36:50Speaker 1: It really helps understand why things feel responsive for sometimes
- 36:52Speaker 1: why they don't and for you listening, even if you're
- 36:55Speaker 1: not writing this kind of low level code. I think
- 36:58Speaker 1: understanding these concepts gives you a much better feel for
- 37:00Speaker 1: what your computer is actually doing under the hood.
- 37:03Speaker 2: It definitely demystifies some of it takes away the magic feeling.
- 37:06Speaker 1: So thinking about all this complexity. It's what makes Windows powerful, right,
- 37:12Speaker 1: but it also feels like there are so many moving parts.
- 37:15Speaker 2: Absolutely, it's this incredible layering of abstractions and mechanisms built
- 37:19Speaker 2: up over decades. It enables amazing things. But yeah, complexity
- 37:23Speaker 2: can also mean fragility.
- 37:25Speaker 1: Sometimes it makes you wonder how does this foundation contribute
- 37:28Speaker 1: to both stability and the occasional crash, And what other
- 37:32Speaker 1: deep system areas might be interesting to explore next time,
- 37:35Speaker 1: maybe digging into how memory actually gets allocated or how
- 37:38Speaker 1: drivers work.
- 37:39Speaker 2: Definitely food for thought, something to mull over until our
- 37:42Speaker 2: next deep dive. Thanks for joining us.