Author Topic: Hammerwatch Port Changer  (Read 3422 times)

DivinityArcane

  • Posts: 30
  • wat
    • View Profile
    • DeviantART profile
Hammerwatch Port Changer
« on: June 29, 2014, 09:43:35 AM »
Hi there.

Long story short, I'm working on a custom server for HW in my free time, and when some friends of mine heard about this, they asked if I knew how to change the port in HW. Well, doing so is pretty simple, and thanks to Myran saving me 1-2 hours of trudging around in the binary, I did it with ease. Thing is, if you're like my friends, and you have no idea how to modify a binary using a hex editor, you probably think this is complete nonsense. If so, this is a simple app to do it for you with the click of a button. (If not, just head over to that thread and read up on how to change it in under 5 minutes, manually.)

Anyway, this app basically searches the file for for the original port, and changes it to whatever port you want  to change it to. Keep in mind that this changes the port for both hosting a game as well as joining a game. So if you change the port to something other than 9995, you won't be able to connect to servers that don't broadcast on the port you changed to. On the other hand, if your friend changes his port to 5050 and hosts a game, and you change your port to 5050, you can connect to his game just fine. So, this is only really useful if you can get your friends to change to the same port as you change to, since HW doesn't communicate the port in the server browser (it's hardcoded as 9995 right now). Either way, it's useful in those situations where you and your friends can't use port 9995, and would rather use 8080 or something your router allows. Unless HW devs add the server ports to the server browser packets, they'll all be assumed to be using 9995, so that's a minor limitation of changing your port for the game.

So, let's cut to the chase. A few things to mention:

  • The app automatically backs up your Hammerwatch.exe to a file named Hammerwatch.exe.bakN where N is a number unique to that backup. This filename will be printed in the output box with the rest of the information. Take note of it in case you want to reverse the changes later!
  • The client will still say "Port: 9995". This is due to the fact that that particular string is hardcoded in assets.bin, and I don't think it's necessary to rewrite that. It's purely cosmetic, and your actual port will still be changed!
  • This should work with any version of HW, since it searches the file, instead of using predefined positions!

So, if you need to change your port to play with your friends, this will help you. At least until HW devs add an option for changing it (if that's on their list of changes, which it may not be.) I've attached the app to this post which you can download and unzip. You may have to run it as administrator.

Alternatively, if you want the source code, go crazy - it's open-source: GitHub Repository and the majority of the madness goes on in a simple method in Form1.cs

And, if you're worried about viruses and such on the internet (which you should be, the internet is a scary place!) here's the VirusTotal results: VirusTotal Scan

If you encounter any problems, let me know. I'll try to keep it up-to-date. While it was originally something I wrote to make my own life easier, I figure it will help a few people out in the long run.