script.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # coding:utf8
  2. __author__ = 'Snow'
  3. import os
  4. import logging
  5. import xml.dom.minidom
  6. import re
  7. import shutil
  8. import glob
  9. import distutils
  10. import gw_data_center
  11. import gw_file_system
  12. def script_init(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
  13. sdk_id = channel_sdk_info['id']
  14. # gw_data_center.pack_small = False
  15. logging.info('script_init: ' + str(channel_sdk_info))
  16. def script_first(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  17. return
  18. logging.info("-----debug exec first func-----")
  19. # game_apk = os.path.join(decompileDir, "game.apk")
  20. game_apk = decompileDir + "/../game.apk"
  21. if os.path.exists(game_apk):
  22. # A3AEECD8
  23. gw_file_system.delete_apk_file_by_aapt(game_apk, "assets/39285EFA.dex")
  24. gw_file_system.delete_apk_file_by_aapt(game_apk, "assets/A3AEECD8.dex")
  25. logging.info("-----debug-----")
  26. def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  27. # s3 = decompileDir + "/smali_classes3"
  28. # A3AEECD8.dex
  29. return
  30. dex = decompileDir + "../39285EFA.dex"
  31. asserts = os.path.join(decompileDir, "assets/39285EFA.dex")
  32. if os.path.exists(asserts) and os.path.exists(os.path.join(dex)):
  33. distutils.dir_util.copy_tree(dex, asserts)
  34. dex = decompileDir + "../A3AEECD8.dex"
  35. asserts = os.path.join(decompileDir, "assets/A3AEECD8.dex")
  36. if os.path.exists(asserts) and os.path.exists(os.path.join(dex)):
  37. distutils.dir_util.copy_tree(dex, asserts)
  38. def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  39. logging.info('------------channelSdkInfo:' + str(channelSdkInfo))
  40. if channelSdkInfo['id'] == '549':
  41. del_qihoo(decompileDir)
  42. add_openFloatWindow_method(decompileDir)
  43. def del_qihoo(decompileDir):
  44. qihoo = os.path.join(decompileDir, 'smali_classes3/com/qihoo')
  45. if os.path.exists(qihoo):
  46. shutil.rmtree(qihoo)
  47. def add_openFloatWindow_method(decompileDir):
  48. r_file_path = 'smali_classes4/com/qihoo/gamecenter/sdk/matrix/Matrix.smali'
  49. src_file = os.path.join(decompileDir, r_file_path)
  50. print(src_file)
  51. if os.path.exists(src_file):
  52. with open(src_file, 'r+') as f:
  53. lines = f.readlines()
  54. method = '.method public static openFloatWindow(Landroid/app/Activity;)V\n'
  55. if method not in lines:
  56. method = ['.method public static openFloatWindow(Landroid/app/Activity;)V\n',
  57. ' .locals 0\n',
  58. ' return-void\n',
  59. '.end method']
  60. for l in method:
  61. lines.append(l)
  62. with open(src_file, 'w+') as fl:
  63. fl.write(''.join(lines))
  64. if __name__ == '__main__':
  65. del_qihoo("C:\\Users\\Administrator\\Desktop\\wlwz")