Open NTxC opened 3 years ago
I got this so far and it works, but the loading tune is forcibly stopped when the menu is supposed to show up anyway. I assume it's because of a call to stop the audio somewhere, but I can't figure out exactly where.
if( bSkipIntroJingle )
{
// S T A R T I N G _ T U N E
auto pattern = hook::pattern( "53 54 41 52 54 49 4E 47 5F 54 55 4E 45 00" );
// L O A D I N G _ T U N E
// 4C 4F 41 44 49 4E 47 5F 54 55 4E 45 00 00
injector::WriteMemory( pattern.get_first( 0 ), 0x44414F4C, true ); // change the string from STARTING_TUNE to LOADING_TUNE
injector::WriteMemory( pattern.get_first( 4 ), 0x5F474E49, true );
injector::WriteMemory( pattern.get_first( 8 ), 0x454E5554, true );
injector::WriteMemory<uint16_t>( pattern.get_first( 12 ), 0x0000, true );
// skip replaying the loading tune
pattern = hook::pattern( "8B 8C 24 94 00 00 00 5E 5B 33 CC" ); // end of function before target function
injector::WriteMemory( pattern.get_first( 40 ), 0x00FFFFB8, true ); // mov eax, -1
injector::WriteMemory<uint16_t>( pattern.get_first( 44 ), 0xC300, true ); // ret
}
I managed to get it to work. Frontend noises will cancel the loading tune, so I made it so that the hidden menu doesn't make a noise after the GTA IV logo. The following code does the job, testers welcome.
if( bSkipIntroJingle && bSkipMenu )
{
// S T A R T I N G _ T U N E
auto pattern = hook::pattern( "53 54 41 52 54 49 4E 47 5F 54 55 4E 45 00" );
// L O A D I N G _ T U N E
// 4C 4F 41 44 49 4E 47 5F 54 55 4E 45 00 00
injector::WriteMemory( pattern.get_first( 0 ), 0x44414F4C, true ); // change the string from STARTING_TUNE to LOADING_TUNE
injector::WriteMemory( pattern.get_first( 4 ), 0x5F474E49, true );
injector::WriteMemory( pattern.get_first( 8 ), 0x454E5554, true );
injector::WriteMemory<uint16_t>( pattern.get_first( 12 ), 0x0000, true );
// skip playing the loading tune the second time
pattern = hook::pattern( "8B 8C 24 94 00 00 00 5E 5B 33 CC" ); // end of the function before the target function
injector::WriteMemory( pattern.get_first( 40 ), 0x00FFFFB8, true ); // mov eax, -1
injector::WriteMemory<uint16_t>( pattern.get_first( 44 ), 0xC300, true ); // ret
// dont stop the loading tune after the GTA IV logo
pattern = hook::pattern( "EB E7 68 3B 28 AA 3F B9 ? ? ? ? E8" );
injector::WriteMemory<uint16_t>( pattern.get_first( 17 ), 0xC030, true ); // xor al, al
}
The end result: youtube video
@NTxC I noticed that the signatures for this patch are for Complete Edition, at least the last 2 ones. I was trying to implement it into the pre-ivce branch which supports v1.0.8.0 and below. I found the signatures for v1.0.8.0 but it keeps throwing the assertion failed error when booting up the game. I was able to trace it back to the pattern.get_first
method
if (bSkipIntroJingle)
{
/*S T A R T I N G _ T U N E*/
auto pattern = hook::pattern("53 54 41 52 54 49 4E 47 5F 54 55 4E 45 00");
/*L O A D I N G _ T U N E */
/*4C 4F 41 44 49 4E 47 5F 54 55 4E 45 00 00*/
injector::WriteMemory(pattern.get_first(0), 0x44414F4C, true); // change the string from STARTING_TUNE to LOADING_TUNE
injector::WriteMemory(pattern.get_first(4), 0x5F474E49, true);
injector::WriteMemory(pattern.get_first(8), 0x454E5554, true);
injector::WriteMemory<uint16_t>(pattern.get_first(12), 0x0000, true);
// skip playing the loading tune the second time
pattern = hook::pattern("8B 8C 24 94 00 00 00 5F 5B 33 CC"); // end of the function before the target function
injector::WriteMemory(pattern.get_first(40), 0x00FFFFB8, true); // mov eax, -1
injector::WriteMemory<uint16_t>(pattern.get_first(44), 0xC300, true); // ret*/
// dont stop the loading tune after the GTA IV logo
pattern = hook::pattern("00 00 68 3B 28 AA 3F B9 ? ? ? ? E8 19 67 45 00 84 C0");
injector::WriteMemory<uint16_t>(pattern.get_first(17), 0xC030, true); // xor al, al
}
This is the updated code with the two v1.0.8.0 signatures below, the last signature might be overkill, not really sure about that. STARTING and LOADING_TUNE strings signatures have not been changed since 1.0.8.0. Hope you can help me figure out what's wrong with it.
@sierratangocharlie26 The assertion errors may show up if the patterns haven't been found in the memory. Haven't had more time to look into it yet, but this one was sticking out. The last pattern in your version of the code:
pattern = hook::pattern("00 00 68 3B 28 AA 3F B9 ? ? ? ? E8 19 67 45 00 84 C0");
seems to be hardcoding the target CALL address (the four bytes after E8). Remember that the executable is relocatable in the memory, so you have to assume that the target CALL address might be different every time, so you must use the question marks instead, like this:
pattern = hook::pattern("00 00 68 3B 28 AA 3F B9 ? ? ? ? E8 ? ? ? ? 84 C0");
Edit: nevermind, looks like that CALL is relative. Still wouldn't risk it with the hardcoded one, though, as the relative offset may be different for different versions of gtaiv.exe. I wrote my code using v1.2.0.43.
@NTxC I just realised that this
// skip playing the loading tune the second time
pattern = hook::pattern("8B 8C 24 94 00 00 00 5F 5B 33 CC"); // end of the function before the target function
injector::WriteMemory(pattern.get_first(40), 0x00FFFFB8, true); // mov eax, -1
injector::WriteMemory<uint16_t>(pattern.get_first(44), 0xC300, true); // ret
won't work for v1.0.8.0 since it will be the start a completely different function, the desired function is at another location. I think for now I'm trying to solve the issue that it can't even change STARTING_TUNE string to LOADING_TUNE because of aforementioned assertion failure. If I comment out the write memory stuff it works fine so I assume the pattern hooking has no issues (?).
I have to mention that I'm relatively new to this topic, I only did little patches in other games and I'm also not really familiar with the methods such as get_first
etc. yet.
@NTxC I found the correct signatures for the two bottom patches for v1.0.8.0 and it works, yet, for some unknown reasons it simply can't find the signature of the STARTING_TUNE string. I tried to check the size of the pattern and it seems it's empty so I assume it just can't find it at all on v1.0.8.0. I still managed to make it work although it requires editing the sounds.dat15 file in the audio configs replacing the LOADING_TUNE there, pretty much the same procedure like in your implementation if you ask me, but not as elegant.
Anyway here's the code with the 1.0.8.0 signatures in case you (or someone else) are interested:
// skip playing the loading tune the second time
auto pattern = hook::pattern("50 E8 ? ? ? ? 5E 5F 83 C4 48 C3"); // end of the function before the target function
injector::WriteMemory(pattern.get_first(13), 0x00FFFFB8, true); // mov eax, -1
injector::WriteMemory<uint16_t>(pattern.get_first(17), 0xC300, true); // ret
// dont stop the loading tune after the GTA IV logo
pattern = hook::pattern("E9 16 07 00 00 68 3B 28 AA 3F B9 ? ? ? ?");
injector::WriteMemory<uint16_t>(pattern.get_first(20), 0xC030, true); // xor al, al
I really have no clue at this point why it couldn't find the signature of that string, maybe one day someone will find the solution for this.
@NTxC @sTc2201 Old feed, but how would I implement this code into the game? I'm still learning as I go, but seeing this and the YT video are how I remember it beginning and I am working to make it as close to original as possible.
This is purely for nostalgia sake - would this be hard to implement?
On consoles, when you popped the disc in and launched the game, the game would play the loading screen song immediately during the R* intro sequence.
On PC, this was changed so that there is a little short version of that song, a jingle that plays before the main menu is shown (absent on consoles).
Seeing how the Fusion Fix implements an option to skip the main menu and go straight to the game, it would be amazing if there was also an option that makes the game play the loading song straight away INSTEAD of the little PC exclusive jingle.
It is minor, but it would add to the experience if you were a seasoned console player and you'd like the startup sequence to be similar to how it was on the consoles.