Advertisement
Guest User

Untitled

a guest
Aug 4th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.20 KB | None | 0 0
  1. // This simple program is made for use with Sputnik
  2. // A small macro programming language created by UberFoX
  3. // http://uberfox.no-ip.org/Sputnik/wiki/index.php/Main_Page
  4.  
  5. // Print the welcome message
  6. print("Org loss (for RC3) script by UberFoX\n");
  7. print("\n");
  8. print("Follow these instructions:\n");
  9. print("* Load the game\n");
  10. print("* Press ALT + TAB to minmize the game\n");
  11. print("* Press enter on this program to CONTINUE and patch the game\n");
  12. print("* Go play!\n");
  13. print("\n");
  14. print("Press any key to continue (AFTER LOADING THE GAME!!!)\n");
  15. // Wait for a key press before continuing
  16. InputC();
  17. print("\n");
  18.  
  19. // Main variables
  20. $GameCap = "Darkest Hour v 1.03";
  21. $GamePID = WinGetProcess($GameCap); // Gets the games PID so we can read/write from it
  22.  
  23. // Only continue if the game is running
  24. if($GamePID)
  25. {
  26.     // Inject the code into the running game
  27.     Poke($GamePID,
  28.         // The code as shown here appears as GTS/TMK "Pokes"
  29.         // This is very hard to read and understanding what it is doing
  30.         // Look below for the "Pokes" for the assembly code that is converted
  31.         // Into these "Pokes"
  32.         @"  Poke 511347 E9 C0 EF EE FF 90
  33.             Poke 400300 00 00 00 00 00 00 00 00 00 00 30
  34.             Poke 40030B 42 A3 00 03 40 00 D8 97 F4 00 00
  35.             Poke 400316 00 66 DF E0 9B 9E 77 10 A1 00 03
  36.             Poke 400321 40 00 D9 1D 04 03 40 00 E9 1F 10
  37.             Poke 40032C 11 00 A1 00 03 40 00 D9 9F F4 00
  38.             Poke 400337 00 00 E9 0F 10 11 00 "
  39.             /* The source code of this Poke bla bla stuff
  40.                It is for use with TSearch 1.6B
  41.             // The injection point
  42.             // Found by BP WRITE on (float) org as an hour passes by in game
  43.             // Value is as shown in game (requires rounding)
  44.             offset 511347
  45.             jmp @Inject
  46.             nop
  47.             @InjectRet:
  48.  
  49.             // The code cave
  50.             offset 400300
  51.             @SaveEAX:
  52.             hex 00000000
  53.             @Value:
  54.             hex 00000000
  55.             @Value2:
  56.             hex 00003042
  57.             @Inject:
  58.             // Save EAX
  59.             mov [@SaveEAX], eax
  60.  
  61.             // Compare the new org with the current org
  62.             fcom dword ptr [edi+0xF4]
  63.             fstsw ax
  64.             fwait
  65.             sahf
  66.             // Possible jumps
  67.             // jpe error_handler
  68.             // ja    st0_greater
  69.             // jb    st0_lower
  70.             // jz    both_equal
  71.             // We will use "ja" meaning jump if greater only
  72.             // This will ensure only org increase is allowed
  73.             // and not org decrease
  74.             ja @End
  75.  
  76.             // Load EAX
  77.             mov eax, [@SaveEAX]
  78.             // Pop the FPU to avoid funky things happening
  79.             fstp dword ptr [@Value]
  80.             // Return
  81.             jmp @InjectRet
  82.  
  83.             // This code will only be run if we want to allow decrese org
  84.             @End:
  85.             // Load EAX
  86.             mov eax, [@SaveEAX]
  87.             // Store value as normal
  88.             fstp dword ptr [edi+0xF4]
  89.             // Return
  90.             jmp @InjectRet
  91.             */
  92.     ); 
  93.     // Print success message
  94.     print("All done! Org loss should now be fixed when a unit is moving\n");
  95.     print("\n");
  96.     print("You can now close this program -- Press any key to continue.");
  97.     // Wait for a key press before continuing
  98.     InputC();
  99. }
  100. else
  101. {
  102.     // Print an error about the game is not running
  103.     print("ERROR - Make sure game is loaded! Only works for 1.03RC3\n");
  104.     print("\n");
  105.     print("You can now close this program -- Press any key to continue.");
  106.     // Wait for a key press before continuing
  107.     InputC();
  108. }
  109. // This is a function from the Sputnik library
  110. // but i included it in this source file so that
  111. // this source file will contain all functions it
  112. // uses without the need of linking to external files
  113. Function Poke( $PID, $Input )
  114. {
  115.     my $LastAddress = "";
  116.     my $LastLength = "";
  117.     my $Pokes = array();
  118.     foreach(Lines($Input) as my $Line)
  119.     {
  120.         $Line = Trim($Line); // Cannot use "my" here since it will cancel out the one above
  121.                              // Not to worry since we using a "my" anyway
  122.         if(!IsEmpty($Line))
  123.         {
  124.             if($Line =~ m/Poke\s+(\w+)\s+(.+)/)
  125.             {
  126.                 my $CurAddress = Dec(Trim($1));
  127.                 my $Values = Replace(Trim($2), " ", "");
  128.                 my $Length = StrLen($Values) / 2;
  129.                 if($LastAddress + $LastLength == $CurAddress)
  130.                 {
  131.                     BinaryAppend($Pokes[UBound($Pokes) - 1][1], BinaryHex($Values));
  132.                 }
  133.                 else
  134.                 {
  135.                     push($Pokes, array($CurAddress, BinaryHex($Values)));
  136.                 }
  137.                 $LastAddress = $CurAddress;
  138.                 $LastLength = $Length;
  139.             }
  140.         }
  141.     }
  142.     foreach($Pokes as my $Poke)
  143.     {
  144.         WriteMem($PID, "", $Poke[0], $Poke[1]);
  145.     }
  146.     unset($Pokes);
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement