1. //###############################################################
  2. //# Purpose: Change the JE/JNE after LangType comparison inside #
  3. //# CGameMode::SendMsg function for /who command #
  4. //# and inside CGameMode::Zc_User_Count #
  5. //###############################################################
  6. function EnableWhoCommand() {
  7. //Step 1a - Find LangType comparison
  8. var LANGTYPE = GetLangType();//Langtype value overrides Service settings hence they use the same variable - g_serviceType
  9. if (LANGTYPE.length === 1)
  10. return "Failed in Step 1 - " + LANGTYPE[0];
  11. var code =
  12. " A1" + LANGTYPE //MOV EAX,DWORD PTR DS:[g_serviceType]
  13. + " 83 F8 03" //CMP EAX,3
  14. + " 0F 84 AB AB 00 00" //JE addr
  15. + " 83 F8 08" //CMP EAX,8
  16. + " 0F 84 AB AB 00 00" //JE addr
  17. + " 83 F8 09" //CMP EAX,9
  18. + " 0F 84 AB AB 00 00" //JE addr
  19. + " 8D" //LEA ECX,[ESP+x]
  20. ;
  21. var offset = exe.findCode(code, PTYPE_HEX, true, "\xAB");
  22. if (offset === -1) {
  23. code = code.replace("AB 00 00 8D", "AB 00 00 B8");//Change LEA to MOV EAX
  24. offset = exe.findCode(code, PTYPE_HEX, true, "\xAB");
  25. }
  26. if (offset === -1)
  27. return "Failed in Step 1 - LangType comparison missing";
  28. //Step 1b - Replace the First JE with JMP to LEA
  29. exe.replace(offset + 5, "90 EB 18", PTYPE_HEX);
  30. //Step 2a - Find PUSH 0B2 followed by CALL MsgStr - Common pattern inside Zc_User_Count
  31. code =
  32. " 68 B2 00 00 00" //PUSH 0B2
  33. + " E8 AB AB AB AB" //CALL MsgStr
  34. + " 83 C4 04" //ADD ESP, 4
  35. ;
  36. offset = exe.findCode(code, PTYPE_HEX, true, "\xAB");
  37. if (offset === -1)
  38. return "Failed in Step 2 - MsgStr call missing";
  39. //Step 2b - Find the JNE after LangType comparison before it (closer to start of Zc_User_Count)
  40. code =
  41. " 75 AB" //JNE SHORT addr
  42. + " A1 AB AB AB 00" //MOV EAX, DWORD PTR DS:[refAddr]
  43. + " 50" //PUSH EAX
  44. + " E8 AB AB AB FF" //CALL IsGravityAid
  45. + " 83 C4 04" //ADD ESP, 4
  46. + " 84 C0" //TEST AL, AL
  47. + " 75" //JNE SHORT addr
  48. ;
  49. var offset2 = exe.find(code, PTYPE_HEX, true, "\xAB", offset - 0x60, offset);
  50. if (offset2 === -1) {
  51. code = code.replace(" A1 AB AB AB 00 50", " FF 35 AB AB AB 00"); //Change MOV EAX to PUSH DWORD PTR DS:[refAddr]
  52. offset2 = exe.find(code, PTYPE_HEX, true, "\xAB", offset - 0x60, offset);
  53. // refAddr pushed further on new exe, so !
  54. if (offset2 === -1) {
  55. code = code.replace(" FF 35 AB AB AB 00"," FF 35 AB AB AB 01");
  56. offset2 = exe.find(code, PTYPE_HEX, true, "\xAB", offset-0x60, offset);
  57. }
  58. }
  59. if (offset2 === -1)
  60. return "Failed in Step 2 - LangType comparison missing";
  61. //Step 2c - Replace First JNE with JMP
  62. exe.replace(offset2, "EB", PTYPE_HEX);
  63. return true;
  64. }

EnableWhoCommand.qs