Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This simple program is made for use with Sputnik
- // A small macro programming language created by UberFoX
- // http://uberfox.no-ip.org/Sputnik/wiki/index.php/Main_Page
- // Print the welcome message
- print("Org loss (for RC3) script by UberFoX\n");
- print("\n");
- print("Follow these instructions:\n");
- print("* Load the game\n");
- print("* Press ALT + TAB to minmize the game\n");
- print("* Press enter on this program to CONTINUE and patch the game\n");
- print("* Go play!\n");
- print("\n");
- print("Press any key to continue (AFTER LOADING THE GAME!!!)\n");
- // Wait for a key press before continuing
- InputC();
- print("\n");
- // Main variables
- $GameCap = "Darkest Hour v 1.03";
- $GamePID = WinGetProcess($GameCap); // Gets the games PID so we can read/write from it
- // Only continue if the game is running
- if($GamePID)
- {
- // Inject the code into the running game
- Poke($GamePID,
- // The code as shown here appears as GTS/TMK "Pokes"
- // This is very hard to read and understanding what it is doing
- // Look below for the "Pokes" for the assembly code that is converted
- // Into these "Pokes"
- @" Poke 511347 E9 C0 EF EE FF 90
- Poke 400300 00 00 00 00 00 00 00 00 00 00 30
- Poke 40030B 42 A3 00 03 40 00 D8 97 F4 00 00
- Poke 400316 00 66 DF E0 9B 9E 77 10 A1 00 03
- Poke 400321 40 00 D9 1D 04 03 40 00 E9 1F 10
- Poke 40032C 11 00 A1 00 03 40 00 D9 9F F4 00
- Poke 400337 00 00 E9 0F 10 11 00 "
- /* The source code of this Poke bla bla stuff
- It is for use with TSearch 1.6B
- // The injection point
- // Found by BP WRITE on (float) org as an hour passes by in game
- // Value is as shown in game (requires rounding)
- offset 511347
- jmp @Inject
- nop
- @InjectRet:
- // The code cave
- offset 400300
- @SaveEAX:
- hex 00000000
- @Value:
- hex 00000000
- @Value2:
- hex 00003042
- @Inject:
- // Save EAX
- mov [@SaveEAX], eax
- // Compare the new org with the current org
- fcom dword ptr [edi+0xF4]
- fstsw ax
- fwait
- sahf
- // Possible jumps
- // jpe error_handler
- // ja st0_greater
- // jb st0_lower
- // jz both_equal
- // We will use "ja" meaning jump if greater only
- // This will ensure only org increase is allowed
- // and not org decrease
- ja @End
- // Load EAX
- mov eax, [@SaveEAX]
- // Pop the FPU to avoid funky things happening
- fstp dword ptr [@Value]
- // Return
- jmp @InjectRet
- // This code will only be run if we want to allow decrese org
- @End:
- // Load EAX
- mov eax, [@SaveEAX]
- // Store value as normal
- fstp dword ptr [edi+0xF4]
- // Return
- jmp @InjectRet
- */
- );
- // Print success message
- print("All done! Org loss should now be fixed when a unit is moving\n");
- print("\n");
- print("You can now close this program -- Press any key to continue.");
- // Wait for a key press before continuing
- InputC();
- }
- else
- {
- // Print an error about the game is not running
- print("ERROR - Make sure game is loaded! Only works for 1.03RC3\n");
- print("\n");
- print("You can now close this program -- Press any key to continue.");
- // Wait for a key press before continuing
- InputC();
- }
- // This is a function from the Sputnik library
- // but i included it in this source file so that
- // this source file will contain all functions it
- // uses without the need of linking to external files
- Function Poke( $PID, $Input )
- {
- my $LastAddress = "";
- my $LastLength = "";
- my $Pokes = array();
- foreach(Lines($Input) as my $Line)
- {
- $Line = Trim($Line); // Cannot use "my" here since it will cancel out the one above
- // Not to worry since we using a "my" anyway
- if(!IsEmpty($Line))
- {
- if($Line =~ m/Poke\s+(\w+)\s+(.+)/)
- {
- my $CurAddress = Dec(Trim($1));
- my $Values = Replace(Trim($2), " ", "");
- my $Length = StrLen($Values) / 2;
- if($LastAddress + $LastLength == $CurAddress)
- {
- BinaryAppend($Pokes[UBound($Pokes) - 1][1], BinaryHex($Values));
- }
- else
- {
- push($Pokes, array($CurAddress, BinaryHex($Values)));
- }
- $LastAddress = $CurAddress;
- $LastLength = $Length;
- }
- }
- }
- foreach($Pokes as my $Poke)
- {
- WriteMem($PID, "", $Poke[0], $Poke[1]);
- }
- unset($Pokes);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement