 again this part this video is part of a series of videos the first five or so we were working with the PR boom which is a version of doom its source code and modifying the game the last two videos or so we've been editing the binary file itself with a hex editor and right now we're gonna do the same thing but a little different in the first hex editing video we changed a string by going into it with hex edit and go over to the ASCII section ASCII column and modifying it you can do that from the command line I don't really see someone doing this too often this way but maybe you want to write a code that automates some changes obviously if you have a binary that's important you're going to want to you know not modify it directly so we're actually going to be dumping it into a new file and if you do want to modify the original be sure to have a backup copy because any little change could make a mistake so before we're using a program called hex edit today we're going to be using hex dump should be in your repositories if you don't already have it installed so let me just real quick here show you that I've got doom oh let me compile it make and I'm going to just to keep things simple move what we just compiled to source doing one okay so I created a binary file I compiled it renamed it and now I can run it like so and you can see it's normal now if I run over you know I can pick up stuff that says picked up armor bonus and if I pick up the health it says picked up health bonus we're gonna change both those messages with one simple command or a one liner command that piped three commands into one and if I type in hex the screen hex dump and I give it that file that we just looked at it dumps out the hex code okay lots of it controls see to kill that or just let it finish and take too long I'm just going to copy and paste this from my notes so well so we have hex dump dash ve and then inside single quotes one slash one and then inside double quotes within those single quotes percent dot 2x and then the name of our file to dump if I run that so if I run that we get this it's basically removing all the spaces and putting everything on basically one line instead of having those different columns so it's the same output just displayed different again there's a link in the description to my notes for this project up on past been go ahead check those out you know I'm not going to explain this will come in because I don't completely understand I just know what it does not exactly how it does it but it's just removing the column the spaces in the columns okay so we have that so now we want to replace part of the code the hex code with another piece of hex code okay so first off what we want to replace I'm gonna change it so instead of saying you picked up a health bonus or you picked up an ammo bonus I want to say you picked up a health item or you picked up an ammo item so in the previous video strings is a great great tool to get a quick overview of the ASCII information in a file so strings dumps out anything that is an ASCII character I'm gonna grep for the word bonus and here we have a few different places obviously these first two are what we want to modify modifying these other ones will corrupt the game we don't want to modify them so what I want to do is I want to modify just these first two and so what's different between them and the rest in this particular case is that they have a period at the end so I'm not going to just replace the word bonus I'm gonna replace the word bonus period with the word item so what do I have to do I'm gonna take that and then there's ASCII to hex converters for the shell I'm just gonna use a web based one because I have it up here I'm gonna paste my ASCII here click convert and there we go if I let's undo padding okay because we don't want any spaces I'm also not really sure if case matters there but I'm gonna change those ease to capital ease and the F's to capital F's so that is our bonus so that's what we're gonna be searching for and replacing inside our file we're gonna use said to do this said is a very great tool for editing text files from the shell I want to change it again to be the word items now or item so bonus B O N U S period that's six characters item I T E M period five characters we need them to be the same length so could say items but you're only picking up one thing so if I say convert this again I would want to change any letter to a couple uppercase just to be sure but the again this is only five characters we need six if you watch previous tour we know that space is the number 20 in hex so I'll just add 20 to the end of that so if we take that and we take our hex dump and then we put it into said and just to make sure I do this right in the tutorial and I don't screw up I'm going to actually copy and paste what we just did so now we're saying said substitute anywhere that we have this which is the hex for bonus period and we're going to say replace it with the hex for items period and then 20 just add a space at the end the G says do it globally now we're looking for the one with a period again we could set said say just look for the first two but maybe it's the third two so I'm just that's why I just use the period to find the two out so if I do that it's going to output the output with those changes well I don't want that output on my screen control C to kill that I want to dump it into a file but I can't just dump it in a file because it will just create a text file that has the hex code in it I don't want the hex code I want the actual binary executable so we're going to take all that we've created so far we're going to pipe it again take that output and put it into a program called xxd xxd we're gonna say dash R dash P again I don't even know what those arguments mean I just know that I looked this up a while ago and it works I'm going to redirect that output well let's look what that looks like yeah so it looks like if you tried to cat out a binary file control C to kill that if you ever do that and your terminal gets messed up just type reset and that will fix that so it's actually creating the binary executable and displaying to my screen I don't want displayed my screen I wanted in the file so I'm gonna say redirect that into said or sorry source folder doom and we'll call it doom to just name in the file has nothing to do with what version of doom because that depends on what wad you're using not what executable when you're working with PR boom so we did that we create the executable but if we go to run it now it's not gonna work for the simple reason that I don't have permission because it's not executable so we want to do is say change mod plus x just like if you created a script now I can do source doom to start the game and now when I pick up the little health vials or the little am or armors it should say that you picked up a health or armor item rather than bonus so let's see there we go picked up an armor item up in the top left of the screen and if I go pick up some of these blue vials picked up a health item so that is how you would change a string from the shell obviously in most cases you're gonna use something like hex edit and the file you want to edit just like we did two videos ago makes a little more sense but if for some reason you need to automate this in a script that is one way to do it and I hope you found that interesting I don't know again how useful it is I mean obviously there is a use for it just probably not very common and but at least it's something educational you hopefully you learned something new I hope you've enjoyed these doom tutorials at this point I don't know I may do one or two more on editing WAD files or this may be the end of this series but either way you'll know by clicking on the link to the playlist which will hopefully be an annotation on the screen and maybe in the description of the video again all the notes for this and the previous videos should be in the description of the video as well so click on that their pace you go to pace bin and they'll just be there and if you have questions I really don't know if I'm gonna be able to help because again this is a topic that I basically just told you everything I know on the topic so if you have a question outside of that I probably don't know but if you know more if you have suggestions definitely let me know because it's a topic that I've always been interested in since I was 15 so 20 years ago playing with hex editors but I know very minimal about it so I thank you for watching this filmsbychris.com that's Chris the K there should be a link in the description 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 ember 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 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 were 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 asked 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 were watching it on YouTube otherwise you can visit patreon.com forward slash metal x1000 and I thank you for your time and your support have a great day