News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: [PC] A couple of questions  (Read 3063 times)

Azkadellia

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 868
  • 提交向你的情妇!
    • View Profile
    • Princess Translations
[PC] A couple of questions
« 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?
Current Projects: On hold indefinitely.
I do the Twitter thing now: https://twitter.com/MistressSaeko (expect lots of game streaming announcements)
Mistress of the RHDN Discord server.

Nagato

  • Jr. Member
  • **
  • Posts: 41
    • View Profile
Re: [PC] A couple of questions
« 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

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: [PC] A couple of questions
« 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

  • IRC Staff
  • Hero Member
  • *****
  • Posts: 3505
    • View Profile
    • Aeon Genesis
Re: [PC] A couple of questions
« Reply #3 on: December 04, 2011, 03:51:35 pm »
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

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 868
  • 提交向你的情妇!
    • View Profile
    • Princess Translations
Re: [PC] A couple of questions
« Reply #4 on: December 04, 2011, 03:57:31 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.
Current Projects: On hold indefinitely.
I do the Twitter thing now: https://twitter.com/MistressSaeko (expect lots of game streaming announcements)
Mistress of the RHDN Discord server.

Klarth

  • Sr. Member
  • ****
  • Posts: 484
    • View Profile
Re: [PC] A couple of questions
« 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

  • Jr. Member
  • **
  • Posts: 41
    • View Profile
Re: [PC] A couple of questions
« Reply #6 on: December 04, 2011, 04:12:18 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

  • IRC Staff
  • Hero Member
  • *****
  • Posts: 3505
    • View Profile
    • Aeon Genesis
Re: [PC] A couple of questions
« 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.