Advertisement
metalx1000

Hexediting PrBoom Doom binary file to increase health

Feb 4th, 2015
1,521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.98 KB | None | 0 0
  1. #required libs:
  2. sudo aptitude install libghc-opengl-dev libghc-sdl-dev make hexedit gawk doom-wad-shareware prboom -y
  3.  
  4. #get doom source code
  5. #http://sourceforge.net/projects/prboom/files/prboom%20stable/2.5.0/
  6. wget "http://colocrossing.dl.sourceforge.net/project/prboom-plus/prboom-plus/2.5.1.3/prboom-plus-2.5.1.3.tar.gz"
  7. tar -xvf prboom-plus-2.5.1.3.tar.gz
  8. cd prboom-plus-2.5.1.3
  9. ./configure
  10. make
  11.  
  12. #move original compile
  13. mv src/prboom-plus src/doom1
  14.  
  15. #Change Player's default health and compile again
  16. vim +62 src/p_inter.c
  17. make
  18.  
  19. #move new compile
  20. mv src/prboom-plus src/doom2
  21.  
  22. #compare the two files
  23. cmp -l src/doom1 src/doom2 | gawk '{printf "%08X %02X %02X\n", $1-1, strtonum(0$2), strtonum(0$3)}'
  24.  
  25. <sample output>
  26. 0000024D F3 D2
  27. 0000024E 69 D2
  28. 0000024F EE 3E
  29. 00000250 BD 0A
  30. 00000251 7B 1D
  31. 00000252 F8 D9
  32. 00000253 C3 76
  33. 00000254 3F ED
  34. 00000255 84 23
  35. 00000256 18 0B
  36. 00000257 57 1B
  37. 00000258 FD 6D
  38. 00000259 53 A6
  39. 0000025A B0 3D
  40. 0000025B C7 4F
  41. 0000025C EE 7F
  42. 0000025D CC 3B
  43. 0000025E 63 D7
  44. 0000025F E1 39
  45. 00000260 68 5F
  46. 00121849 64 E8
  47. 0012184A 00 03
  48. </sample output>
  49.  
  50. #ignore all but last two line of output
  51. #open original binary in hexedit
  52. hexedit src/doom1
  53.  
  54. #press F4 and jump to 00121849 from above.
  55. #This position will very based on compiling.
  56. #so reference the command above.
  57. #make changes 64 to E8 and 00 to 03
  58. #F2 to save and control-c to exit
  59.  
  60. #other examples
  61. #max Ammo levels start a address 121800
  62.  
  63. #hex numbers
  64. #Hex to int
  65. perl -e "print unpack('v', pack('H*', '6400'));" #this will output 100 which is what health originally was
  66. perl -e "print unpack('v',pack('H*', 'e803'));" #This will output 1000 which is what we changed health to
  67. perl -e "print unpack('v',pack('H*', 'e802'));" #This is 744 because the second two digits move by intervals of 256
  68. perl -e "print unpack('v',pack('H*', 'e80f'));" #4072 don't forget we are going from 0 to f
  69. perl -e "print unpack('v',pack('H*', '6300'));" #99 the first two digits get us the intervals from 0 to 255
  70. perl -e "print unpack('v',pack('H*', 'ff00'));" #This is because 16*16=256 but we start at 0
  71. perl -e "print unpack('v',pack('H*', 'E703'));" #This is 999 explained more below
  72.  
  73. #The 'E' part.  
  74. # 7 is 7.  This column go to F which will be 15 - again because we start with 0  
  75. # 14*16=224  You multiply each value in this column by 16. F would be 16 but we start at 0 so F=15 and E=14
  76. # 3*256=768 Everything in this column is multiplied by 256
  77. # 0 is 0 but you would multiply everything in this column by 4096 because 256*16=4096
  78. # So add it all together 14*16+7+3*256=999
  79.  
  80. #changing strings from the command line
  81. #626F6E75732E is hex for 'bonus'
  82. #6974656D2E20 is hex for 'item. ' - There is a space at the end to keep the strings the same length
  83. #hexdump converts the file to editable text
  84. #sed finds and replaces the strings in hexcode
  85. #xxd converts the editable text back into a binary file
  86. hexdump -ve '1/1 "%.2X"' ./src/doom2|sed "s/626F6E75732E/6974656D2E20/g"|xxd -r -p > src/doom3
  87. chmod +x src/doom3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement