 Okay, this is, again, a series, this is part six, I believe, of a series. Be sure to check out the annotation on the screen for the full playlist, and you'll want to watch the previous videos before watching this one. But before the last few videos, we've been modifying the PR boom, which is a version of Doom. We've been modifying the source code and compiling it, making the game have new functionality. Today, we're actually going to start editing the binary file. Now, this is something you don't have to do with Doom anymore, because it's open source. You can get the source code. There's a few different versions out there, and modify it and make your changes. But if it wasn't open source, if the source code was not available, if you wanted to make modifications to the game, to the actual functionality of the game, not just, you know, the graphics, which there were Watt editors, you would have to add the binary. Back in the day, there was a program called, Hex Do, what was it called? Do Hex Something? And it will allow you to modify certain things like the speed of a character, the damage, its health. It was a great little tool. And what it was, it was manually editing the binary file, which it was, actually, I should say manually, it was doing it for you, so you didn't have to manually edit the binary file. So today, we're going to be looking at, it's doing something very basic, changing some messages in the game by editing the source code. So first thing I'm going to do is I'm going to start Doom up. There we go. So in here, sorry, the game, I can say IDKFA, which is a cheat code. And up at the top, it says, very happy ammo added. That was the message. So again, IDKFA, that's the message for that cheat code. And if you watch previous videos, almost all the messages in the game are set in a file, they're predefined. But luckily, lots of times when binary files are compiled, the strings maintain their stringiness. So we can actually go into HexEdit and very easily find the strings we're looking for and edit them. I've done this in a previous tutorial. If you have a program that has menus and stuff, you can edit the menus in many cases. So, all depending on how it's compiled, though. But what we're going to do here is we're going to use a program called HexEdit that should be in your repositories for your distro. So if you're on a Debian-based distro, you can use, such as Debian or Linux Mint, you can use apt-get and install HexEdit. And we want to point it at our file, which is PRBoom. It's inside our source folder here. PRBoom plus in this case. There we go. Okay, so up on the left-hand column is the Hex value of the position that you're at. So you can see line one, we start at 0, 0, 0, 0, 0. Line two says 18. That's because that's how far down there's, depending on how you're displaying it, that number will change. That's just where line two starts is at that position. And then you have your hex code. And then the third column is kind of an ASCII output of that hex code. So what I'm going to do is I'm going to hit Tab. And if you're not too familiar with binary, I'm going to talk a little bit more about the actual binary code, the center column, next week. I hit Tab to come over to this ASCII section. And ASCII is just the plain text. So what we want to find is where it said happy ammo load. So I'm going to type, I'm going to say forward slash to search. And I'm going to say ammo. And ammo number, ammo per. So you can start going through here until you find where it says very happy ammo load. But I can tell you right now you're not going to find it like this. Why? Oh, because your search is case sensitive. I'm just scrolling back up to the top right now. I don't know the command in this particular program to jump back up to the top of the file. Anyway, as an example, I can say forward slash, oh, maybe it's ammo like that. And you can start searching like that. And there's some words analog with it, but none of them say happy ammo load. OK. So how can I search through this and find the string I'm looking for? I'm sure there's a way to search case in sensitive in this program. But the way I normally search for strings, a quick and easy way is to use a program called strings and another program called grep. I've mentioned strings before. If you have a binary file that you're curious about, the first thing I do is I run strings on it. So strings, the name of our binary file. Now hit enter and it brings up all ASCII characters from that file. So now I can use grep and I can grep for ammo. Great. Lots of ammo in there. Yellow ammo bars, blah, blah, blah. But we want to be case in sensitive. So what I'm going to do is I'm going to add case in sensitive, boom. And now I can even grep for dash I happy, which is actually probably a better thing to search for because how many times is the word happy in the video game Doom? So I hit that and you can see, oh, they did write it very happy. Now you might think go into the game, see how it's written there, but as I've mentioned in previous tutorials in the game, everything is displayed as capital letters. So now I can say I can search for very happy ammo just like that. So I'm going to start up my hex editor again, hit tab to go over to our ASCII, forward slash to search, and I'm just going to center click to paste that in there or you can type it out, hit enter, and here we are, very happy ammo added. So important thing to note when you were editing things like this in a hex editor, the code is very specific on where stuff is. You can't change the lengths of stuff like this without screwing stuff up. At least not how I do it or know how to do it. So I can change this message. I can change it to very, oops, cool ammo added. And you notice that there's still that D at the end there. I can just space over that. That's fine. Not going to notice a space in the game. I can hit control X and Y to save that. So I exit and save. Now I can run the game again. And now, I'm going to go in here and I type in IDKFA. It says very cool ammo added rather than very happy ammo added. Now, as I was saying, you need to keep it at that length. So you can do stuff shorter but you can't really do stuff longer. If you know how, let me know. Because it all has to do with pointers and C code, things point. This is at this spot. Go there and then it does that until it finds the end of that. I don't know what's called. I'll say Exocoda. But basically, if I come over here and I say cool to find out where we were. So here, very cool ammo added. You notice there's a dot right here where my cursor is. It looks like a period, but it's not. That's indicating the end of that string. So when you type in that code, that the cheat code, the DOOM binary goes, okay, look in memory and go to this point. It goes right to where my cursor is right now. The very beginning there and display that until you hit the end of that. And this dot right here is where that ends. Now if I hit tab, you see it brings me back over to right here the hex code. So I can tab back and forth and you see it says 00. So 00 is the code for that. If I put a period right there and tab over, you'll notice that it's 2E. See, 2E. So a period and that end of the string are two different things. They may look the same over in the ASCII because it's just being displayed as a period. It is not really a period. It is a 00. It's like a null character. So if I tried to make this longer and I was just to wipe out that dot, as you can see now over here, it's showing up as a 20 in the hex code. The code, the program is now going to go, okay, when you display this message, start here and go all the way to here. So it's going to display that second message too, which is obviously not what you want and not too bad in this case. So if I hit control X and Y to save and then I run the game and I go into the game and I type in IDKFA, you can see it just starts displaying the next message and it actually even gets cut off because it's too long for it to be displayed here. So again IDKFA, it says very cool ammo added and then it starts displaying another message, which is for when you turn off God mode. So if I say IDDQD, turning it on, IDDQD, turning it off, it doesn't affect that message because when I type in that other cheat code, and let me go over here, it doesn't care that that null character isn't before there because the code says go straight to this point in memory and display everything to this dot. So although we didn't want that message to display, we didn't really screw up the game, but that's because we're just working with strings here. If you remove the null character for something outside of these strings, the game will probably crash or could cause some sort of security risk theoretically, especially if you're playing a network game. So you want to be conscious of that. So if I accidentally deleted that, such as I did, how do I put that back? I can't just put a period there because it will display a period in the game there. What I'll have to do is hit Tab, and I'll say 00. And now that character is a 00. If I hit Ctrl-X, Y to save, run the game again. Notice that we don't have to recompile because we're directly editing the binary file, IDKFA, and we're back to our very cool animal added. So that is editing strings here in Doom. And again, this should work with most binary files unless it's encoded to protect those strings, which some companies do. It can also be compressed to try to save space in which case strings may not show up. But that is how you can edit strings, and you can do that for pretty much any message in the game. So anything that's playing text or even messages that we're seeing here in the shell that are outputting, you should be able to find those strings. So like if we... I haven't tried this, but I think if we go Hex Edit, I'll come over here and I'll search for Music Player. You can see that Music Player is there. And I don't know if Music Player is anywhere else. Okay. So just real quick, I'll just change this to a D. Ctrl-X, yes. I'll run the game. And if I exit out, you can see here where that message was it now says D instead of P for Player. So yeah. Basically in this game, any string that you can edit, that's a string, you should be able to edit. Now in the actual game, I believe this new game options, load game, save game, those are actually images. Those are actual strings same once you go into here. But like if I was to go into Nightmare mode, this all is strings inside the game, so I can modify that. So if you wanted to modify this new game option load, those are actually pictures that are inside the WOD file. You can change those with a WOD Editor, which I may touch on editing WODs at the end of this series. But if you ever played with Doom, you've probably played with WOD files. That's the normal way of editing games to change picture sounds and stuff like that. So that's it. That's just changing strings. Next week, we're actually going to change the hex code in the binary to change your player's life, you know, health value, the default health value. So that's something I hope you will find interesting. We'll compare two files to figure out where the change is made and then go in there and change it. So I thank you for watching. If you enjoy these tutorials, I hope that you are. I hope you're getting them. If not, you know, learning about how to go in and edit source code and binary files, just I hope that you like the video game Doom and that you can make it do fun things now. My website, filmsbychris.com, there should be a link in the description. Be sure to visit there. Also check out the description for notes on what we did here today so you can see everything there. I thank you for watching. And as always, I hope that you have a great day. Okay, this is an introduction to filmsbychris.com. I'm Chris. That's Chris the K. That's me right there. My daughter, Amber. And my wife, Jennifer. We pretty much live in the swamps of Florida. I'm a firefighter by day as well as by night. We work long hours. But that's not why you're here. You're here about the videos I put up on YouTube. These videos are mainly about computers and programming, which means most of my videos look something like this. And if that's what you're interested in, great. If not, that's all right. I do videos on other topics too, such as video editing, special effects, photo editing, 3D design, and music creation. If you are one of my viewers and you enjoy my videos, my Patreon page is a place where you can go to help support my videos. So I ask that you take the time to go to my Patreon page and look at different levels of rewards you can receive for different levels of backing. There should be a link in the description of this video if you're watching it on YouTube. Otherwise, you can visit patreon.com forward slash metalx1000. And I thank you for your time and your support. Have a great day.