AtomCrafty / UniversalInjectorFramework

A framework to inject your own code into Windows applications.
46 stars 3 forks source link

Program entry point could not be found (0xc0000142) #4

Closed allrobot closed 4 months ago

allrobot commented 5 months ago

I use VS and set it to generate as winmm.dll 32-bit, but it gives an error.

---------------------------
stopping.exe - 应用程序错误
---------------------------
应用程序无法正常启动(0xc0000142)。请单击“确定”关闭应用程序。 
---------------------------
确定   
---------------------------

It's meaning is Program entry point could not be found (0xc0000142).

https://github.com/satan53x/SExtractor/tree/main/tools/UniversalInjectorFramework ,it's dll can work, but it output with GBK(936) encoding instead of the JIS(932) encoding of the program itself.(I used Locale.Emulator.2.5.0.1 to simulate the Japanese environment)

My system is GBK encoding.

AtomCrafty commented 5 months ago

I don't fully understand the issue. Are you saying the winmm.dll from the SExtractor repository works, but if you build it yourself it doesn't work? If so, please send me the winmm.dll you built as well as the executable of the program you're trying to inject into.

allrobot commented 5 months ago

I don't fully understand the issue. Are you saying the winmm.dll from the SExtractor repository works, but if you build it yourself it doesn't work? If so, please send me the winmm.dll you built as well as the executable of the program you're trying to inject into.

YES. I'm sorry, I made some modifications to the exe program to enable the loading of the 32-bit winmm.dll that I built. However, even though I set the font_manager enable flag to true, the font file is not being loaded correctly. The changes are only visible when the font file is installed directly.

https://github.com/satan53x/SExtractor/issues/55

If the font file MSPGothic-Regular.ttf is loaded correctly, it should display image A instead of image B.

image A√: image

image B×: image

這是某个田径場。 the font is converted to another font 这是某个田径场。

EXE link to download: https://pixeldrain.com/u/YduBrUg3

AtomCrafty commented 5 months ago

The config file from your link will load the font file, but never tell the program to actually use one of the fonts in there, because font_manager.spoof_creation.enable is set to false.

Unfortunately just setting it to true doesn't work and you will get this error:

[font_manager] Unable to enumerate import address table
[font_manager] This likely means the module had some sort of tamper protection applied to it

The issue here is that the import table of stopping.exe cannot be enumerated by DetourEnumerateImportsEx. I've had a look at the import table and it seems the OriginalFirstThunk pointers are all null, which is not supported by Detours.

allrobot commented 5 months ago

The issue here is that the import table of stopping.exe cannot be enumerated by DetourEnumerateImportsEx. I've had a look at the import table and it seems the OriginalFirstThunk pointers are all null, which is not supported by Detours.

Since Detours is not supported, is there any way to make this program load font files correctly? Is installing fonts the only way?

AtomCrafty commented 5 months ago

Does installing the font in Windows work for you? Even if I install the font, the game won't use it. Loading the font seems to work without issues, but it looks like the game simply uses a different font.

image

allrobot commented 5 months ago

Does installing the font in Windows work for you? Even if I install the font, the game won't use it. Loading the font seems to work without issues, but it looks like the game simply uses a different font.

From the screenshot, the game program did not load the MSPGothic-Regular.ttf font file. The game still uses the original default font. I don't understand why the font was installed but the game program didn't load it. Perhaps you could try restarting your computer? If restarting your computer doesn't work, it might be that your system version is too high. The system version I have here is Windows 10 Enterprise Edition 21H2.

AtomCrafty commented 5 months ago

Even after installing the font and restarting Windows it still shows 這 instead of 这.

allrobot commented 5 months ago

Even after installing the font and restarting Windows it still shows 這 instead of 这.

If you are using the same system version (Windows 10 or Windows 7) and the font installation still does not display correctly, I cannot clearly determine the reason inside.

I can display it right here, as shown in the picture:

23

If you use the third-party Python library Pylivemaker to extract, execute lmar x game.exe -o game_files documentation, and then for all LSB files, execute lmlsb dump xxxx.lsb > xxxx.txt, you can search for the string font using Notepad. You will find that the game calls for the MS Pゴシック font. The English name for this font is MS PGothic. The location of the LSB files related to the font is:

image

AtomCrafty commented 5 months ago

I'm on Windows 11, not 10 or 7. Unfortunately I don't really have the capacity to investigate this further.

All UIF is supposed to do when font_manager.resource_files is set is to call AddFontResourceEx, which it successfully does in your case. That should make the font available to the program, just as if it was installed. If it doesn't do so, that's a Windows issue and out of scope for me to fix.

All I can say is that Locale Emulator is known to cause issues with font loading. But since the Locale Emulator project has been abandoned, I don't expect that to be fixed anytime soon. It might be worth investigating whether you can find a way to run the game without LE.

allrobot commented 5 months ago

All I can say is that Locale Emulator is known to cause issues with font loading. But since the Locale Emulator project has been abandoned, I don't expect that to be fixed anytime soon. It might be worth investigating whether you can find a way to run the game without LE.

Perhaps Ollydbg can modify the program's Win function to change the code page to 932, allowing the game to display JIS-encoded fonts correctly when run locally. However, I regret that I do not know how to use Ollydbg to modify the program for this purpose.

AtomCrafty commented 5 months ago

Usually I'd recommend looking into UIF's tunnel_decoder (or the new text_processor feature) for that, but since the executable has an invalid import table, that won't be possible.

allrobot commented 1 month ago

Even after installing the font and restarting Windows it still shows 這 instead of 这.

Switched to another computer and found a solution, not sure if it's reliable.

I think it's probably because the new font file I installed didn't overwrite the original font file, that's why you can't see the changed font after installing the font file.

Open win+r regedit, input HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts

Delete the MSPGothic value in the opened registry, then restart the computer to see that the protected font has been removed. After that, install the MSPGothic-Regular.ttf I provided, and then will display as in the font.

It's possible that the system already has the original font, and it can't be overwritten by the new font file (even if it indicates successful installation). So you have to wait for the registry to be deleted, then restart the computer and install the new font file to see the changes in the game fonts. Microsoft's Windows system is really not that great; maybe this is the style of coding by those guys from India...

AtomCrafty commented 1 month ago

That makes sense. I guess another solution in that case would be to change the font face name within the custom font file to something other than MSPGothic.

allrobot commented 1 month ago

That makes sense. I guess another solution in that case would be to change the font face name within the custom font file to something other than MSPGothic.

Now MSPGothic has been removed from the system fonts, and a 32-bit DLL file has been created, but it's not working. Even when named and placed in the current directory, the game is unable to load the font file.

chrome_j1K6Ofe56l

dll+uif_config.json+uif_log.log ストッピング!!! 陸上競技編.zip