+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  [PC] A couple of questions
Pages: [1]
Author Topic: [PC] A couple of questions  (Read 1 times)
Azkadellia
Guest
« on: December 04, 2011, 03:16:36 am »

First: How do I go about changing a PC game from running on JP region PCs to US region PCs?
Second: I found the font the game uses (MS Mincho, BTW), but how do I change it to a font of my choosing?
Nagato
Guest
« Reply #1 on: December 04, 2011, 09:43:00 am »

If you want to make a thorough change to the locale you will need to hook the locale functions to ensure they say they all think they are running in ANSI instead of CP932. Off the top of my head these functions include GetACP(), GetLocaleInfo(), GetOEMCP(), GetConsoleCP(), GetConsoleOutputCP(). This isn't all of them but it covers most of the major ones I can think of. I didn't list any of the Ex versions of the functions so you will need to look at the MSDN pages for those to get a more thorough list.

To change the font you will need to change the calls to CreateFont() and CreateFontIndirect(). For the CreateFont()s you will need to change the charset parameter as well. Shift-JIS is charset 128 (0x80) so find that and change it to ANSI. Note that you cannot use any Japanese characters after you change the charset of the font or else you will start seeing gibberish characters. CreateFont() also accepts the name of the font so you can just change it from MS Mincho to whatever there.

Start with changing the charset of CreateFont() and then move on to the other functions if the game still doesn't work properly.
« Last Edit: December 04, 2011, 09:50:05 am by Nagato »
henke37
Guest
« Reply #2 on: December 04, 2011, 03:34:53 pm »

Microsoft already has a tool for making applications use a different locale than the system. It's called applocale.
Gideon Zhi
Guest
« Reply #3 on: December 04, 2011, 03:51:35 pm »

Quote from: Nagato on December 04, 2011, 09:43:00 am
To change the font you will need to change the calls to CreateFont() and CreateFontIndirect(). For the CreateFont()s you will need to change the charset parameter as well. Shift-JIS is charset 128 (0x80) so find that and change it to ANSI. Note that you cannot use any Japanese characters after you change the charset of the font or else you will start seeing gibberish characters. CreateFont() also accepts the name of the font so you can just change it from MS Mincho to whatever there.

I had a similar question to this, actually. I found the CreateFont() call in the game I'm working on and adjusted the region parameter accordingly (which created a whole lot of mojibake in my game), but the LPCSTR font name parameter points to a null value and the game still defaults to MS Gothic. I'm sure that I'm editing the right call, though. What's going on here?
Azkadellia
Guest
« Reply #4 on: December 04, 2011, 03:57:31 pm »

Quote from: henke37 on December 04, 2011, 03:34:53 pm
Microsoft already has a tool for making applications use a different locale than the system. It's called applocale.

I'm trying to avoid having people use applocale to play the game.
Klarth
Guest
« Reply #5 on: December 04, 2011, 03:59:44 pm »

I told you last night that you don't necessarily have to supply a font name to CreateFont.  If you use CreateFont without the LPCSTR parameter, Windows will find the first font that matches the other parameters.  Change the parameter that defines the charset you wish.  Past that, you'd have to find a way put a string into the .exe and push the offset instead of pushing null.
Nagato
Guest
« Reply #6 on: December 04, 2011, 04:12:18 pm »

Quote from: Gideon Zhi on December 04, 2011, 03:51:35 pm
I had a similar question to this, actually. I found the CreateFont() call in the game I'm working on and adjusted the region parameter accordingly (which created a whole lot of mojibake in my game), but the LPCSTR font name parameter points to a null value and the game still defaults to MS Gothic. I'm sure that I'm editing the right call, though. What's going on here?
What Klarth said is correct. From MSDN: "If lpszFace is NULL or empty string, GDI uses the first font that matches the other specified attributes."

If you want to use a specific font then you'll need to find a safe spot to put the font name into the EXE and then another spot to put a code cave at so you can push the new address. If you can't find a sufficient amount of blank space then you can add a new blank section to the EXE and just write all of your code and strings in there.
Gideon Zhi
Guest
« Reply #7 on: December 04, 2011, 04:44:48 pm »

Yeah, the point is that the only parameters passed to CreateFont were int nHeight, dwrd fdwCharSet, and LPCSTR lpszFace, the latter of which was just a pointer to a null string. Changing fdwCharSet from 0x80 to 0x00 *still* resulted in MS Gothic getting printed, albeit with mojibake for the sjis. Klarth has since suggested (on IRC) that it might have something to do with the application's locale, which was the *other* question in this thread. Unfortunately I don't have any time to spend on IDA today, so for now I'll just shut up and read the rest of the thread as it comes out.
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC