File:vpatch th06 unicode.zip

This custom version of vpatch_th06.dll changes the references to the game's .exe file name from Shift-JIS to Unicode. With this, the patch will always refer to 東方紅魔郷.exe (and never to any mojibake representation), independent of the current locale.

Of course, this alone won't suddenly make vpatch work with the Japanese th06 without AppLocale. This would require the game itself to use Unicode.

It is mainly required to be able to chain the Touhou Community Reliant Automatic Patcher to vpatch. Since all the relevant code is called from DllMain, these modifications would have been impossible to achieve on-the-fly with thcrap in its current state of development.

Setup
Copy vpatch_th06_unicode.dll to the directory containing th06 and vpatch, and delete the original vpatch_th06.dll from that position. This is necessary because vpatch might otherwise inject the original DLL.

Detailed changelog
All adresses refer to file offsets.


 * 0x02c61: Change the application name pointer to our modified name.
 * 0x033e2: Double the size of the local stack to accommodate for wide chars.
 * 0x033f4: Replace GetModuleFileNameA with GetModuleFileNameW.
 * 0x03403: Adjust calculation to point to the last 10 wide chars of the GetModuleFileNameW buffer.
 * 0x0340b</tt>: Replace the call to vpatch_th06.dll's custom compare function with a call to StrCmpW, and remove the local stack cleanup (all Windows functions do so themselves).
 * 0x03470</tt>: Double the size of the local stack to accommodate for wide chars.
 * 0x11124</tt>: Replace the Shift-JIS string "東方紅魔郷.exe" with its UTF-16 representation. Overwrite the second instance, since the string is larger in UTF-16 and we only need one constant copy of it.
 * 0x124cf</tt>: Change CreateProcessA to CreateProcessW.
 * 0x14490</tt>: Add one more element to the relocation table.
 * 0x14496</tt>: Insert a relocation for the StrCmpW call. The rest of the relocation table is moved by 2 bytes.
 * Add a new import table, importing GetModuleFileNameW</tt> from KERNEL32.DLL and StrCmpW</tt> from SHLWAPI.DLL.