Advertisement
Guest User

Untitled

a guest
Jul 14th, 2014
1,659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 100.39 KB | None | 0 0
  1. #include amxmodx
  2. #include amxmisc
  3.  
  4. #include orpheu
  5. #include orpheu_memory
  6. #include orpheu_advanced
  7.  
  8. #define PLUGIN_NAME "Check files by OSTROG"
  9. #define PLUGIN_VERSION "1.0"
  10. #define PLUGIN_AUTHOR "OSTROG"
  11.  
  12. #define CONFIG_PATH                 "addons/amxmodx/configs/ost_path_list.ini"
  13. #define ORPHEU_FUNCTIONS_PATH       "addons/amxmodx/configs/orpheu/functions/"
  14. #define ORPHEU_MEMORY_PATH          "addons/amxmodx/configs/orpheu/memory/"
  15.  
  16. #define CONSOLE_PRINT_PREFIX        "[OST Check Files] "
  17. #define CONSOLE_PRINT_ERROR_PREFIX  "[ERROR] "
  18.  
  19. static  NAME_CMD_PATH[]                     =   "add_path"
  20. static  CHAR_PATH_W_B[]                     =   "["
  21. static  CHAR_PATH_W_E[]                     =   "]"
  22. static  CHAR_PATH_R_E[]                     =   "="
  23.  
  24. static  CONFIG_SAVE[]                       =   {
  25.     0x2f,0x2f,0x20,0x20,0xd0,0x9a,0xd0,0xbe,0xd0,0xbd,0xd1,0x84,0xd0,0xb8,0xd0,0xb3,0x20,0xd1,0x81,0x20,0xd0,0xbd,0xd0,0xb0,0xd1,0x81,0xd1,0x82,0xd1,0x80,0xd0,0xbe,0xd0,0xb9,0xd0,0xba,0xd0,0xb0,0xd0,0xbc,0xd0,0xb8,0x3a,0xd,0xa,0x2f,0x2f,0x20,0x20,0x20,0x20,0xd0,0x9a,0xd0,0xbe,0xd0,0xbc,0xd0,0xb0,0xd0,0xbd,0xd0,0xb4,0xd0,
  26.     0xb0,0x20,0xd0,0xb8,0xd0,0xbc,0xd0,0xb5,0xd0,0xb5,0xd1,0x82,0x20,0xd1,0x81,0xd0,0xbb,0xd0,0xb5,0xd0,0xb4,0xd1,0x83,0xd1,0x8e,0xd1,0x89,0xd0,0xb8,0xd0,0xb9,0x20,0xd0,0xbf,0xd1,0x80,0xd0,0xbe,0xd1,0x82,0xd0,0xbe,0xd1,0x82,0xd0,0xb8,0xd0,0xbf,0x3a,0xd,0xa,0x2f,0x2f,0x20,0x20,0x20,0x20,0x20,0x20,0x61,0x64,0x64,0x5f,0x70,
  27.     0x61,0x74,0x68,0x5b,0x20,0x65,0x78,0x65,0x63,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0x5d,0x5b,0x20,0x72,0x75,0x6c,0x65,0x20,0x5d,0x20,0x3d,0x20,0x70,0x61,0x74,0x68,0xd,0xa,0x2f,0x2f,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xd0,0xb3,0xd0,0xb4,0xd0,0xb5,0x20,0x22,0x65,0x78,0x65,0x63,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,
  28.     0x22,0x20,0xd1,0x81,0xd1,0x82,0xd1,0x80,0xd0,0xbe,0xd0,0xba,0xd0,0xb0,0x20,0xd0,0xba,0xd0,0xbe,0xd1,0x82,0xd0,0xbe,0xd1,0x80,0xd0,0xb0,0xd1,0x8f,0x20,0xd0,0xbf,0xd0,0xbe,0xd0,0xb9,0xd0,0xb4,0xd0,0xb5,0xd1,0x82,0x20,0xd0,0xb2,0x20,0x73,0x65,0x72,0x76,0x65,0x72,0x5f,0x63,0x6d,0x64,0x2c,0x20,0x25,0x6e,0x20,0x2d,0x20,0xd0,
  29.     0xb7,0xd0,0xb0,0xd0,0xbc,0xd0,0xb5,0xd0,0xbd,0xd1,0x8f,0xd0,0xb5,0xd1,0x82,0xd1,0x81,0xd1,0x8f,0x20,0xd0,0xbd,0xd0,0xb0,0x20,0xd0,0xb8,0xd0,0xbc,0xd1,0x8f,0x20,0xd0,0xb8,0xd0,0xb3,0xd1,0x80,0xd0,0xbe,0xd0,0xba,0xd0,0xb0,0x20,0x25,0x6d,0x20,0x2d,0x20,0xd0,0xb7,0xd0,0xb0,0xd0,0xbc,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20,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0xd0,0xbd,0xd0,0xb0,0x20,0xd0,0xb2,0xd1,
  47.     0x8b,0xd0,0xbf,0xd0,0xbe,0xd0,0xbb,0xd0,0xbd,0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,0xd0,0xb5,0x20,0xd0,0xb8,0xd0,0xbb,0xd0,0xb8,0x20,0xd0,0xbd,0xd0,0xb5,0xd1,0x82,0x20,0xd0,0xb7,0xd0,0xb0,0xd0,0xb2,0xd0,0xb8,0xd1,0x81,0xd0,0xb8,0xd1,0x82,0x20,0xd0,0xbe,0xd1,0x82,0x20,0x21,0x20,0xd0,0xbf,0xd0,0xb5,0xd1,0x80,0xd0,0xb5,0xd0,0xb4,
  48.     0x20,0x61,0x6c,0x6c,0x20,0x2c,0xd,0xa,0x2f,0x2f,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xd1,0x82,0xd1,0x83,0xd1,0x82,0x20,0x21,0x20,0xd0,0xbd,0xd0,0xb5,0xd1,0x82,0x20,0xd1,0x81,0xd0,0xbb,0xd0,0xb5,0xd0,0xb4,0xd0,0xbe,
  49.     0xd0,0xb2,0xd0,0xb0,0xd1,0x82,0xd0,0xb5,0xd0,0xbb,0xd1,0x8c,0xd0,0xbd,0xd0,0xbe,0x20,0xd0,0xb2,0xd1,0x8b,0xd0,0xbf,0xd0,0xbe,0xd0,0xbb,0xd0,0xbd,0xd0,0xb8,0xd1,0x82,0xd1,0x8c,0xd1,0x81,0xd1,0x8f,0x20,0x65,0x78,0x65,0x63,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,0x2e,0xd,0xa,0x2f,0x2f,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
  50.     0x20,0x20,0x20,0x20,0x5b,0x20,0x21,0x66,0x30,0x61,0x62,0x34,0x63,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0,0xbb,0xd1,0x8c,0xd0,0xbd,0xd0,0xbe,0x20,0xd1,0x84,0xd0,0xb0,0xd0,0xb9,0xd0,0xbb,0xd0,0xb0,0x20,0xd0,0xb5,0xd1,0x81,0xd1,0x82,0xd1,0x8c,0x20,
  54.     0x2c,0x20,0xd,0xa,0x2f,0x2f,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xd0,0xbf,0xd0,0xbe,0xd0,0xb9,0xd0,0xb4,0xd0,0xb5,0xd1,0x82,0x20,0xd0,0xbb,0xd0,0xb8,0x20,0x65,0x78,0x65,0x63,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,
  55.     0xd0,0xbd,0xd0,0xb0,0x20,0xd0,0xb2,0xd1,0x8b,0xd0,0xbf,0xd0,0xbe,0xd0,0xbb,0xd0,0xbd,0xd0,0xb5,0xd0,0xbd,0xd0,0xb8,0xd0,0xb5,0x20,0xd0,0xb8,0xd0,0xbb,0xd0,0xb8,0x20,0xd0,0xbd,0xd0,0xb5,0xd1,0x82,0x20,0xd0,0xb7,0xd0,0xb0,0xd0,0xb2,0xd0,0xb8,0xd1,0x81,0xd0,0xb8,0xd1,0x82,0x20,0xd0,0xbe,0xd1,0x82,0x20,0x21,0x20,0xd0,0xbf,
  56.     0xd0,0xb5,0xd1,0x80,0xd0,0xb5,0xd0,0xb4,0x20,0x28,0x20,0x66,0x30,0x61,0x62,0x34,0x63,0x37,0x33,0x20,0x2d,0x20,0xd0,0xbf,0xd0,0xb5,0xd1,0x80,0xd0,0xb2,0xd1,0x8b,0xd0,0xbc,0xd0,0xb8,0x20,0x38,0x2d,0xd1,0x8e,0x20,0xd0,0xb1,0xd1,0x83,0xd0,0xba,0xd0,0xb2,0xd0,0xb0,0xd0,0xbc,0xd0,0xb8,0x20,0x6d,0x64,0x35,0x20,0xd1,0x84,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b0,0xd0,0xbd,0xd0,0xbd,0xd0,0xbe,0xd0,0xbc,0xd1,0x83,0x20,0xd0,0xb2,
  64.     0xd0,0xb0,0xd0,0xbc,0xd0,0xb8,0x20,0x2c,0x20,0xd0,0xbb,0xd0,0xb8,0xd0,0xb1,0xd0,0xbe,0x20,0xd1,0x84,0xd0,0xb0,0xd0,0xb9,0xd0,0xbb,0xd0,0xb0,0x20,0xd0,0xbd,0xd0,0xb5,0xd1,0x82,0xd1,0x83,0x2e,0xd,0xa,0xd,0xa,0x61,0x64,0x64,0x5f,0x70,0x61,0x74,0x68,0x5b,0x20,0x6b,0x69,0x63,0x6b,0x20,0x22,0x25,0x6e,0x22,0x20,0x22,0x4f,
  65.     0x70,0x65,0x6e,0x47,0x4c,0x20,0x44,0x65,0x74,0x65,0x63,0x74,0x65,0x64,0x22,0x20,0x5d,0x5b,0x20,0x21,0x70,0x72,0x65,0x76,0x7c,0x61,0x6c,0x6c,0x20,0x5d,0x20,0x3d,0x20,0x2e,0x2e,0x2f,0x6f,0x70,0x65,0x6e,0x67,0x6c,0x33,0x32,0x2e,0x64,0x6c,0x6c,0xd,0xa,0x61,0x64,0x64,0x5f,0x70,0x61,0x74,0x68,0x5b,0x20,0x6b,0x69,0x63,0x6b,
  66.     0x20,0x22,0x25,0x6e,0x22,0x20,0x22,0x43,0x53,0x58,0x47,0x75,0x61,0x72,0x64,0x20,0x44,0x65,0x74,0x65,0x63,0x74,0x65,0x64,0x22,0x20,0x5d,0x5b,0x20,0x21,0x70,0x72,0x65,0x76,0x7c,0x61,0x6c,0x6c,0x20,0x5d,0x20,0x3d,0x20,0x2e,0x2e,0x2f,0x43,0x53,0x58,0x47,0x75,0x61,0x72,0x64,0x2e,0x64,0x6c,0x6c,0xd,0xa,0x61,0x64,0x64,0x5f,
  67.     0x70,0x61,0x74,0x68,0x5b,0x20,0x6b,0x69,0x63,0x6b,0x20,0x22,0x25,0x6e,0x22,0x20,0x22,0x50,0x72,0x6f,0x74,0x65,0x63,0x74,0x6f,0x72,0x20,0x44,0x65,0x74,0x65,0x63,0x74,0x65,0x64,0x22,0x20,0x5d,0x5b,0x20,0x21,0x70,0x72,0x65,0x76,0x7c,0x61,0x6c,0x6c,0x20,0x5d,0x20,0x3d,0x20,0x2e,0x2e,0x2f,0x70,0x72,0x6f,0x74,0x65,0x63,0x74,
  68.     0x6f,0x72,0x2e,0x64,0x6c,0x6c,0xd,0xa,0x61,0x64,0x64,0x5f,0x70,0x61,0x74,0x68,0x5b,0x20,0x6b,0x69,0x63,0x6b,0x20,0x22,0x25,0x6e,0x22,0x20,0x22,0x43,0x61,0x72,0x64,0x69,0x6e,0x61,0x6c,0x20,0x44,0x65,0x74,0x65,0x63,0x74,0x65,0x64,0x22,0x20,0x5d,0x5b,0x20,0x21,0x70,0x72,0x65,0x76,0x7c,0x61,0x6c,0x6c,0x20,0x5d,0x20,0x3d,
  69.     0x20,0x2e,0x2e,0x2f,0x63,0x61,0x72,0x64,0x69,0x6e,0x61,0x6c,0x2e,0x64,0x6c,0x6c,0xd,0xa,0x61,0x64,0x64,0x5f,0x70,0x61,0x74,0x68,0x5b,0x20,0x6b,0x69,0x63,0x6b,0x20,0x22,0x25,0x6e,0x22,0x20,0x22,0x43,0x54,0x2d,0x53,0x68,0x69,0x65,0x6c,0x64,0x20,0x44,0x65,0x74,0x65,0x63,0x74,0x65,0x64,0x22,0x20,0x5d,0x5b,0x20,0x21,0x70,
  70.     0x72,0x65,0x76,0x7c,0x61,0x6c,0x6c,0x20,0x5d,0x20,0x3d,0x20,0x2e,0x2e,0x2f,0x63,0x74,0x2d,0x73,0x68,0x69,0x65,0x6c,0x64,0x2e,0x61,0x73,0x69,0xd,0xa,0x61,0x64,0x64,0x5f,0x70,0x61,0x74,0x68,0x5b,0x20,0x6b,0x69,0x63,0x6b,0x20,0x22,0x25,0x6e,0x22,0x20,0x22,0x42,0x61,0x64,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x6d,
  71.     0x61,0x6e,0x2e,0x64,0x6c,0x6c,0x20,0x44,0x65,0x74,0x65,0x63,0x74,0x65,0x64,0x22,0x20,0x5d,0x5b,0x20,0x21,0x66,0x30,0x61,0x62,0x34,0x63,0x37,0x33,0x7c,0x61,0x6c,0x6c,0x20,0x5d,0x20,0x3d,0x20,0x2e,0x2e,0x2f,0x76,0x61,0x6c,0x76,0x65,0x2f,0x63,0x6c,0x5f,0x64,0x6c,0x6c,0x73,0x2f,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x6d,
  72.     0x61,0x6e,0x2e,0x64,0x6c,0x6c,0xd,0xa,0x61,0x64,0x64,0x5f,0x70,0x61,0x74,0x68,0x5b,0x20,0x6b,0x69,0x63,0x6b,0x20,0x22,0x25,0x6e,0x22,0x20,0x22,0x42,0x61,0x64,0x20,0x44,0x65,0x6d,0x6f,0x50,0x6c,0x61,0x79,0x65,0x72,0x2e,0x64,0x6c,0x6c,0x20,0x44,0x65,0x74,0x65,0x63,0x74,0x65,0x64,0x22,0x20,0x5d,0x5b,0x20,0x21,0x70,0x72,
  73.     0x65,0x76,0x7c,0x21,0x37,0x65,0x66,0x35,0x62,0x35,0x38,0x31,0x7c,0x21,0x62,0x64,0x63,0x35,0x32,0x33,0x38,0x34,0x7c,0x61,0x6c,0x6c,0x20,0x5d,0x20,0x3d,0x20,0x2e,0x2e,0x2f,0x44,0x65,0x6d,0x6f,0x50,0x6c,0x61,0x79,0x65,0x72,0x2e,0x64,0x6c,0x6c,0xd,0xa,0x00
  74. }
  75.  
  76.  
  77.  
  78. /*    ######################################    EngineBase Begin    ######################################    */
  79. static  ORPHEU_NAME_ENGINE_BASE[]                       =   "__ost_engine_base"
  80. static  ORPHEU_PATTERN_ENGINE_BASE[]                    =   "[^"*^"]"
  81. /*     ######################################    EngineBase End    ######################################     */
  82.  
  83. /*    ######################################    WriteByteEng Begin    ######################################    */
  84. static  ORPHEU_NAME_WRITE_BYTE_ENG[]                    =   "__ost_write_byte_eng"
  85. static  ORPHEU_PATTERN_WRITE_BYTE_ENG[]                 =   "0"
  86. /*     ######################################    WriteByteEng End    ######################################     */
  87.  
  88. /*    ######################################    WriteByte Begin    ######################################    */
  89. static  ORPHEU_NAME_WRITE_BYTE[]                        =   "__ost_write_byte"
  90. static  ORPHEU_ARGV_WRITE_BYTE[]                        =   "{^"type^":^"long^"},{^"type^":^"long^"}"
  91. static  ORPHEU_RET_WRITE_BYTE[]                         =   "long"
  92. static  ORPHEU_PATTERN_WRITE_BYTE[]                     =   "[0x43,0x6D,0x64,0x5F,0x41,0x64,0x64,0x43,0x6F,0x6D,0x6D,0x61,0x6E,0x64,0x3A,0x20,0x25,0x73,0x20,0x61,0x6C,0x72,0x65,0x61,0x64,0x79,0x20,0x64,0x65,0x66,0x69,0x6E,0x65,0x64,0x20,0x61,0x73,0x20,0x61,0x20,0x76,0x61,0x72,0x0A,0x00]"
  93. /*     ######################################    WriteByte End    ######################################     */
  94.  
  95. /*    ######################################    Malloc Begin    ######################################    */
  96. static  ORPHEU_NAME_MALLOC_WIN[]                        =   "__ost_malloc_win"
  97.  
  98. static  ORPHEU_NAME_MALLOC_LIN[]                        =   "__ost_malloc_lin"
  99. static  ORPHEU_PATTERN_MALLOC_W[]                       =   "[^"*^"]"
  100. static  ORPHEU_PATTERN_MALLOC_L[]                       =   "^"Hunk_Alloc^""
  101.  
  102. static  ORPHEU_ARGV_MALLOC[]                            =   "{^"type^":^"long^"}"
  103. static  ORPHEU_RET_MALLOC[]                             =   "long"
  104. /*     ######################################    Malloc End    ######################################     */
  105.  
  106. /*    ######################################    Cbuf_AddText Begin    ######################################    */
  107. static  ORPHEU_NAME_CBUF_ADDTEXT[]                      =   "__ost_cbuf_addtext_lin"
  108. static  ORPHEU_PATTERN_CBUF_ADDTEXT_W[]                 =   "[^"*^"]"
  109. static  ORPHEU_PATTERN_CBUF_ADDTEXT_L[]                 =   "^"Cbuf_AddText^""
  110. /*     ######################################    Cbuf_AddText End    ######################################     */
  111.  
  112. /*    ######################################    SV_SendResources Begin    ######################################    */
  113. static  ORPHEU_NAME_SV_SENDRES[]                        =   "__ost_sv_sendresources"
  114. static  ORPHEU_PATTERN_SV_SENDRES_W[]                   =   "[0x55,0x8B,0xEC,0x83,0xEC,0x20,0x53,0x57,0x6A,0x20,0x8D,0x45,0xE0,0x6A,0x00,0x50,0xE8,^"*^",^"*^",^"*^",^"*^",0x8B,0x5D,0x08,0x6A,0x2D,0x53,0xE8]"
  115. static  ORPHEU_PATTERN_SV_SENDRES_L[]                   =   "^"SV_SendResources^""
  116. /*     ######################################    SV_SendResources End    ######################################     */
  117.  
  118. /*    ######################################    SV_ParseConsistencyResponse Begin    ######################################    */
  119. static  ORPHEU_NAME_SV_PARSECONS[]                      =   "__ost_sv_parseconsistencyresponse"
  120. static  ORPHEU_PATTERN_SV_PARSECONS_W[]                 =   "[0x55,0x8B,0xEC,0x81,0xEC,0x98,0x01,0x00,0x00,0x53,0x56,0x57,0x33,0xC0,0x6A,0x20,0x89,0x45,0xF8,0x89,0x45,0xFC,0x50,0x8D,0x45,0x88,0x50,0xE8,^"*^",^"*^",^"*^",^"*^",0xE8,^"*^",^"*^",^"*^",^"*^"]"
  121. static  ORPHEU_PATTERN_SV_PARSECONS_L[]                 =   "^"SV_ParseConsistencyResponse^""
  122. /*     ######################################    SV_ParseConsistencyResponse End    ######################################     */
  123.  
  124. /*    ######################################    MSG_ReadBits Begin    ######################################    */
  125. static  ORPHEU_NAME_MSG_READBITS[]                      =   "__ost_msg_readbits"
  126. static  ORPHEU_PATTERN_MSG_READBITS_W[]                 =   "[0x55,0x8B,0xEC,0xA1,^"*^",^"*^",^"*^",^"*^",0x85,0xC0,0x74,0x07,0xB8,0x01,0x00,0x00,0x00,0x5D,0xC3,0x53,0x56,0x8B,0x35,^"*^",^"*^",^"*^",^"*^",0x57,0x8B,0x3D,^"*^",^"*^",^"*^",^"*^",0x83,0xFF,0x08]"
  127. static  ORPHEU_PATTERN_MSG_READBITS_L[]                 =   "^"MSG_ReadBits^""
  128. /*     ######################################    MSG_ReadBits End    ######################################     */
  129.  
  130. /*    ######################################    MSG_WriteBits Begin    ######################################    */
  131. static  ORPHEU_NAME_MSG_WRITEBITS[]                     =   "__ost_msg_writebits_lin"
  132. static  ORPHEU_PATTERN_MSG_WRITEBITS_W[]                =   "[0x55,0x8B,0xEC,0x8B,0x4D,0x0C,0x53,0x56,0x33,0xC0,0x57,0x8B,0x7D,0x08,0x83,0xF9,0x20,0x7D,^"*^",0xBA,0x01,0x00,0x00,0x00,0xD3,0xE2,0x3B,0xFA,0x72]"
  133. static  ORPHEU_PATTERN_MSG_WRITEBITS_L[]                =   "^"MSG_WriteBits^""
  134. /*     ######################################    MSG_WriteBits End    ######################################     */
  135.  
  136. /*    ######################################    SV_RequestMissingResources Begin    ######################################    */
  137. static  ORPHEU_NAME_SV_REQ_MISS[]                       =   "__ost_sv_requestmissingresources"
  138. static  ORPHEU_PATTERN_SV_REQ_MISS_W[]                  =   "[^"*^"]"
  139. static  ORPHEU_PATTERN_SV_REQ_MISS_L[]                  =   "^"SV_RequestMissingResources^""
  140. /*     ######################################    SV_RequestMissingResources End    ######################################     */
  141.  
  142.  
  143.  
  144. static  SAVE_ORIGINAL_DATA_W[] = {
  145.     0x43,0x6D,0x64,0x5F,0x41,0x64,0x64,0x43,0x6F,0x6D,0x6D,0x61,0x6E,0x64,0x3A,0x20,0x25,0x73,0x20,
  146.     0x61,0x6C,0x72,0x65,0x61,0x64,0x79,0x20,0x64,0x65,0x66,0x69,0x6E,0x65,0x64,0x20,0x61,0x73,0x20,
  147.     0x61,0x20,0x76,0x61,0x72,0x0A,0x00
  148. }
  149.  
  150.  
  151.  
  152.  
  153. static  BYTE_CODE_W_BYTE[] = { 0x8A, 0x44, 0x24, 0x08, 0x8B, 0x54, 0x24, 0x04, 0x88, 0x02, 0xC3 , 0x00 }
  154. static  BYTE_CODE_TRY_FILES[] = {
  155.     0xFFFE96B9,0xFFFE969D,0xFFFE9671,0xFFFE9655,0xFFFE9629,0xFFFE960D,0xFFFE95E1,0xFFFE95C5,0xFFFE9599,0xFFFE95BD,0xFFFE9551,0xFFFE9575,0x90C29509,0x899D1B45,0xB9C0D019,0x000001BC,
  156.     0x74AF8FFC,0x00015983,0x9D6701A8,0xFFB9C0F5,0x29010169,0x5F9C1D5C,0x00418645,0x66522B6E,0x81CA8A7C,0xFFFE96FB,0xC1C9E911,0xC788000B,0xF3FDACD7,0xF3D87C97,0x5B9C29BC,0x90C23145,
  157.     0x66523AD2,0x81CA7CB8,0xFFFE8FF7,0xC1C9DCD5,0xC78805D7,0xF3FDBA53,0x890C1759,0x75A7952B,0x00004C01,0x02EA0464,0x9D67C407,0xC35F3119,0x9C673561,0x000190D7,0xC1C67ED8,0xF807FD5D,
  158.     0x0909A81F,0x08E6C65C,0xCB888D2F,0xFFFDA6B3,0xCB2890E9,0x89039D2B,0xABF293C9,0xAAF2AEDB,0x5F5A71A2,0x00418199,0x555639E5,0x438AAE69,0xFF3F9FE0,0xE88A8FED,0x7E418C25,0x00414C7F,
  159.     0x438A06A0,0x480183C0,0xFF848E6D,0x3345DAD0,0xC1C78322,0xC6020434,0x148BF8FD,0x8BCC80A2,0x59E8F97D,0x85FE8CBD,0x890A1588,0x7301F1E1,0x1C728124,0x4F470011,0x43C6B54B,0xFFFE8D44,
  160.     0x5E5E2FF9,0xC08AC9B1,0x55563545,0x438AB0C9,0xFFF98848,0xF08A23C0,0x2B1D1EBD,0x455E0FB6,0xE7C08C45,0x8BFF06A0,0xF845C5B5,0x44C607AC,0xFFFE4348,0x44C78A6D,0x8B7FD680,0xF8559901,
  161.     0x0011C5EB,0xC0320A44,0xFFFE2F00,0xC60297D5,0x005C8274,0x548C0C51,0x20B7EB60,0x33010D1C,0xFF0B7540,0x038A883D,0x94885F05,0x00018DF4,0x89D33F90,0x00858400,0x4D470CD8,0x5F5CAAEF,
  162.     0x90C1E59A,0x77764BF9,0x74010139,0x555476CF,0x11B8E303,0xE8101CFB,0xFFFE86B4,0x11101FC4,0xFF63776F,0x05C6867D,0x7775FE19,0x00010F13,0x5553E0B7,0xC08A5387,0x5555DC75,0x0005C6CC,
  163.     0xC4800DA0,0xFFFE7DC0,0xF673DA18,0x00258989,0x83010DF0,0xF18A8710,0x048868FD,0x24059BB8,0xFFFF17E8,0x83F99BBD,0x05773251,0x000132B5,0x83F21010,0xF33A121E,0x81674156,0x756F2CA9,
  164.     0x2BEF9A2E,0x8DCC9AE1,0x448C1245,0x09E90C68,0x8BFE866A,0x24159A5D,0xFDE94DBD,0x8BFE8187,0x2455978B,0x1F0597A0,0xFFFC71E0,0x03DE0D35,0x43007541,0xC2728421,0x400955A7,0x5F5C11FC,
  165.     0x90C1DCDA,0x5055EB69,0x000115B0,0x04C5978C,0x50FE80A0,0x8BF7051C,0x40013A7C,0xC482161C,0x2405891C,0x83104AEF,0xDA8A1422,0x427384B9,0x253A9172,0x8B37081F,0x8BFA2E42,0x02529075,
  166.     0x0424D8EB,0xFFFCA66C,0xB9D58EB1,0x000114C8,0x85E95675,0x8BFE82CF,0x245590F1,0x04429358,0xFFFC0528,0x04C2917D,0xEB055AB5,0xF339D113,0xC480C25D,0x0000D5BC,0xC359DF61,0x5555E7D1,
  167.     0x0005BC50,0xC48014C4,0xFFFE84EC,0xF673CCBC,0x002590B5,0x8B011B94,0x8BEB92EF,0xE8C692CC,0xFFFE78B0,0xC48A6361,0xD78A524D,0xFFFC3244,0x8BD59209,0x008A3AB6,0x8B24D065,0xFEB772F9,
  168.     0xC48A7FF9,0xFFFD73EC,0x8BD99331,0x8BCA9378,0xFF2F7233,0xC48A7F4D,0x445778C8,0x04C59A6B,0x5D011900,0xC359DF9D,0x53ED937B,0x8308DEE9,0x07741985,0xFFFE9C5C,0x83028581,0x5D5A1FE9,
  169.     0x90011C5E,0x8355D269,0xFA80702C,0x0001228C,0x008A9CB9,0xDA8A1FD4,0x4B18D7DD,0x05017663,0x7D721F00,0x8D18CF41,0x5889CD7C,0x9375ABB4,0x74F79C84,0x4051A718,0x0424D25F,0x4A04D3B9,
  170.     0xFF8477E5,0xC745D6D8,0x0001422C,0x148A1DCC,0x5215A8D4,0x8D08DB11,0x7A82888C,0x12741D58,0x0424E995,0x8B5328F7,0xE80FA067,0xFFFE7434,0x7A8244B5,0x117423B0,0x7508EACD,0xD189D270,
  171.     0x61E92225,0xEBFE729D,0x047BA6D0,0x520CE8F2,0x0E8A54B5,0xFFFDE23C,0xFF078DE1,0x754E3898,0x5F5ADC2B,0x90C1DDDE,0x22238D38,0xC4824732,0xC08A6614,0x8B55CF59,0xE8C6ACC0,0xFFFE70D4,
  172.     0x11BA7665,0x831016EB,0x74FE1DBD,0x01FEA4FA,0xFF81CAE4,0x8903E918,0x4BEA3235,0x742177A1,0x2120BECB,0x00C645BB,0x000126B7,0x438A3D09,0x1842338C,0x73882EE7,0xEBF732D8,0x1C422ADA,
  173.     0x21BB1AB3,0xC720405B,0x00012056,0x18422B8C,0x433A1C22,0x8B10FDA8,0x8BD19AB2,0xFEE37821,0x73887519,0x8BF732A4,0x5B5ED50A,0x00419B91,0x212023D1,0x000142EB,0x23E821D8,0xC3224021,
  174.     0x212037DD,0x7401421B,0x22237A2B,0x448A40D2,0x5DE92ED4,0xC3FE74CD,0xFFFE6B21,0xFFFE6B05
  175. }
  176. static  EntryPoint1_Offset = 0x000001C4
  177. static  EntryPoint2_Offset = 0x000004B0
  178. static  EntryPoint3_Offset = 0x000004C0
  179.  
  180.  
  181.  
  182.  
  183. #define OS_BAD      0
  184. #define OS_WINDOWS  1
  185. #define OS_LINUX    2
  186.  
  187. static OS = OS_BAD
  188. static PE_Base = 0
  189. static MODULE_SIZE = 0
  190.  
  191. static IF_RESTART = false
  192. static CURR_PATH_FILE[1024]
  193. static ENGINE_BASE = 0
  194. static ENGINE_END = 20*1024*1024
  195. static Malloc_Base = 0
  196. static WriteByteAddr = 0
  197. static OrpheuFunction:o_Malloc
  198. static OrpheuFunction:o_wByte
  199. static SV_SendResources = 0
  200. static Resources_Base = 0
  201. static CountResources_Base = 0
  202. static SomeTotalValue_Base = 0
  203. static SV_ParseConsistencyResponse = 0
  204. static Cbuf_AddText = 0
  205. static MSG_ReadBits = 0
  206. static MSG_WriteBits = 0
  207. static WriteByteProcess = false
  208.  
  209. static global_host_client = 0
  210. static ServerCount_Base = 0
  211. static First_FileName[ 1024 ]
  212. static DownloadSiteEnabled = false
  213. static DownloadSite[ 4096 ] = ""
  214.  
  215. static ScriptsCount = 0
  216. static Scripts_Base = 0
  217. static ScriptFilesCount = 0
  218. static ScriptFiles_Base = 0
  219.  
  220. static REOURCE_COUNT_MAX        =   0x500
  221. static REOURCE_ITEM_SIZE        =   0x88
  222. static CONS_DATA_COUNT_MAX      =   0x200
  223.  
  224. #define MAX_SCRIPTS 1024
  225. #define MAX_FILES   0x200
  226. #define SI_NORMAL   0
  227. #define SI_INVERT   1
  228. #define SM_PREV     0
  229. #define SM_CONST    1
  230. #define SM_ALL      2
  231.  
  232. /*
  233.  
  234. Need:
  235.  
  236.     functions:
  237.         SV_SendResources                -   absolute addr
  238.         SV_ParseConsistencyResponse     -   absolute addr
  239.         MSG_ReadBits                    -   absolute addr
  240.         Cbuf_AddText                    -   absolute addr
  241.  
  242.     vars:
  243.         ServerCount                     -   absolute addr
  244.         *global_host_client             -   absolute addr
  245.         offset_PlayerName               -   DWord[win./lin.]
  246.         offset_IfConsiData              -   DWord[win./lin.]
  247.         resources_list                  -   absolute addr
  248.  
  249. */
  250.  
  251. static Developer = true
  252. stock GetDWordHex( W ) {
  253.  
  254.     static HexTable[256][2] = {
  255.         { 0x30 , 0x30 } , { 0x30 , 0x31 } , { 0x30 , 0x32 } , { 0x30 , 0x33 } , { 0x30 , 0x34 } , { 0x30 , 0x35 } , { 0x30 , 0x36 } , { 0x30 , 0x37 } , { 0x30 , 0x38 } , { 0x30 , 0x39 } , { 0x30 , 0x41 } , { 0x30 , 0x42 } , { 0x30 , 0x43 } , { 0x30 , 0x44 } , { 0x30 , 0x45 } , { 0x30 , 0x46 } ,
  256.         { 0x31 , 0x30 } , { 0x31 , 0x31 } , { 0x31 , 0x32 } , { 0x31 , 0x33 } , { 0x31 , 0x34 } , { 0x31 , 0x35 } , { 0x31 , 0x36 } , { 0x31 , 0x37 } , { 0x31 , 0x38 } , { 0x31 , 0x39 } , { 0x31 , 0x41 } , { 0x31 , 0x42 } , { 0x31 , 0x43 } , { 0x31 , 0x44 } , { 0x31 , 0x45 } , { 0x31 , 0x46 } ,
  257.         { 0x32 , 0x30 } , { 0x32 , 0x31 } , { 0x32 , 0x32 } , { 0x32 , 0x33 } , { 0x32 , 0x34 } , { 0x32 , 0x35 } , { 0x32 , 0x36 } , { 0x32 , 0x37 } , { 0x32 , 0x38 } , { 0x32 , 0x39 } , { 0x32 , 0x41 } , { 0x32 , 0x42 } , { 0x32 , 0x43 } , { 0x32 , 0x44 } , { 0x32 , 0x45 } , { 0x32 , 0x46 } ,
  258.         { 0x33 , 0x30 } , { 0x33 , 0x31 } , { 0x33 , 0x32 } , { 0x33 , 0x33 } , { 0x33 , 0x34 } , { 0x33 , 0x35 } , { 0x33 , 0x36 } , { 0x33 , 0x37 } , { 0x33 , 0x38 } , { 0x33 , 0x39 } , { 0x33 , 0x41 } , { 0x33 , 0x42 } , { 0x33 , 0x43 } , { 0x33 , 0x44 } , { 0x33 , 0x45 } , { 0x33 , 0x46 } ,
  259.        
  260.         { 0x34 , 0x30 } , { 0x34 , 0x31 } , { 0x34 , 0x32 } , { 0x34 , 0x33 } , { 0x34 , 0x34 } , { 0x34 , 0x35 } , { 0x34 , 0x36 } , { 0x34 , 0x37 } , { 0x34 , 0x38 } , { 0x34 , 0x39 } , { 0x34 , 0x41 } , { 0x34 , 0x42 } , { 0x34 , 0x43 } , { 0x34 , 0x44 } , { 0x34 , 0x45 } , { 0x34 , 0x46 } ,
  261.         { 0x35 , 0x30 } , { 0x35 , 0x31 } , { 0x35 , 0x32 } , { 0x35 , 0x33 } , { 0x35 , 0x34 } , { 0x35 , 0x35 } , { 0x35 , 0x36 } , { 0x35 , 0x37 } , { 0x35 , 0x38 } , { 0x35 , 0x39 } , { 0x35 , 0x41 } , { 0x35 , 0x42 } , { 0x35 , 0x43 } , { 0x35 , 0x44 } , { 0x35 , 0x45 } , { 0x35 , 0x46 } ,
  262.         { 0x36 , 0x30 } , { 0x36 , 0x31 } , { 0x36 , 0x32 } , { 0x36 , 0x33 } , { 0x36 , 0x34 } , { 0x36 , 0x35 } , { 0x36 , 0x36 } , { 0x36 , 0x37 } , { 0x36 , 0x38 } , { 0x36 , 0x39 } , { 0x36 , 0x41 } , { 0x36 , 0x42 } , { 0x36 , 0x43 } , { 0x36 , 0x44 } , { 0x36 , 0x45 } , { 0x36 , 0x46 } ,
  263.         { 0x37 , 0x30 } , { 0x37 , 0x31 } , { 0x37 , 0x32 } , { 0x37 , 0x33 } , { 0x37 , 0x34 } , { 0x37 , 0x35 } , { 0x37 , 0x36 } , { 0x37 , 0x37 } , { 0x37 , 0x38 } , { 0x37 , 0x39 } , { 0x37 , 0x41 } , { 0x37 , 0x42 } , { 0x37 , 0x43 } , { 0x37 , 0x44 } , { 0x37 , 0x45 } , { 0x37 , 0x46 } ,
  264.        
  265.         { 0x38 , 0x30 } , { 0x38 , 0x31 } , { 0x38 , 0x32 } , { 0x38 , 0x33 } , { 0x38 , 0x34 } , { 0x38 , 0x35 } , { 0x38 , 0x36 } , { 0x38 , 0x37 } , { 0x38 , 0x38 } , { 0x38 , 0x39 } , { 0x38 , 0x41 } , { 0x38 , 0x42 } , { 0x38 , 0x43 } , { 0x38 , 0x44 } , { 0x38 , 0x45 } , { 0x38 , 0x46 } ,
  266.         { 0x39 , 0x30 } , { 0x39 , 0x31 } , { 0x39 , 0x32 } , { 0x39 , 0x33 } , { 0x39 , 0x34 } , { 0x39 , 0x35 } , { 0x39 , 0x36 } , { 0x39 , 0x37 } , { 0x39 , 0x38 } , { 0x39 , 0x39 } , { 0x39 , 0x41 } , { 0x39 , 0x42 } , { 0x39 , 0x43 } , { 0x39 , 0x44 } , { 0x39 , 0x45 } , { 0x39 , 0x46 } ,
  267.         { 0x41 , 0x30 } , { 0x41 , 0x31 } , { 0x41 , 0x32 } , { 0x41 , 0x33 } , { 0x41 , 0x34 } , { 0x41 , 0x35 } , { 0x41 , 0x36 } , { 0x41 , 0x37 } , { 0x41 , 0x38 } , { 0x41 , 0x39 } , { 0x41 , 0x41 } , { 0x41 , 0x42 } , { 0x41 , 0x43 } , { 0x41 , 0x44 } , { 0x41 , 0x45 } , { 0x41 , 0x46 } ,
  268.         { 0x42 , 0x30 } , { 0x42 , 0x31 } , { 0x42 , 0x32 } , { 0x42 , 0x33 } , { 0x42 , 0x34 } , { 0x42 , 0x35 } , { 0x42 , 0x36 } , { 0x42 , 0x37 } , { 0x42 , 0x38 } , { 0x42 , 0x39 } , { 0x42 , 0x41 } , { 0x42 , 0x42 } , { 0x42 , 0x43 } , { 0x42 , 0x44 } , { 0x42 , 0x45 } , { 0x42 , 0x46 } ,
  269.        
  270.         { 0x43 , 0x30 } , { 0x43 , 0x31 } , { 0x43 , 0x32 } , { 0x43 , 0x33 } , { 0x43 , 0x34 } , { 0x43 , 0x35 } , { 0x43 , 0x36 } , { 0x43 , 0x37 } , { 0x43 , 0x38 } , { 0x43 , 0x39 } , { 0x43 , 0x41 } , { 0x43 , 0x42 } , { 0x43 , 0x43 } , { 0x43 , 0x44 } , { 0x43 , 0x45 } , { 0x43 , 0x46 } ,
  271.         { 0x44 , 0x30 } , { 0x44 , 0x31 } , { 0x44 , 0x32 } , { 0x44 , 0x33 } , { 0x44 , 0x34 } , { 0x44 , 0x35 } , { 0x44 , 0x36 } , { 0x44 , 0x37 } , { 0x44 , 0x38 } , { 0x44 , 0x39 } , { 0x44 , 0x41 } , { 0x44 , 0x42 } , { 0x44 , 0x43 } , { 0x44 , 0x44 } , { 0x44 , 0x45 } , { 0x44 , 0x46 } ,
  272.         { 0x45 , 0x30 } , { 0x45 , 0x31 } , { 0x45 , 0x32 } , { 0x45 , 0x33 } , { 0x45 , 0x34 } , { 0x45 , 0x35 } , { 0x45 , 0x36 } , { 0x45 , 0x37 } , { 0x45 , 0x38 } , { 0x45 , 0x39 } , { 0x45 , 0x41 } , { 0x45 , 0x42 } , { 0x45 , 0x43 } , { 0x45 , 0x44 } , { 0x45 , 0x45 } , { 0x45 , 0x46 } ,
  273.         { 0x46 , 0x30 } , { 0x46 , 0x31 } , { 0x46 , 0x32 } , { 0x46 , 0x33 } , { 0x46 , 0x34 } , { 0x46 , 0x35 } , { 0x46 , 0x36 } , { 0x46 , 0x37 } , { 0x46 , 0x38 } , { 0x46 , 0x39 } , { 0x46 , 0x41 } , { 0x46 , 0x42 } , { 0x46 , 0x43 } , { 0x46 , 0x44 } , { 0x46 , 0x45 } , { 0x46 , 0x46 }  
  274.     }
  275.  
  276.     static Result[9]
  277.     new id
  278.    
  279.     id = ( W >> 24  ) & 0xFF
  280.     Result[0] = HexTable[ id ][0]
  281.     Result[1] = HexTable[ id ][1]
  282.    
  283.     id = ( W >> 16  ) & 0xFF
  284.     Result[2] = HexTable[ id ][0]
  285.     Result[3] = HexTable[ id ][1]
  286.    
  287.     id = ( W >> 8  ) & 0xFF
  288.     Result[4] = HexTable[ id ][0]
  289.     Result[5] = HexTable[ id ][1]
  290.    
  291.     id = W & 0xFF
  292.     Result[6] = HexTable[ id ][0]
  293.     Result[7] = HexTable[ id ][1]
  294.    
  295.     Result[8] = 0
  296.  
  297.     return Result
  298.  
  299. }
  300. stock MSG_Print( msg[] ) {
  301.  
  302.     server_print( "%s%s" , CONSOLE_PRINT_PREFIX , msg )
  303.  
  304. }
  305. stock MSG_Error( msg[] ) {
  306.  
  307.     server_print( "%s%s%s" , CONSOLE_PRINT_PREFIX , CONSOLE_PRINT_ERROR_PREFIX , msg )
  308.  
  309. }
  310. stock MSG_ShowAddr( name[] , Addr ) {
  311.  
  312.     if ( !( Developer ) )
  313.        
  314.         return
  315.  
  316.     static temp[ 4096 ]
  317.  
  318.     new len = strlen( name )
  319.  
  320.     new mt = 4
  321.    
  322.     if ( len < 32 )
  323.  
  324.         mt += 32 - len
  325.  
  326.     static mtable[] = " ."
  327.  
  328.     new i
  329.    
  330.     for( i = 0; i < mt; i++ )
  331.    
  332.         temp[ i ] = mtable[ i & 1 ]
  333.  
  334.     temp[ mt ] = 0
  335.  
  336.     server_print( "%s >>> %s: %s 0x%s" , CONSOLE_PRINT_PREFIX , name , temp , GetDWordHex( Addr ) )
  337.  
  338. }
  339.  
  340. public plugin_precache() {
  341.  
  342.     register_plugin (   PLUGIN_NAME     ,   PLUGIN_VERSION          ,   PLUGIN_AUTHOR   )
  343.  
  344.     MSG_Print( "Loaded..." )
  345.  
  346.     TryConfig()
  347.  
  348.     read_function_init()
  349.    
  350.     return PLUGIN_CONTINUE
  351.  
  352. }
  353. public plugin_init() {
  354.  
  355.     TryRestart( true )
  356.  
  357. }
  358. public plugin_end() {
  359.  
  360.     DeatchAllEngineHook()
  361.    
  362.     Detours_DeatchAll()
  363.  
  364. }
  365.  
  366.  
  367.  
  368. stock OS_Init() {
  369.  
  370.     if ( ( rByte( ENGINE_BASE ) == 0x4D ) && (  rByte( ENGINE_BASE + 1 ) == 0x5A ) ) {  //  Dos MZ
  371.  
  372.         OS = OS_WINDOWS
  373.  
  374.         PE_Base = ENGINE_BASE + rDWord( ENGINE_BASE + 0x3C )
  375.  
  376.         MODULE_SIZE = rDWord( PE_Base + 0x50 )  //  SizeOfImage
  377.        
  378.         ENGINE_END = ENGINE_BASE + MODULE_SIZE - 64
  379.  
  380.         return true
  381.  
  382.     }
  383.  
  384.     if ( rDWord( ENGINE_BASE ) == 0x464C457F ) {    //  Linux \x7F + ELF
  385.  
  386.         OS = OS_LINUX
  387.  
  388.         return true
  389.  
  390.     }
  391.    
  392.     OS = OS_BAD
  393.    
  394.     return false
  395.  
  396. }
  397. stock TryConfig() {
  398.  
  399.     if ( file_exists(CONFIG_PATH) )
  400.    
  401.         return false
  402.  
  403.     new F = fopen( CONFIG_PATH , "w" )
  404.    
  405.     fputs( F , CONFIG_SAVE )
  406.  
  407.     fclose( F )
  408.    
  409.     IF_RESTART = true
  410.  
  411.     return true
  412.  
  413. }
  414. stock TryRestart( show = false ) {
  415.  
  416.     if ( IF_RESTART ) {
  417.  
  418.         if ( show )
  419.        
  420.             MSG_Print( "Restart..." )
  421.  
  422.         server_cmd( "restart" )
  423.        
  424.         return true
  425.  
  426.     }
  427.    
  428.     return false
  429.  
  430. }
  431. stock SetEngine() {
  432.  
  433.     ENGINE_BASE = OrpheuGetAddr( ORPHEU_NAME_ENGINE_BASE )
  434.  
  435.     ENGINE_END += ENGINE_BASE
  436.  
  437. }
  438. stock TryOS() {
  439.  
  440.     if ( OS == OS_BAD ) {
  441.    
  442.         MSG_Error( "Unknown operating system" )
  443.    
  444.         return true
  445.    
  446.     }
  447.    
  448.     return false
  449.  
  450. }
  451. stock read_function_init() {
  452.  
  453. /*    ######################################    EngineBase Begin    ######################################    */
  454.     create_function_get_addr_eng( ORPHEU_NAME_ENGINE_BASE , ORPHEU_PATTERN_ENGINE_BASE , ORPHEU_PATTERN_ENGINE_BASE )
  455. /*     ######################################    EngineBase End    ######################################     */
  456.    
  457.     if ( TryRestart() )
  458.        
  459.         return
  460.  
  461.     SetEngine()
  462.  
  463.     OS_Init()
  464.    
  465.     if ( TryOS() )
  466.    
  467.         return
  468.  
  469.  
  470.  
  471. /*    ######################################    WriteByteEng Begin    ######################################    */
  472.     create_memory_eng_byte( ORPHEU_NAME_WRITE_BYTE_ENG , ORPHEU_PATTERN_WRITE_BYTE_ENG , ORPHEU_PATTERN_WRITE_BYTE_ENG )
  473. /*     ######################################    WriteByteEng End    ######################################     */
  474.    
  475. /*    ######################################    WriteByte Begin    ######################################    */
  476.     create_function_eng( ORPHEU_NAME_WRITE_BYTE , ORPHEU_ARGV_WRITE_BYTE , ORPHEU_RET_WRITE_BYTE , ORPHEU_PATTERN_WRITE_BYTE , ORPHEU_PATTERN_WRITE_BYTE )
  477. /*     ######################################    WriteByte End    ######################################     */
  478.  
  479. /*    ######################################    Malloc Begin    ######################################    */
  480.     create_function_eng_empty( ORPHEU_NAME_MALLOC_WIN , ORPHEU_ARGV_MALLOC , ORPHEU_RET_MALLOC )
  481.     create_function_eng( ORPHEU_NAME_MALLOC_LIN , ORPHEU_ARGV_MALLOC , ORPHEU_RET_MALLOC , ORPHEU_PATTERN_MALLOC_W , ORPHEU_PATTERN_MALLOC_L )
  482. /*    ######################################    Malloc End    ######################################    */
  483.  
  484. /*    ######################################    Cbuf_AddText Begin    ######################################    */
  485.     create_function_get_addr_eng( ORPHEU_NAME_CBUF_ADDTEXT , ORPHEU_PATTERN_CBUF_ADDTEXT_W , ORPHEU_PATTERN_CBUF_ADDTEXT_L )
  486. /*     ######################################    Cbuf_AddText End    ######################################     */
  487.  
  488. /*    ######################################    SV_ParseConsistencyResponse Begin    ######################################    */
  489.     create_function_get_addr_eng( ORPHEU_NAME_SV_PARSECONS , ORPHEU_PATTERN_SV_PARSECONS_W , ORPHEU_PATTERN_SV_PARSECONS_L )
  490. /*     ######################################    SV_ParseConsistencyResponse End    ######################################     */
  491.  
  492. /*    ######################################    SV_SendResources Begin    ######################################    */
  493.     create_function_get_addr_eng( ORPHEU_NAME_SV_SENDRES , ORPHEU_PATTERN_SV_SENDRES_W , ORPHEU_PATTERN_SV_SENDRES_L )
  494. /*     ######################################    SV_SendResources End    ######################################     */
  495.  
  496. /*    ######################################    MSG_ReadBits Begin    ######################################    */
  497.     create_function_get_addr_eng( ORPHEU_NAME_MSG_READBITS , ORPHEU_PATTERN_MSG_READBITS_W , ORPHEU_PATTERN_MSG_READBITS_L )
  498. /*     ######################################    MSG_ReadBits End    ######################################     */
  499.  
  500. /*    ######################################    MSG_WriteBits Begin    ######################################    */
  501.     create_function_get_addr_eng( ORPHEU_NAME_MSG_WRITEBITS , ORPHEU_PATTERN_MSG_WRITEBITS_W , ORPHEU_PATTERN_MSG_WRITEBITS_L )
  502. /*     ######################################    MSG_WriteBits End    ######################################     */
  503.  
  504. /*    ######################################    MSG_WriteBits Begin    ######################################    */
  505.     create_function_get_addr_eng( ORPHEU_NAME_SV_REQ_MISS , ORPHEU_PATTERN_SV_REQ_MISS_W , ORPHEU_PATTERN_SV_REQ_MISS_L )
  506. /*     ######################################    MSG_WriteBits End    ######################################     */
  507.  
  508.  
  509.     if ( TryRestart() )
  510.  
  511.         return
  512.  
  513.     if ( Main() ) {
  514.  
  515.         MSG_Print( "Is Loaded..." )
  516.  
  517.     } else
  518.  
  519.         MSG_Error( "Main function error" )
  520.  
  521.     return
  522.  
  523. }
  524.  
  525. static CurrJSON[ 4096 ]
  526. stock create_memory_eng( name[] , m_type[] , pattern_win[] , pattern_lin[] ) {
  527.    
  528.     format( CURR_PATH_FILE , sizeof(CURR_PATH_FILE)-1 , "%s%s" , ORPHEU_MEMORY_PATH , name )
  529.  
  530.     if ( file_exists(CURR_PATH_FILE) )
  531.    
  532.         return false
  533.    
  534.     format( CurrJSON , sizeof(CurrJSON)-1 , "{^n^t^"name^"^t^t^t:^t^"%s^",^n^t^"library^"^t^t:^t^"engine^",^n^t^"type^"^t^t^t:^t^"%s^",^n^t^"memoryType^"^t:^t^"data^",^n^t^"identifiers^"^t:^n^t[^n^t^t{^n^t^t^t^"os^"^t:^t^"windows^",^n^t^t^t^"mod^"^t:^t^"cstrike^",^n^t^t^t^"value^"^t:^t%s^n^t^t},^n^t^t{^n^t^t^t^"os^"^t:^t^"linux^",^n^t^t^t^"mod^"^t:^t^"cstrike^",^n^t^t^t^"value^"^t:^t%s^n^t^t}^n^t]^n}" , name , m_type , pattern_win , pattern_lin )
  535.  
  536.     new F = fopen( CURR_PATH_FILE , "at" )
  537.  
  538.     fputs( F , CurrJSON )
  539.  
  540.     fclose( F )
  541.    
  542.     IF_RESTART = true
  543.    
  544.     return true
  545.  
  546. }
  547. stock create_memory_eng_string( name[] , pattern_win[] , pattern_lin[] ) {
  548.    
  549.     return create_memory_eng( name , "string" , pattern_win , pattern_lin )
  550.  
  551. }
  552. stock create_memory_eng_long( name[] , pattern_win[] , pattern_lin[] ) {
  553.    
  554.     return create_memory_eng( name , "long" , pattern_win , pattern_lin )
  555.  
  556. }
  557. stock create_memory_eng_byte( name[] , pattern_win[] , pattern_lin[] ) {
  558.    
  559.     return create_memory_eng( name , "byte" , pattern_win , pattern_lin )
  560.  
  561. }
  562. stock create_memory_eng_byte_empty( name[] ) {
  563.  
  564.     format( CURR_PATH_FILE , sizeof(CURR_PATH_FILE)-1 , "%s%s" , ORPHEU_MEMORY_PATH , name )
  565.  
  566.     if ( file_exists(CURR_PATH_FILE) )
  567.    
  568.         return false
  569.    
  570.     format( CurrJSON , sizeof(CurrJSON)-1 , "{^n^t^"name^"^t^t^t:^t^"%s^",^n^t^"library^"^t^t:^t^"engine^",^n^t^"type^"^t^t^t:^t^"byte^",^n^t^"memoryType^"^t:^t^"data^",^n^t^"identifiers^"^t:^n^t[^n^t^t{^n^t^t^t^"os^"^t:^t^"windows^"^n^t^t},^n^t^t{^n^t^t^t^"os^"^t:^t^"linux^"^n^t^t}^n^t]^n}" , name )
  571.  
  572.     new F = fopen( CURR_PATH_FILE , "at" )
  573.  
  574.     fputs( F , CurrJSON )
  575.  
  576.     fclose( F )
  577.    
  578.     IF_RESTART = true
  579.    
  580.     return true
  581.  
  582. }
  583. stock create_function_eng( name[] , argv[] , ret[] , pattern_win[] , pattern_lin[] ) {
  584.    
  585.     format( CURR_PATH_FILE , sizeof(CURR_PATH_FILE)-1 , "%s%s" , ORPHEU_FUNCTIONS_PATH , name )
  586.  
  587.     if ( file_exists(CURR_PATH_FILE) )
  588.    
  589.         return false
  590.  
  591.     format( CurrJSON , sizeof(CurrJSON)-1 , "{^n^t^"name^"^t^t^t:^t^"%s^",^n^t^"library^"^t^t:^t^"engine^",^n^t^"arguments^"^t:^n^t[^n^t^t%s^n^t],^n^t^"return^"^t:^n^t{^n^t^t^"type^"^t:^t^"%s^"^n^t},^n^t^"identifiers^"^t:^n^t[^n^t^t{^n^t^t^t^"os^"^t:^t^"windows^",^n^t^t^t^"value^"^t:^t%s^n^t^t},^n^t^t{^n^t^t^t^"os^"^t:^t^"linux^",^n^t^t^t^"value^"^t:^t%s^n^t^t}^n^t]^n}" , name , argv , ret , pattern_win , pattern_lin )
  592.  
  593.     new F = fopen( CURR_PATH_FILE , "at" )
  594.  
  595.     fputs( F , CurrJSON )
  596.  
  597.     fclose( F )
  598.    
  599.     IF_RESTART = true
  600.    
  601.     return true
  602.  
  603. }
  604. stock create_function_eng_empty( name[] , argv[] , ret[] ) {
  605.    
  606.     format( CURR_PATH_FILE , sizeof(CURR_PATH_FILE)-1 , "%s%s" , ORPHEU_FUNCTIONS_PATH , name )
  607.  
  608.     if ( file_exists(CURR_PATH_FILE) )
  609.    
  610.         return false
  611.  
  612.     format( CurrJSON , sizeof(CurrJSON)-1 , "{^n^t^"name^"^t^t^t:^t^"%s^",^n^t^"library^"^t^t:^t^"engine^",^n^t^"arguments^"^t:^n^t[^n^t^t%s^n^t],^n^t^"return^"^t:^n^t{^n^t^t^"type^"^t:^t^"%s^"^n^t}^n}" , name , argv , ret )
  613.  
  614.     new F = fopen( CURR_PATH_FILE , "at" )
  615.  
  616.     fputs( F , CurrJSON )
  617.  
  618.     fclose( F )
  619.    
  620.     IF_RESTART = true
  621.    
  622.     return true
  623.  
  624. }
  625. stock create_function_get_addr_eng( name[] , pattern_win[] = "" , pattern_lin[] = "" ) {
  626.    
  627.     format( CURR_PATH_FILE , sizeof(CURR_PATH_FILE)-1 , "%s%s" , ORPHEU_FUNCTIONS_PATH , name )
  628.  
  629.     if ( file_exists(CURR_PATH_FILE) )
  630.    
  631.         return false
  632.    
  633.     format( CurrJSON , sizeof(CurrJSON)-1 , "{^n^t^"name^"^t^t^t:^t^"%s^",^n^t^"library^"^t^t:^t^"engine^",^n^t^"identifiers^"^t:^n^t[^n^t^t{^n^t^t^t^"os^"^t:^t^"windows^",^n^t^t^t^"value^"^t:^t%s^n^t^t},^n^t^t{^n^t^t^t^"os^"^t:^t^"linux^",^n^t^t^t^"value^"^t:^t%s^n^t^t}^n^t]^n}" , name , pattern_win , pattern_lin )
  634.  
  635.     new F = fopen( CURR_PATH_FILE , "at" )
  636.  
  637.     fputs( F , CurrJSON )
  638.  
  639.     fclose( F )
  640.    
  641.     IF_RESTART = true
  642.    
  643.     return true
  644.  
  645. }
  646.  
  647. stock OrpheuGetAddr( name[] ) {
  648.  
  649.     new OrpheuFunction:func = OrpheuGetFunction( name )
  650.  
  651.     new func_addr = OrpheuGetFunctionAddress( func )
  652.  
  653.     return func_addr
  654.  
  655. }
  656.  
  657. stock rByte( addr ) {
  658.  
  659.     static byte[1]
  660.    
  661.     OrpheuGetBytesAtAddress( addr , byte , 1 )
  662.  
  663.     return byte[0]
  664.  
  665. }
  666. stock rWord( addr ) {
  667.  
  668.     static byte[2]
  669.    
  670.     OrpheuGetBytesAtAddress( addr , byte , 2 )
  671.  
  672.     return ( byte[0] | ( byte[1] << 8 ) )
  673.  
  674. }
  675. stock rDWord( addr ) {
  676.  
  677.     static byte[4]
  678.    
  679.     OrpheuGetBytesAtAddress( addr , byte , 4 )
  680.  
  681.     return ( byte[0] | ( byte[1] << 8 ) | ( byte[2] << 16 ) | ( byte[3] << 24 ) )
  682.  
  683. }
  684. stock wByte( addr , data ) {
  685.    
  686.     if ( WriteByteProcess )
  687.        
  688.         OrpheuCall( o_wByte , addr , data & 0xFF )
  689.    
  690.     else {
  691.    
  692.         SetByteWriteByte()
  693.    
  694.         OrpheuCall( o_wByte , addr , data & 0xFF )
  695.    
  696.         UnSetByteWriteByte()
  697.  
  698.     }
  699.  
  700. }
  701. stock wWord( addr , data ) {
  702.  
  703.     wByte( addr     , data      )
  704.     wByte( addr + 1 , data >> 8 )
  705.  
  706. }
  707. stock wDWord( addr , data ) {
  708.  
  709.     wByte( addr     , data       )
  710.     wByte( addr + 1 , data >> 8  )
  711.     wByte( addr + 2 , data >> 16 )
  712.     wByte( addr + 3 , data >> 24 )
  713.  
  714. }
  715. stock wPString( addr , data[] ) {
  716.  
  717.     new len = strlen( data )
  718.    
  719.     new i = 0
  720.    
  721.     for ( i = 0; i <= len; i++ )
  722.    
  723.         wByte( addr + i , data[i] )
  724.  
  725. }
  726. stock wByteEng( addr , data ) {
  727.  
  728.     OrpheuMemorySetAtAddress( addr , ORPHEU_NAME_WRITE_BYTE_ENG , 1 , data & 0xFF )
  729.  
  730. }
  731. stock wWordEng( addr , data ) {
  732.  
  733.     wByteEng( addr     , data      )
  734.     wByteEng( addr + 1 , data >> 8 )
  735.  
  736. }
  737. stock wDWordEng( addr , data ) {
  738.  
  739.     wByteEng( addr     , data       )
  740.     wByteEng( addr + 1 , data >> 8  )
  741.     wByteEng( addr + 2 , data >> 16 )
  742.     wByteEng( addr + 3 , data >> 24 )
  743.  
  744. }
  745. stock wPStringEng( addr , data[] ) {
  746.  
  747.     new len = strlen( data )
  748.    
  749.     new i = 0
  750.    
  751.     for ( i = 0; i <= len; i++ )
  752.    
  753.         wByteEng( addr + i , data[i] )
  754.  
  755. }
  756.  
  757. enum code_t {
  758.     code_t_base ,
  759.     code_t_size
  760. }
  761. static CurrCode[ code_t ]
  762. stock WriteCode( Code[] , size_memory ) {
  763.  
  764.     new Base = Malloc( ( ( 1 << 16 ) * 2 ) + size_memory * 4 )
  765.    
  766.     if ( Base == 0 ) {
  767.  
  768.         NewError( "WriteCode memory is null" )
  769.  
  770.         return 0
  771.  
  772.     }
  773.    
  774.     Base += ( 1 << 16 )
  775.  
  776.     new i
  777.    
  778.     for ( i = 0; i < size_memory; i++ )
  779.    
  780.         wDWord( Base + i*4 , ( ( Code[i] ^ (i*4) ) + 13523 ) ^ ( ( (i*4) << 3 ) + 78963 ) )
  781.  
  782.     CurrCode[ code_t_base ] = Base
  783.     CurrCode[ code_t_size ] = size_memory * 4
  784.  
  785.     return Base
  786.  
  787. }
  788. stock ReplaceCodeDWord( OldData , NewData , Count = 256 ) {
  789.  
  790.     return ReplaceMemoryDWord( CurrCode[ code_t_base ] , CurrCode[ code_t_size ] , OldData , NewData , Count )
  791.  
  792. }
  793. stock ReplaceCodeRelative( Search , AbsoluteAddr , Count = 256 ) {
  794.  
  795.     new i
  796.     new predel = CurrCode[ code_t_base ] + CurrCode[ code_t_size ] - 4
  797.    
  798.     new ss = 0
  799.    
  800.     for( i = CurrCode[ code_t_base ]; i <= predel; i++ )
  801.    
  802.         if ( rDWord( i ) == Search ) {
  803.  
  804.             wDWord( i , AbsoluteAddr - i - 4 )
  805.  
  806.             ss++
  807.            
  808.             if ( ss >= Count )
  809.            
  810.                 return ss
  811.  
  812.         }
  813.  
  814.     return ss
  815.  
  816. }
  817. stock FindCodeDWord( Search , Offset = 0 ) {
  818.  
  819.     new i
  820.     new predel = CurrCode[ code_t_base ] + CurrCode[ code_t_size ] - 4
  821.    
  822.     for( i = CurrCode[ code_t_base ]; i <= predel; i++ )
  823.    
  824.         if ( rDWord( i ) == Search )
  825.        
  826.             return i + Offset
  827.            
  828.     return 0
  829.  
  830. }
  831. stock FindCode( Pattern[] , SizePattern , Offset = 0 ) {
  832.  
  833.     return Find( CurrCode[ code_t_base ] , CurrCode[ code_t_base ] + CurrCode[ code_t_size ] , Pattern , SizePattern , Offset )
  834.  
  835. }
  836.  
  837. #define MAX_DWORDS  1024
  838. static DWordsAllocSize = 0
  839. static DWordsCursor = 0
  840. static DWordsList[ MAX_DWORDS ]
  841. stock ResetDWord( AllocSize = 0 ) {
  842.  
  843.     DWordsCursor = 0
  844.    
  845.     DWordsAllocSize = AllocSize
  846.  
  847. }
  848. stock AddDWord( dw ) {
  849.  
  850.     if ( DWordsCursor >= MAX_DWORDS ) {
  851.    
  852.         MSG_Print( "DWordsList is full" )
  853.    
  854.         return false
  855.    
  856.     }
  857.  
  858.     DWordsList[ DWordsCursor++ ] = dw
  859.  
  860.     return true
  861.    
  862. }
  863. stock AddImmortalPString( Str[] ) {
  864.  
  865.     new Mem = GetImmortalPString( Str )
  866.    
  867.     if ( Mem == 0 )
  868.    
  869.         return false
  870.    
  871.     AddDWord( Mem )
  872.  
  873.     return true
  874.    
  875. }
  876. stock CreateStruct() {
  877.  
  878.     new MemSize = DWordsCursor * 4
  879.    
  880.     if ( MemSize < DWordsAllocSize )
  881.  
  882.         MemSize = DWordsAllocSize
  883.    
  884.     new Base = Malloc( MemSize )
  885.    
  886.     if ( Base == 0 )
  887.    
  888.         return 0
  889.  
  890.     new i
  891.    
  892.     for( i = 0; i < DWordsCursor; i++ )
  893.    
  894.         wDWord( Base + i*4 , DWordsList[ i ] )
  895.  
  896.     return Base
  897.  
  898. }
  899.  
  900. stock GetImmortalPString( Str[] ) {
  901.  
  902.     new Base = Malloc( strlen(Str) + 1 )
  903.    
  904.     if ( Base == 0 )
  905.    
  906.         return 0
  907.    
  908.     wPString( Base , Str )
  909.    
  910.     return Base
  911.  
  912. }
  913. stock GetImmortalDWord( dw ) {
  914.  
  915.     new Base = Malloc( 4 )
  916.    
  917.     if ( Base == 0 )
  918.    
  919.         return 0
  920.    
  921.     wDWord( Base , dw )
  922.    
  923.     return Base
  924.  
  925. }
  926. stock Find( Base , End , Pattern[] , size_memory , Offset = 0 ) {
  927.  
  928.     if ( size_memory == 0 )
  929.    
  930.         return 0;
  931.  
  932.     new i = 0
  933.    
  934.     End -= size_memory
  935.  
  936.     Base--;
  937.    
  938.     while ( Base <= End ) {
  939.        
  940.         i = 0
  941.    
  942.         while( i < size_memory ) {
  943.        
  944.             if ( ( Pattern[i] != 0xFF ) && ( rByte( Base + i ) != Pattern[i] ) )
  945.            
  946.                 break;
  947.  
  948.             i++
  949.        
  950.         }
  951.        
  952.         if ( i == size_memory )
  953.        
  954.             return Base + Offset
  955.  
  956.         Base++;
  957.  
  958.     }
  959.    
  960.     return 0
  961.  
  962. }
  963. stock ReplaceMemoryDWord( Base , size_memory , Pattern , Need , Count = 1 ) {
  964.  
  965.     new predel = Base + size_memory - 4
  966.    
  967.     new i
  968.    
  969.     new SC = 0
  970.    
  971.     for ( i = Base; i < predel; i++ ) {
  972.    
  973.         if ( rDWord( i ) == Pattern ) {
  974.        
  975.             wDWord( i , Need )
  976.            
  977.             SC++
  978.            
  979.             if ( SC == Count ) {
  980.            
  981.                 return SC
  982.            
  983.             }
  984.        
  985.         }
  986.    
  987.     }
  988.    
  989.     return SC
  990.  
  991. }
  992. stock MallocFill( size_memory , Char = 0 ) {
  993.  
  994.     new Base = Malloc( size_memory )
  995.    
  996.     if ( Base != 0 )
  997.    
  998.         Fill( Base , size_memory , Char )
  999.        
  1000.     return Base
  1001.  
  1002. }
  1003. stock Fill( Base , size_memory , Char = 0 ) {
  1004.  
  1005.     new i
  1006.     new predel = Base + size_memory - 1
  1007.    
  1008.     for( i = Base; i <= predel; i++ )
  1009.    
  1010.         wByte( i , Char )
  1011.  
  1012. }
  1013. stock Malloc( size_memory ) {
  1014.  
  1015.     return OrpheuCall( o_Malloc , size_memory )
  1016.  
  1017. }
  1018.  
  1019. stock SetByteWriteByte() {
  1020.  
  1021.     if ( WriteByteProcess )
  1022.  
  1023.         return false
  1024.  
  1025.     wPStringEng( WriteByteAddr , BYTE_CODE_W_BYTE )
  1026.  
  1027.     WriteByteProcess = true
  1028.  
  1029.     return true
  1030.  
  1031. }
  1032. stock UnSetByteWriteByte() {
  1033.    
  1034.     if ( !( WriteByteProcess ) )
  1035.    
  1036.         return false
  1037.        
  1038.     wPStringEng( WriteByteAddr , SAVE_ORIGINAL_DATA_W )
  1039.  
  1040.     WriteByteProcess = false
  1041.  
  1042.     return true
  1043.  
  1044. }
  1045. stock FindWriteByte() {
  1046.  
  1047.     o_wByte = OrpheuGetFunction( ORPHEU_NAME_WRITE_BYTE )
  1048.  
  1049.     WriteByteAddr = OrpheuGetFunctionAddress( o_wByte )
  1050.    
  1051.     return true
  1052.  
  1053. }
  1054.  
  1055. stock FindMallocPtr() {
  1056.  
  1057.     new PtrString = WriteByteAddr
  1058.  
  1059.     new i
  1060.  
  1061.     new j
  1062.    
  1063.     for ( i = ENGINE_BASE; i <= ENGINE_END; i++ )
  1064.    
  1065.         if ( ( rByte( i ) == 0x68 ) && ( rDWord( i + 1 ) == PtrString ) )
  1066.    
  1067.             for ( j = i + 4; j < i + 1024; j++ )
  1068.            
  1069.                 if ( ( rDWord( j ) & 0xFFFFFF ) == 0xE8106A )
  1070.                
  1071.                     return ( ( j + 3 ) + rDWord( j + 3 ) + 4 )
  1072.    
  1073.     return 0;
  1074.  
  1075. }
  1076. stock FindMalloc() {
  1077.  
  1078.     if ( OS == OS_LINUX ) {
  1079.    
  1080.         o_Malloc = OrpheuGetFunction( ORPHEU_NAME_MALLOC_LIN )
  1081.    
  1082.         MSG_ShowAddr( "Malloc_Base" , OrpheuGetFunctionAddress(o_Malloc) )
  1083.    
  1084.         return true
  1085.  
  1086.     }
  1087.  
  1088.     Malloc_Base = FindMallocPtr()
  1089.  
  1090.     if ( Malloc_Base == 0 )
  1091.    
  1092.         return NewError( "Malloc_Base is null" );
  1093.  
  1094.     o_Malloc = OrpheuCreateFunction( Malloc_Base , ORPHEU_NAME_MALLOC_WIN )
  1095.  
  1096.     MSG_ShowAddr( "Malloc_Base" , Malloc_Base )
  1097.    
  1098.     if ( OrpheuGetFunctionAddress(o_Malloc) != Malloc_Base )
  1099.    
  1100.         return NewError( "GetAddr(Malloc) != Malloc_Base" );
  1101.  
  1102.     return true
  1103.  
  1104. }
  1105. stock FindCBuf_AddText() {
  1106.  
  1107.     if ( OS == OS_LINUX ) {
  1108.    
  1109.         Cbuf_AddText = OrpheuGetAddr( ORPHEU_NAME_CBUF_ADDTEXT )
  1110.        
  1111.         MSG_ShowAddr( "Cbuf_AddText" , Cbuf_AddText )
  1112.        
  1113.         return ( Cbuf_AddText != 0 )
  1114.    
  1115.     }
  1116.  
  1117.     static PATTERN[] = { 0x66756243,0x6464415F,0x74786554,0x766F203A,0x6C667265,0x000A776F }
  1118.  
  1119.     new i
  1120.    
  1121.     new PtrString = 0
  1122.    
  1123.     for ( i = ENGINE_BASE; i <= ENGINE_END; i++ )
  1124.    
  1125.         if (
  1126.             ( rDWord( i        ) == PATTERN[0]  ) &&
  1127.             ( rDWord( i + 4    ) == PATTERN[1]  ) &&
  1128.             ( rDWord( i + 4*2  ) == PATTERN[2]  ) &&
  1129.             ( rDWord( i + 4*3  ) == PATTERN[3]  ) &&
  1130.             ( rDWord( i + 4*4  ) == PATTERN[4]  ) &&
  1131.             ( rDWord( i + 4*5  ) == PATTERN[5]  )
  1132.         ) {
  1133.        
  1134.             PtrString = i
  1135.        
  1136.             break
  1137.        
  1138.         }
  1139.  
  1140.     if ( PtrString == 0 )
  1141.    
  1142.         return NewError( "PtrString CBuf_AddText is null" );
  1143.  
  1144.     new CodePtr = 0
  1145.    
  1146.     for ( i = ENGINE_BASE; i <= ENGINE_END; i++ )
  1147.    
  1148.         if ( rDWord( i ) == PtrString ) {
  1149.        
  1150.             CodePtr = i
  1151.        
  1152.             break
  1153.        
  1154.         }
  1155.    
  1156.     if ( CodePtr == 0 )
  1157.    
  1158.         return NewError( "CodePtr CBuf_AddText is null" );
  1159.    
  1160.    
  1161.    
  1162.     for ( i = CodePtr; i >= CodePtr - 256; i-- )
  1163.    
  1164.         if ( ( rByte( i ) == 0x55 ) && ( rByte( i + 1 ) == 0x8B ) && ( rByte( i + 2 ) == 0xEC ) ) { // stack frame begin
  1165.  
  1166.             Cbuf_AddText = i
  1167.            
  1168.             break
  1169.        
  1170.         }
  1171.        
  1172.     if ( Cbuf_AddText == 0 )
  1173.    
  1174.         return NewError( "CBuf_AddText is null" )
  1175.  
  1176.     MSG_ShowAddr( "Cbuf_AddText" , Cbuf_AddText )
  1177.        
  1178.     return true;
  1179.  
  1180. }
  1181. stock FindMSG_ReadBits() {
  1182.  
  1183.     MSG_ReadBits = OrpheuGetAddr( ORPHEU_NAME_MSG_READBITS )
  1184.  
  1185.     MSG_ShowAddr( "MSG_ReadBits" , MSG_ReadBits )
  1186.  
  1187.     return ( MSG_ReadBits != 0 )
  1188.  
  1189. }
  1190. stock FindMSG_WriteBits() {
  1191.  
  1192.     MSG_WriteBits = OrpheuGetAddr( ORPHEU_NAME_MSG_WRITEBITS )
  1193.  
  1194.     MSG_ShowAddr( "MSG_WriteBits" , MSG_WriteBits )
  1195.  
  1196.     return ( MSG_WriteBits != 0 )
  1197.  
  1198. }
  1199. stock FindSV_SendResources() {
  1200.  
  1201.     SV_SendResources = OrpheuGetAddr( ORPHEU_NAME_SV_SENDRES )
  1202.    
  1203.     MSG_ShowAddr( "SV_SendResources" , SV_SendResources )
  1204.    
  1205.     return ( SV_SendResources != 0 )
  1206.  
  1207. }
  1208. stock FindSV_ParseConsistencyResponse() {
  1209.  
  1210.     SV_ParseConsistencyResponse = OrpheuGetAddr( ORPHEU_NAME_SV_PARSECONS )
  1211.    
  1212.     MSG_ShowAddr( "SV_ParseConsistencyResponse" , SV_ParseConsistencyResponse )
  1213.        
  1214.     return true
  1215.    
  1216. }
  1217. stock FindResources() {
  1218.  
  1219.     if ( OS == OS_WINDOWS ) {
  1220.  
  1221.         new i
  1222.        
  1223.         new Ptr = 0
  1224.        
  1225.         for( i = SV_SendResources; i < SV_SendResources + 128; i++ )
  1226.        
  1227.             if ( rWord( i ) == 0x2B6A ) {
  1228.            
  1229.                 Ptr = i;
  1230.                
  1231.                 break;
  1232.            
  1233.             }
  1234.            
  1235.         if ( Ptr == 0 )
  1236.        
  1237.             return NewError( "Ptr FindResources( 0x2B6A ) is null" );
  1238.            
  1239.         new Ptr2 = 0
  1240.        
  1241.         for( i = Ptr; i < Ptr + 128; i++ )
  1242.        
  1243.             if ( rWord( i ) == 0x0C6A ) {
  1244.            
  1245.                 Ptr2 = i;
  1246.                
  1247.                 break;
  1248.            
  1249.             }
  1250.        
  1251.         if ( Ptr2 == 0 )
  1252.        
  1253.             return NewError( "Ptr2 FindResources( 0x0C6A ) is null" );
  1254.        
  1255.  
  1256.         new CountPtr = 0
  1257.        
  1258.        
  1259.         for( i = Ptr2; i < Ptr2 + 12; i++ ) {
  1260.            
  1261.             if ( rByte( i ) == 0xA1 ) {
  1262.                
  1263.                 CountPtr = i + 1;
  1264.                    
  1265.                 break;
  1266.                
  1267.             } else
  1268.             if ( ( rByte( i ) == 0xFF ) && ( rByte( i + 1 ) == 0x35 ) ) {
  1269.                
  1270.                 CountPtr = i + 2;
  1271.                    
  1272.                 break;
  1273.                
  1274.             }
  1275.            
  1276.         }
  1277.  
  1278.        
  1279.         if ( CountPtr == 0 )
  1280.        
  1281.             return NewError( "CountPtr( Win ) FindResources is null" );
  1282.            
  1283.         Resources_Base = rDWord(CountPtr) - 0x88 * 0x500;
  1284.    
  1285.     } else {
  1286.    
  1287.    
  1288.         new i
  1289.         new j
  1290.         new l
  1291.        
  1292.         for( i = SV_SendResources; i < SV_SendResources + 4096; i++ )
  1293.        
  1294.             if ( rByte( i ) == 0x0C )
  1295.            
  1296.                 for( j = i + 1; j <= i + 16; j++ )
  1297.                
  1298.                     if ( ( rByte( j ) == 0xE8 ) && ( (j+1) + rDWord( (j+1) ) + 4 ) == MSG_WriteBits ) {
  1299.                    
  1300.                         for( l = j - 4; l >= j - 16; l-- ) {
  1301.                        
  1302.                             new count_base = rDWord( l )
  1303.                        
  1304.                             if (
  1305.                                 ( count_base >= ENGINE_BASE ) && ( count_base <= ENGINE_END ) &&
  1306.                                 ( rDWord( count_base ) >= 0 ) && ( rDWord( count_base ) <= 0x500 ) &&
  1307.                                 ( rDWord( count_base + 4 + 0x2C * 0x200 ) >= 0 ) && ( rDWord( count_base + 4 + 0x2C * 0x200 ) <= 0x200 )
  1308.                             ) {
  1309.                            
  1310.                                 CountResources_Base = count_base
  1311.  
  1312.                                 SomeTotalValue_Base = count_base + 4 + 0x2C * 0x200
  1313.                                
  1314.                                 Resources_Base = count_base - 0x88 * 0x500
  1315.                                
  1316.                                 MSG_ShowAddr( "Resources_Base" , Resources_Base )
  1317.                                 MSG_ShowAddr( "CountResources_Base" , CountResources_Base )
  1318.                                 MSG_ShowAddr( "SomeTotalValue_Base" , SomeTotalValue_Base )
  1319.  
  1320.                                 return true;
  1321.                    
  1322.                             }
  1323.                            
  1324.                         }
  1325.                    
  1326.                     }
  1327.  
  1328.         if ( Resources_Base == 0 )
  1329.        
  1330.             return NewError( "Resources_Base( Lin ) FindResources is null" );
  1331.  
  1332.     }
  1333.  
  1334.     CountResources_Base = Resources_Base + 0x88 * 0x500;
  1335.  
  1336.     SomeTotalValue_Base = CountResources_Base + 4 + 0x2C * 0x200   
  1337.  
  1338.     MSG_ShowAddr( "Resources_Base" , Resources_Base )
  1339.     MSG_ShowAddr( "CountResources_Base" , CountResources_Base )
  1340.     MSG_ShowAddr( "SomeTotalValue_Base" , SomeTotalValue_Base )
  1341.  
  1342.     return true;
  1343.  
  1344. }
  1345. stock FindServerCount() {
  1346.  
  1347.     new i
  1348.  
  1349.     new Base_1 = 0
  1350.    
  1351.     for( i = SV_SendResources; i < SV_SendResources + 256; i++ )
  1352.    
  1353.         if ( rByte( i ) == 0x20 ) {
  1354.        
  1355.             Base_1 = i
  1356.            
  1357.             break;
  1358.        
  1359.         }
  1360.  
  1361.     if ( Base_1 == 0 )
  1362.    
  1363.         return NewError( "FindServerCount(Base_1) is null" )
  1364.  
  1365.        
  1366.        
  1367.     new Base_2 = 0
  1368.    
  1369.     for( i = Base_1 + 1; i < Base_1 + 256; i++ )
  1370.    
  1371.         if ( rByte( i ) == 0x00 ) {
  1372.        
  1373.             Base_2 = i
  1374.            
  1375.             break;
  1376.        
  1377.         }
  1378.  
  1379.     if ( Base_2 == 0 )
  1380.    
  1381.         return NewError( "FindServerCount(Base_2) is null" )
  1382.    
  1383.  
  1384.  
  1385.     new Base_3 = 0
  1386.    
  1387.     for( i = Base_2 + 1; i < Base_2 + 256; i++ )
  1388.    
  1389.         if ( rByte( i ) == 0x2D ) {
  1390.        
  1391.             Base_3 = i
  1392.            
  1393.             break;
  1394.        
  1395.         }
  1396.  
  1397.     if ( Base_3 == 0 )
  1398.    
  1399.         return NewError( "FindServerCount(Base_3) is null" )
  1400.        
  1401.        
  1402.        
  1403.     new Base_4 = 0
  1404.    
  1405.     for( i = Base_3 + 1; i < Base_3 + 256; i++ )
  1406.    
  1407.         if ( rByte( i ) == 0xE8 ) {
  1408.        
  1409.             Base_4 = i
  1410.            
  1411.             break;
  1412.        
  1413.         }
  1414.  
  1415.     if ( Base_4 == 0 )
  1416.    
  1417.         return NewError( "FindServerCount(Base_4) is null" )
  1418.  
  1419.  
  1420.  
  1421.     for( i = Base_4 + 1; i < Base_4 + 256; i++ ) {
  1422.    
  1423.         new Temp = rDWord( i )
  1424.    
  1425.         if ( ( Temp >= ENGINE_BASE ) && ( Temp <= ENGINE_END ) && ( rDWord( Temp ) >= 0 ) && ( rDWord( Temp ) <= ( 1 << 16 ) ) && ( rDWord( Temp - 4 ) == 32 ) ) {
  1426.        
  1427.             ServerCount_Base = Temp
  1428.            
  1429.             break;
  1430.        
  1431.         }
  1432.  
  1433.     }
  1434.  
  1435.     if ( ServerCount_Base == 0 )
  1436.    
  1437.         return NewError( "FindServerCount(ServerCount_Base) is null" )
  1438.  
  1439.     MSG_ShowAddr( "ServerCount_Base" , ServerCount_Base )
  1440.  
  1441.     return true
  1442.  
  1443. }
  1444. stock FindGlobalHostClient() {
  1445.  
  1446.     if ( OS == OS_LINUX ) {
  1447.    
  1448.         new Ptr = OrpheuGetAddr( ORPHEU_NAME_SV_REQ_MISS )
  1449.  
  1450.         new i
  1451.    
  1452.         for( i = Ptr; i < Ptr + 256; i++ ) {
  1453.        
  1454.             if ( ( rByte( i ) == 0x8B ) && ( ( rByte( i + 1 ) == 0x35 ) || ( rByte( i + 1 ) == 0x1D ) ) ) {
  1455.            
  1456.                 new Curr = rDWord( i + 2 )
  1457.            
  1458.                 if ( ( Curr >= ENGINE_BASE ) && ( Curr <= ENGINE_END ) ) {
  1459.            
  1460.                     global_host_client = Curr
  1461.                
  1462.                     MSG_ShowAddr( "global_host_client( Lin )( search type 1 )" , global_host_client )
  1463.                
  1464.                     return true
  1465.                
  1466.                 }
  1467.                
  1468.            
  1469.             }
  1470.        
  1471.         }
  1472.        
  1473.         for( i = Ptr; i < Ptr + 256; i++ ) {
  1474.        
  1475.             if ( rByte( i ) == 0x8B ) {
  1476.            
  1477.                 new Curr = rDWord( i + 2 )
  1478.            
  1479.                 if ( ( Curr >= ENGINE_BASE ) && ( Curr <= ENGINE_END ) ) {
  1480.            
  1481.                     global_host_client = Curr
  1482.                
  1483.                     MSG_ShowAddr( "global_host_client( Lin )( search type 2 )" , global_host_client )
  1484.                
  1485.                     return true
  1486.                
  1487.                 }
  1488.                
  1489.            
  1490.             }
  1491.        
  1492.         }
  1493.        
  1494.         for( i = Ptr; i < Ptr + 256; i++ ) {
  1495.        
  1496.             new Curr = rDWord( i )
  1497.            
  1498.             if ( ( Curr >= ENGINE_BASE ) && ( Curr <= ENGINE_END ) ) {
  1499.            
  1500.                 global_host_client = Curr
  1501.                
  1502.                 MSG_ShowAddr( "global_host_client( Lin )( search type 3 )" , global_host_client )
  1503.                
  1504.                 return true
  1505.            
  1506.             }
  1507.        
  1508.         }
  1509.        
  1510.         return NewError( "global_host_client( Lin ) is null" )
  1511.    
  1512.     }
  1513.  
  1514.     static Pattern[] = {
  1515.         0x51 ,
  1516.         0x8B , 0x0D ,  0xFF,0xFF,0xFF,0xFF ,
  1517.         0x03 , 0xD0 ,
  1518.         0xC6 , 0x85 ,  0xFF,0xFF,0xFF,0xFF , 0x00 ,
  1519.         0x8D , 0x04
  1520.     }
  1521.  
  1522.     new Search = Find( SV_ParseConsistencyResponse , SV_ParseConsistencyResponse + 4096 , Pattern , sizeof(Pattern) , 3 )
  1523.     MSG_ShowAddr( "global_host_client(Search)" , Search )
  1524.     MSG_ShowAddr( "global_host_client(rDWord( Search ))" , rDWord( Search ) )
  1525.  
  1526.     if ( ( Search == 0 ) || ( rDWord( Search ) < ENGINE_BASE ) || ( rDWord( Search) > ENGINE_END ) )
  1527.  
  1528.         return NewError( "global_host_client( Search | Win ) is null" )
  1529.  
  1530.     global_host_client = rDWord( Search )
  1531.    
  1532.     MSG_ShowAddr( "global_host_client" , global_host_client )
  1533.  
  1534.     return true
  1535.  
  1536. }
  1537.  
  1538.  
  1539. stock GetRandomChar() {
  1540.  
  1541.     new rd = random_num( 0 ,  2 )
  1542.    
  1543.     if ( rd == 0 )
  1544.         return random_num( 66 , 66 + 20 )
  1545.  
  1546.     if ( rd == 1 )
  1547.         return random_num( 49 , 48 + 7 )
  1548.  
  1549.     if ( rd == 2 )
  1550.         return random_num( 98 , 98 + 20 )
  1551.  
  1552.     return GetRandomChar()
  1553.  
  1554. }
  1555. stock GetRandomString( Str[] , Min , Max ) {
  1556.  
  1557.     new len = random_num( Min , Max )
  1558.  
  1559.     new i = 0
  1560.  
  1561.     while( i <= len )
  1562.    
  1563.         Str[ i++ ] = GetRandomChar()
  1564.  
  1565.     Str[ i ] = 0
  1566.  
  1567. }
  1568.  
  1569. stock SetSite() {
  1570.  
  1571.     get_cvar_string( "sv_downloadurl" , DownloadSite , sizeof(DownloadSite)-1 )
  1572.  
  1573.     DownloadSiteEnabled = ( strlen(DownloadSite) != 0 )
  1574.  
  1575.     return true
  1576.  
  1577. }
  1578. stock Get_MD5( MD5_Hex[] ) {
  1579.  
  1580.     static HexTable[] = "0123456789abcdef"
  1581.  
  1582.     static NormalMD5_Hex[ 9 ]
  1583.  
  1584.     new len = strlen( MD5_Hex )
  1585.  
  1586.     if ( len > 8 )
  1587.    
  1588.         len = 8;
  1589.  
  1590.     new i
  1591.  
  1592.     new z = 0
  1593.  
  1594.     for( i = 0; i < len; i++ )
  1595.    
  1596.         NormalMD5_Hex[ z++ ] = MD5_Hex[ i ]
  1597.  
  1598.     while( z < 8 )
  1599.  
  1600.         NormalMD5_Hex[ z++ ] = 48   //  ord( '0' )
  1601.  
  1602.     NormalMD5_Hex[ 8 ] = 0
  1603.  
  1604.     strtolower( NormalMD5_Hex )
  1605.  
  1606.     new MD5 = 0
  1607.  
  1608.     new j
  1609.  
  1610.     i = 0
  1611.  
  1612.     for( i = 0; i < 8; i++ ) {
  1613.    
  1614.         j = 0
  1615.    
  1616.         while( j < 16 ) {
  1617.        
  1618.             if ( NormalMD5_Hex[ i ] == HexTable[ j ] ) {
  1619.  
  1620.                 MD5 |= j << ( ( i << 2 ) - ( ( i & 1 ) * 8 ) + 4 )
  1621.            
  1622.                 break;         
  1623.            
  1624.             }
  1625.            
  1626.             j++
  1627.            
  1628.         }
  1629.            
  1630.         if ( j == 16 ) {
  1631.  
  1632.             static Str[ 1024 ]
  1633.             format( Str , sizeof(Str)-1 , "Bad MD5: %s" , MD5_Hex )
  1634.  
  1635.             NewError( Str )
  1636.            
  1637.             return 0
  1638.  
  1639.         }
  1640.    
  1641.     }
  1642.  
  1643.     return MD5
  1644.  
  1645. }
  1646. stock Script_ParseTokens( Script[] ) {
  1647.  
  1648.     static M_Spac[] = " "
  1649.     static M_Tab [] = {0x09}
  1650.    
  1651.     static M_Inve[] = "!"
  1652.     static M_Next[] = "|"
  1653.     static M_Prev[] = "prev"
  1654.     static M_All [] = "all"
  1655.  
  1656.     static Token[ 1024 ]
  1657.  
  1658.     new len = strlen( Script )
  1659.  
  1660.     new i
  1661.  
  1662.     new z
  1663.  
  1664.     new c
  1665.    
  1666.     new TokenLen
  1667.  
  1668.     new SI = SI_NORMAL
  1669.  
  1670.     ScriptsCount = 0
  1671.    
  1672.     new ScriptsMaxCount = 1
  1673.    
  1674.     for( i = 0; i < len; i++ )
  1675.    
  1676.         if ( Script[i] == M_Next[0] )
  1677.        
  1678.             ScriptsMaxCount++
  1679.  
  1680.     Scripts_Base = Malloc( ScriptsMaxCount * ( 4 * 3 ) )
  1681.    
  1682.     if ( Scripts_Base == 0 )
  1683.    
  1684.         return NewError( "Scripts_Base is null" )
  1685.    
  1686.     new Scripts_Cursor = Scripts_Base
  1687.    
  1688.     i = 0
  1689.  
  1690.     z = 0
  1691.  
  1692.  
  1693.     while( i < len ) {
  1694.  
  1695.         while( ( i < len ) && ( ( Script[ i ] == M_Spac[0] ) || ( Script[ i ] == M_Tab[0] ) ) ) i++
  1696.  
  1697.         if ( i >= len ) break;
  1698.        
  1699.         if ( Script[ i ] == M_Inve[0] ) {
  1700.        
  1701.             SI = SI_INVERT
  1702.  
  1703.             i++
  1704.        
  1705.             while( ( i < len ) && ( ( Script[ i ] == M_Spac[0] ) || ( Script[ i ] == M_Tab[0] ) ) ) i++
  1706.        
  1707.         }
  1708.    
  1709.         if ( i >= len ) break;
  1710.  
  1711.         z = 0
  1712.  
  1713.         while( i < len ) {
  1714.        
  1715.             c = Script[ i++ ]
  1716.  
  1717.             if ( c == M_Next[0] ) {
  1718.            
  1719.                 Token[ z ] = 0
  1720.            
  1721.                 break;
  1722.  
  1723.             }
  1724.            
  1725.             Token[ z++ ] = c
  1726.            
  1727.         }
  1728.  
  1729.         trim( Token )
  1730.        
  1731.         TokenLen = strlen(Token)
  1732.  
  1733.         if ( TokenLen == 0 ) {
  1734.        
  1735.             SI = SI_NORMAL
  1736.        
  1737.             continue;
  1738.  
  1739.         }
  1740.  
  1741.         if ( SI == SI_NORMAL ) {
  1742.        
  1743.             wDWord( Scripts_Cursor , SI_NORMAL )
  1744.             Scripts_Cursor += 4
  1745.            
  1746.         } else {
  1747.        
  1748.             wDWord( Scripts_Cursor , SI_INVERT )
  1749.             Scripts_Cursor += 4
  1750.            
  1751.         }
  1752.        
  1753.         SI = SI_NORMAL
  1754.        
  1755.         ScriptsCount++
  1756.        
  1757.         if ( equal( Token , M_Prev , strlen(M_Prev) ) ) {
  1758.        
  1759.             wDWord( Scripts_Cursor , SM_PREV )
  1760.             Scripts_Cursor += 4
  1761.             wDWord( Scripts_Cursor , 0 )
  1762.             Scripts_Cursor += 4
  1763.        
  1764.             continue;
  1765.        
  1766.         }
  1767.  
  1768.         if ( equal( Token , M_All , strlen(M_All) ) ) {
  1769.        
  1770.             wDWord( Scripts_Cursor , SM_ALL )
  1771.             Scripts_Cursor += 4
  1772.             wDWord( Scripts_Cursor , 0 )
  1773.             Scripts_Cursor += 4
  1774.        
  1775.             continue;
  1776.        
  1777.         }
  1778.  
  1779.         wDWord( Scripts_Cursor , SM_CONST )
  1780.         Scripts_Cursor += 4
  1781.  
  1782.         wDWord( Scripts_Cursor , Get_MD5(Token) )
  1783.         Scripts_Cursor += 4
  1784.  
  1785.     }
  1786.    
  1787.     return true
  1788.  
  1789. }
  1790. stock ProcessFile( Exec[] , Script[] , Path[] ) {
  1791.  
  1792.     if ( !( Script_ParseTokens( Script ) ) )
  1793.    
  1794.         return NewError( "Script_ParseTokens error" )
  1795.  
  1796.     new len = strlen( Exec )   
  1797.     Exec[ len ] = 0x0A
  1798.     Exec[ len + 1 ] = 0x00
  1799.  
  1800.     new Exec_Base = GetImmortalPString( Exec )
  1801.  
  1802.     if ( Exec_Base == 0 )
  1803.    
  1804.         return NewError( "Exec_Base memory is null" )
  1805.  
  1806.     wDWord( ScriptFiles_Base + ( ScriptFilesCount * ( 4 * 3 ) ) + 0 * 4 , Exec_Base )
  1807.     wDWord( ScriptFiles_Base + ( ScriptFilesCount * ( 4 * 3 ) ) + 1 * 4 , ScriptsCount )
  1808.     wDWord( ScriptFiles_Base + ( ScriptFilesCount * ( 4 * 3 ) ) + 2 * 4 , Scripts_Base )
  1809.  
  1810.     ScriptFilesCount++
  1811.  
  1812.  
  1813.  
  1814.     //MSG_Print( Exec )
  1815.     //MSG_Print( Script )
  1816.     //MSG_Print( Path )
  1817.     //MSG_Print( "" )
  1818.  
  1819.     force_unmodified( force_exactfile , {0, 0, 0} , {0, 0, 0} , Path )
  1820.    
  1821.     //ForceUnmodifiedOwn( Path )
  1822.  
  1823.     return true
  1824.  
  1825. }
  1826. stock ParseConfig() {
  1827.    
  1828.     new File_Handle
  1829.    
  1830.     File_Handle = fopen( CONFIG_PATH , "r" )
  1831.    
  1832.     if ( !( File_Handle ) )
  1833.    
  1834.         return NewError( "No found config!" )
  1835.  
  1836.  
  1837.     static buffer_low[ 4096 ]
  1838.     static buffer_nor[ 4096 ]
  1839.    
  1840.     static id[ 4096 ]
  1841.    
  1842.     static script[ 4096 ]
  1843.    
  1844.     static path[ 4096 ]
  1845.    
  1846.     strtolower( NAME_CMD_PATH )
  1847.    
  1848.     new plen = strlen(NAME_CMD_PATH)
  1849.    
  1850.     new m_Line = 0
  1851.  
  1852.  
  1853.     while( !( feof( File_Handle ) ) ) {
  1854.    
  1855.         m_Line++
  1856.  
  1857.         fgets( File_Handle , buffer_nor , sizeof(buffer_nor)-1 )
  1858.            
  1859.         trim( buffer_nor )
  1860.  
  1861.        
  1862.         format( buffer_low , sizeof( buffer_low )-1 , "%s" , buffer_nor )
  1863.        
  1864.         strtolower( buffer_low )
  1865.        
  1866.         new len = strlen(buffer_low)
  1867.  
  1868.         if ( len > plen ) {
  1869.        
  1870.             new i = 0;
  1871.            
  1872.             while( ( i < plen ) && ( buffer_low[i] == NAME_CMD_PATH[i] ) ) i++;
  1873.            
  1874.             if ( i == plen ) {
  1875.  
  1876.                 while( ( i < len ) && ( buffer_low[i] != CHAR_PATH_W_B[0] ) ) i++;
  1877.    
  1878.                 i++
  1879.                
  1880.                 new z = 0
  1881.                
  1882.                 while( ( i < len ) && ( buffer_low[i] != CHAR_PATH_W_E[0] ) )
  1883.                
  1884.                     id[z++] = buffer_nor[i++]
  1885.  
  1886.                 i++
  1887.                    
  1888.                 id[z] = 0
  1889.                 trim( id )
  1890.                
  1891.                 if ( strlen(id) > 0 ) {
  1892.                
  1893.                     while( ( i < len ) && ( buffer_low[i] != CHAR_PATH_W_B[0] ) ) i++;
  1894.                    
  1895.                     i++
  1896.                    
  1897.                     z = 0
  1898.                
  1899.                     while( ( i < len ) && ( buffer_low[i] != CHAR_PATH_W_E[0] ) )
  1900.                    
  1901.                         script[z++] = buffer_low[i++]
  1902.                    
  1903.                     script[z] = 0
  1904.                     trim( script )
  1905.                    
  1906.                     if ( strlen(script) > 0 ) {
  1907.                        
  1908.                         while( ( i < len ) && ( buffer_low[i] != CHAR_PATH_R_E[0] ) ) i++;
  1909.                        
  1910.                         i++
  1911.                        
  1912.                         z = 0
  1913.                        
  1914.                         while( i < len )
  1915.                
  1916.                             path[z++] = buffer_nor[i++]
  1917.                        
  1918.                         i++
  1919.                            
  1920.                         path[z] = 0
  1921.                         trim( path )
  1922.                        
  1923.                         if ( strlen(path) > 0 ) {
  1924.                        
  1925.                             if ( !( ProcessFile( id , script , path ) ) ) {
  1926.                                
  1927.                                 server_print( "%sParse config: Error ProcessFile( line: %d )" , CONSOLE_PRINT_PREFIX , m_Line  )
  1928.                            
  1929.                                 return NewError( "Error ProcessFile" )
  1930.                                
  1931.                             }
  1932.                        
  1933.                         } else
  1934.                        
  1935.                         server_print( "%sParse config: Empty path( line: %d )" , CONSOLE_PRINT_PREFIX , m_Line  )
  1936.                        
  1937.                     } else
  1938.                        
  1939.                         server_print( "%sParse config: Empty script( line: %d )" , CONSOLE_PRINT_PREFIX , m_Line  )
  1940.  
  1941.                 } else
  1942.                    
  1943.                     server_print( "%sParse config: Empty exec string( line: %d )" , CONSOLE_PRINT_PREFIX , m_Line  )
  1944.                
  1945.             }
  1946.  
  1947.         }
  1948.  
  1949.     }
  1950.  
  1951.     //server_print( "AdminFlags => %s" , AdminFlags )
  1952.     fclose( File_Handle )
  1953.  
  1954.     return true
  1955.  
  1956. }
  1957. static AddResCount = 0
  1958. stock ForceUnmodifiedOwn( Path[] ) {
  1959.  
  1960.     new Resou_Count = rDWord( CountResources_Base )
  1961.    
  1962.     new Consi_Count = rDWord( SomeTotalValue_Base )
  1963.  
  1964.     if ( Resou_Count >= REOURCE_COUNT_MAX )
  1965.    
  1966.         return NewError( "Full resources" )
  1967.  
  1968.     new Resou_Base = Resources_Base + ( Resou_Count * REOURCE_ITEM_SIZE )
  1969.  
  1970.     Fill( Resou_Base , REOURCE_ITEM_SIZE )
  1971.  
  1972.     wPString( Resou_Base , Path )
  1973.     Resou_Base += 64
  1974.  
  1975.     wDWord( Resou_Base , 4 )   
  1976.     Resou_Base += 4
  1977.    
  1978.     wDWord( Resou_Base , REOURCE_COUNT_MAX + AddResCount++ )   
  1979.     Resou_Base += 4
  1980.  
  1981.     wDWord( Resou_Base , 0xFFFFFFFF )  
  1982.     Resou_Base += 4
  1983.  
  1984.     wDWord( Resou_Base , 0x81 )
  1985.  
  1986.     wDWord( CountResources_Base , Resou_Count + 1 )
  1987.    
  1988.     wDWord( SomeTotalValue_Base , Consi_Count + 1 )
  1989.    
  1990. }
  1991. stock AddFiles() {
  1992.  
  1993.     //force_unmodified( force_exactfile , {0, 0, 0} , {0, 0, 0} , "../Core.dll" )
  1994.  
  1995.     GetRandomString( First_FileName , 12 , 16 )
  1996.  
  1997.     force_unmodified( force_exactfile , {0, 0, 0} , {0, 0, 0} , First_FileName )
  1998.     //ForceUnmodifiedOwn( First_FileName )
  1999.  
  2000.     ScriptFiles_Base = Malloc( 4 * CONS_DATA_COUNT_MAX )
  2001.    
  2002.     if ( ScriptFiles_Base == 0 )
  2003.    
  2004.         return NewError( "ScriptFiles_Base memory is null" )
  2005.    
  2006.     if ( !( ParseConfig() ) )
  2007.    
  2008.         return NewError( "Error(AddFiles) :: ParseConfig" )
  2009.  
  2010.     return true
  2011.  
  2012. }
  2013.  
  2014. stock Main() {
  2015.  
  2016.     if ( !( FindWriteByte() ) )                     return NewError( "Not found signature :: FindWriteByte" )
  2017.  
  2018.     SetByteWriteByte()
  2019.  
  2020.  
  2021.  
  2022.     if ( !( FindMalloc() ) )                        return NewError( "Not found signature :: FindMalloc" )
  2023.  
  2024.     if ( !( FindCBuf_AddText() ) )                  return NewError( "Not found signature :: FindCBuf_AddText" )
  2025.  
  2026.     if ( !( FindMSG_ReadBits() ) )                  return NewError( "Not found signature :: FindMSG_ReadBits" )
  2027.  
  2028.     if ( !( FindMSG_WriteBits() ) )                 return NewError( "Not found signature :: FindMSG_WriteBits" )
  2029.  
  2030.     if ( !( FindSV_SendResources() ) )              return NewError( "Not found signature :: FindSV_SendResources" )
  2031.  
  2032.     if ( !( FindSV_ParseConsistencyResponse() ) )   return NewError( "Not found signature :: FindSV_ParseConsistencyResponse" )
  2033.  
  2034.     if ( !( FindResources() ) )                     return NewError( "Not found signature :: FindResources" )
  2035.     /*
  2036.     if ( !( FindServerCount() ) )                   return NewError( "Not found signature :: FindServerCount" )
  2037.     */
  2038.     if ( !( FindGlobalHostClient() ) )              return NewError( "Not found signature :: FindGlobalHostClient" )
  2039.  
  2040.  
  2041.  
  2042.     if ( !( SetSite() ) )                           return NewError( "Main Error :: SetSite" )
  2043.  
  2044.     if ( !( AddFiles() ) )                          return NewError( "Main Error :: AddFiles" )
  2045.  
  2046.     if ( !( AttachTryFiles() ) )                    return NewError( "Main Error :: AttachTryFiles" )
  2047.  
  2048.     UnSetByteWriteByte()
  2049.  
  2050.     return true
  2051.  
  2052. }
  2053.  
  2054. stock AttachTryFiles() {
  2055.  
  2056. /*
  2057. type
  2058.  info_s = ^info_t;
  2059.  info_t = Record
  2060.   Resources_Base:     array_resource_s;
  2061.   Resources_Count:    PCardinal;
  2062.   ConsiData_Count:    PCardinal;
  2063.  
  2064.   Site:               Cardinal;
  2065.  
  2066.   TryFileName:        Cardinal;
  2067.  
  2068.   CheckFilesCount:    Cardinal;
  2069.   FirstIndex:         Cardinal;
  2070.   EndIndex:           Cardinal;
  2071.  
  2072.   Host_CL:            PCardinal;
  2073.   Name_Offset:        Cardinal;
  2074.   IfConsData_Offset:  Cardinal;
  2075.   Proxy_Offset:       Cardinal;
  2076.   ServerCount:        PCardinal;
  2077.  
  2078.   FirstSwap:          Cardinal;
  2079.  
  2080.   Scripts:            script_files_s;
  2081.  
  2082.   LastIndex:          Cardinal;
  2083.   LastMD5:            Cardinal;
  2084.  
  2085.   Cbuf_AddText:       TCbuf_AddText;
  2086.  
  2087.   MemoryConsi:        memory_t;
  2088.   MemoryNotConsi:     memory_t;
  2089.  
  2090.  
  2091.   MSG_Buffer:         buffer_t;
  2092.  End;
  2093. */
  2094.  
  2095.  
  2096.     new Memory_Size = REOURCE_COUNT_MAX * REOURCE_ITEM_SIZE
  2097.     new Memory_Base = Malloc( Memory_Size )
  2098.  
  2099.     if ( Memory_Base == 0 )
  2100.    
  2101.         return NewError( "Memory_Base(AttachTryFiles) is null" )
  2102.  
  2103.     new Memory2_Base = Malloc( Memory_Size )
  2104.  
  2105.     if ( Memory2_Base == 0 )
  2106.    
  2107.         return NewError( "Memory2_Base(AttachTryFiles) is null" )
  2108.        
  2109.     ResetDWord( 4096 )
  2110.  
  2111.     AddDWord( Resources_Base )
  2112.     AddDWord( CountResources_Base )
  2113.     AddDWord( SomeTotalValue_Base )
  2114.  
  2115.     if ( DownloadSiteEnabled )
  2116.         AddImmortalPString( DownloadSite )
  2117.     else   
  2118.         AddDWord( 0 )
  2119.  
  2120.     AddImmortalPString( First_FileName )
  2121.  
  2122.     AddDWord( ScriptFilesCount )
  2123.     AddDWord( 0 )
  2124.     AddDWord( 0 )
  2125.  
  2126.     AddDWord( global_host_client )
  2127.     if ( OS == OS_WINDOWS ) {
  2128.         AddDWord( 0x4D08 )      //  PlayerName
  2129.         AddDWord( 0x18   )      //  Padding18
  2130.         AddDWord( 0x254C )      //  Proxy
  2131.     } else {
  2132.         AddDWord( 0x4BE8 )      //  PlayerName
  2133.         AddDWord( 0x18   )      //  Padding18
  2134.         AddDWord( 0x243C )      //  Proxy
  2135.     }
  2136.     AddDWord( ServerCount_Base )
  2137.    
  2138.     AddDWord( 1 )
  2139.  
  2140.     AddDWord( ScriptFiles_Base )
  2141.  
  2142.     AddDWord( 0 )
  2143.     AddDWord( 0 )
  2144.  
  2145.     AddDWord( Cbuf_AddText )
  2146.    
  2147.     AddDWord( Memory_Base )
  2148.     AddDWord( Memory_Size )
  2149.     AddDWord( 0 )
  2150.    
  2151.     AddDWord( Memory2_Base )
  2152.     AddDWord( Memory_Size )
  2153.     AddDWord( 0 )
  2154.    
  2155.     AddDWord( 0 )
  2156.     AddDWord( 0 )
  2157.     AddDWord( 0 )
  2158.     AddDWord( 0 )
  2159.     AddDWord( 0 )
  2160.     AddDWord( 0 )
  2161.  
  2162.     new Info_Base = CreateStruct()
  2163.  
  2164.     if ( Info_Base == 0 )
  2165.    
  2166.         return NewError( "Info_Base(AttachTryFiles) is null" )
  2167.  
  2168.  
  2169.  
  2170.     new Code_Base = WriteCode( BYTE_CODE_TRY_FILES , sizeof(BYTE_CODE_TRY_FILES) )
  2171.  
  2172.     if ( Code_Base == 0 )
  2173.    
  2174.         return NewError( "Code_Base(AttachTryFiles) is null" )
  2175.  
  2176.     EntryPoint1_Offset += Code_Base
  2177.     EntryPoint2_Offset += Code_Base
  2178.     EntryPoint3_Offset += Code_Base
  2179.  
  2180.  
  2181.  
  2182.     new SV_SendResources_Gate = Detours_Attach( SV_SendResources                    , EntryPoint1_Offset )
  2183.    
  2184.     if ( SV_SendResources_Gate == 0 ) {
  2185.    
  2186.         Detours_DeatchAll()
  2187.        
  2188.         return NewError( "SV_SendResources_Gate(AttachTryFiles) is null" )
  2189.  
  2190.     }
  2191.  
  2192.     new SV_ParseConsistencyRes_Gate = Detours_Attach( SV_ParseConsistencyResponse   , EntryPoint2_Offset )
  2193.    
  2194.     if ( SV_ParseConsistencyRes_Gate == 0 ) {
  2195.    
  2196.         Detours_DeatchAll()
  2197.        
  2198.         return NewError( "SV_ParseConsistencyRes_Gate(AttachTryFiles) is null" )
  2199.  
  2200.     }
  2201.  
  2202.     new MSG_ReadBits_Gate = Detours_Attach( MSG_ReadBits                            , EntryPoint3_Offset )
  2203.    
  2204.     if ( MSG_ReadBits_Gate == 0 ) {
  2205.    
  2206.         Detours_DeatchAll()
  2207.        
  2208.         return NewError( "MSG_ReadBits_Gate(AttachTryFiles) is null" )
  2209.  
  2210.     }
  2211.  
  2212. //  Replace:
  2213. //    $11111111 - to Info Structure
  2214. //    $21212121 - to To PDWord
  2215. //    $22222222 - to Relative EntryPoint MSG_ReadBits_Gate
  2216. //    $23232323 - to Relative EntryPoint SV_ParseConsistencyResponse_Gate
  2217.  
  2218.     ReplaceCodeDWord( 0x11111111 , Info_Base )
  2219.     new DWord_Temp = Malloc( 4 )
  2220.     wDWord( DWord_Temp , 1 )
  2221.     ReplaceCodeDWord( 0x21212121 , DWord_Temp )
  2222.     ReplaceCodeRelative( 0x22222222 , MSG_ReadBits_Gate )
  2223.     ReplaceCodeRelative( 0x23232323 , SV_ParseConsistencyRes_Gate )
  2224.     DWord_Temp = Malloc( 4 )
  2225.     wDWord( DWord_Temp , 0 )
  2226.     ReplaceCodeDWord( 0x77777777 , DWord_Temp )
  2227.     ReplaceCodeRelative( 0x55555555 , SV_SendResources_Gate )
  2228.  
  2229.  
  2230.  
  2231.     return true
  2232.  
  2233. }
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240. #define MAX_HOOKS   1024
  2241. enum hook_t {
  2242.     hook_t_valid ,
  2243.     hook_t_base ,
  2244.     hook_t_origin
  2245. }
  2246. static HooksCursor = 0
  2247. static HooksList[ MAX_HOOKS ][ hook_t ]
  2248. stock AttachEngineHook( Base , NewData ) {
  2249.  
  2250.     if ( HooksCursor >= MAX_HOOKS ) {
  2251.    
  2252.         MSG_Print( "HooksList is full" )
  2253.    
  2254.         return false
  2255.  
  2256.     }
  2257.  
  2258.     new Cursor = 0
  2259.  
  2260.     while( Cursor < HooksCursor ) {
  2261.    
  2262.         if ( !( HooksList[ Cursor ][ hook_t_valid ] ) )
  2263.        
  2264.             break
  2265.    
  2266.         Cursor++
  2267.  
  2268.     }
  2269.    
  2270.     if ( Cursor == HooksCursor ) {
  2271.  
  2272.         if ( HooksCursor >= MAX_HOOKS ) {
  2273.    
  2274.             MSG_Print( "HooksList is full" )
  2275.        
  2276.             return false
  2277.  
  2278.         }
  2279.        
  2280.         HooksCursor++
  2281.  
  2282.     }
  2283.    
  2284.     HooksList[ Cursor ][ hook_t_valid ] = true
  2285.     HooksList[ Cursor ][ hook_t_base ]      = Base
  2286.     HooksList[ Cursor ][ hook_t_origin ]    = rDWord( Base )
  2287.    
  2288.     wDWordEng( Base , NewData )
  2289.    
  2290.     return true
  2291.  
  2292. }
  2293. stock DeatchEngineHook( Base ) {
  2294.  
  2295.     new Cursor = 0
  2296.  
  2297.     for( Cursor = 0; Cursor < HooksCursor; Cursor++ )
  2298.    
  2299.         if ( ( HooksList[ Cursor ][ hook_t_valid ] ) && ( HooksList[ Cursor ][ hook_t_base ] == Base ) ) {
  2300.                    
  2301.             wDWordEng( HooksList[ Cursor ][ hook_t_base ] , HooksList[ Cursor ][ hook_t_origin ] )
  2302.  
  2303.             HooksList[ Cursor ][ hook_t_valid ] = false
  2304.        
  2305.             break
  2306.        
  2307.         }
  2308.  
  2309.  
  2310. }
  2311. stock DeatchAllEngineHook() {
  2312.  
  2313.     new Cursor = 0
  2314.  
  2315.     for( Cursor = 0; Cursor < HooksCursor; Cursor++ )
  2316.    
  2317.         if ( HooksList[ Cursor ][ hook_t_valid ] ) {
  2318.            
  2319.             wDWordEng( HooksList[ Cursor ][ hook_t_base ] , HooksList[ Cursor ][ hook_t_origin ] )
  2320.  
  2321.             HooksList[ Cursor ][ hook_t_valid ] = false
  2322.            
  2323.         }
  2324.  
  2325. }
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333. stock NewError( Error[] ) {
  2334.  
  2335.     MSG_Error( Error )
  2336.    
  2337.     return false
  2338.  
  2339. }
  2340.  
  2341.  
  2342.  
  2343.  
  2344.  
  2345. static DisAsm_Channel = 0
  2346. static DisAsm_ReadLength = 0
  2347. static DisAsm_CmdSize = 0
  2348. static DisAsm_IsDebug = false
  2349.  
  2350. #define MRM_SIZE    3
  2351. #define MRM_MOD     0
  2352. #define MRM_REG     1
  2353. #define MRM_RM      2
  2354.  
  2355. #define SIB_SIZE    3
  2356. #define SIB_SCALE   0
  2357. #define SIB_INDEX   1
  2358. #define SIB_BASE    2
  2359.  
  2360. stock DisAsm_GetByte() {
  2361.  
  2362.     return rByte( DisAsm_Channel )
  2363.  
  2364. }
  2365. stock DisAsm_Inc( b = 1 ) {
  2366.  
  2367.     DisAsm_Channel += b
  2368.     DisAsm_ReadLength += b
  2369.     DisAsm_CmdSize += b
  2370.  
  2371. }
  2372. stock DisAsm_GetMRM( MRM[] , IfInc = true ) {
  2373.  
  2374.     new b = DisAsm_GetByte()
  2375.  
  2376.     //static MRM[ MRM_SIZE ]
  2377.  
  2378.     MRM[ MRM_MOD ] = ( b >> 6 ) & 3
  2379.     MRM[ MRM_REG ] = ( b >> 3 ) & 7
  2380.     MRM[ MRM_RM  ] = ( b      ) & 7
  2381.  
  2382.     if ( IfInc )
  2383.    
  2384.         DisAsm_Inc()
  2385.    
  2386.     //return MRM
  2387.  
  2388. }
  2389. stock DisAsm_GetSIB( SIB[] , IfInc = true ) {
  2390.  
  2391.     new b = DisAsm_GetByte()
  2392.  
  2393.     //static SIB[ MRM_SIZE ]
  2394.  
  2395.     SIB[ SIB_SCALE ] = ( b >> 6 ) & 3
  2396.     SIB[ SIB_INDEX ] = ( b >> 3 ) & 7
  2397.     SIB[ SIB_BASE  ] = ( b      ) & 7
  2398.  
  2399.     if ( IfInc )
  2400.    
  2401.         DisAsm_Inc()
  2402.    
  2403.     //return SIB
  2404.  
  2405. }
  2406. stock DisAsm_ProcessMRM() {
  2407.  
  2408.  
  2409.     static MRM[ MRM_SIZE ]
  2410.    
  2411.     static SIB[ SIB_SIZE ]
  2412.    
  2413.     DisAsm_GetMRM( MRM )
  2414.  
  2415.     if ( MRM[ MRM_MOD ] == 0 ) {
  2416.        
  2417.         if ( MRM[ MRM_RM ] == 4 ) {
  2418.        
  2419.             DisAsm_GetSIB( SIB )
  2420.                
  2421.             if ( SIB[ SIB_BASE ] == 5 )
  2422.                
  2423.                 DisAsm_Inc( 4 );
  2424.    
  2425.         }
  2426.    
  2427.     } else
  2428.     if  ( MRM[ MRM_MOD ] == 1 ) {
  2429.        
  2430.         if ( MRM[ MRM_RM ] == 4 ) {
  2431.        
  2432.             DisAsm_GetSIB( SIB )
  2433.            
  2434.             DisAsm_Inc()
  2435.        
  2436.         } else
  2437.            
  2438.             DisAsm_Inc();
  2439.    
  2440.     } else
  2441.     if  ( MRM[ MRM_MOD ] == 2 ) {
  2442.    
  2443.         if ( MRM[ MRM_RM ] == 4 ) {
  2444.        
  2445.             DisAsm_GetSIB( SIB )
  2446.            
  2447.             DisAsm_Inc( 4 )
  2448.            
  2449.         } else
  2450.        
  2451.             DisAsm_Inc( 4 )
  2452.            
  2453.     } else
  2454.     if  ( MRM[ MRM_MOD ] == 3 ) {
  2455.    
  2456.    
  2457.     }
  2458.  
  2459. }
  2460.  
  2461. stock DisAsm_Read_Prefix() {
  2462.    
  2463.     new B = DisAsm_GetByte()
  2464.  
  2465.     if (
  2466.         ( B == 0x26 ) ||
  2467.         ( B == 0x26 ) ||
  2468.         ( B == 0x2E ) ||
  2469.         ( B == 0x36 ) ||
  2470.         ( B == 0x3E ) ||
  2471.         ( B == 0x64 ) ||
  2472.         ( B == 0x65 ) ||
  2473.         ( B == 0xF0 ) ||
  2474.         ( B == 0xF2 ) ||
  2475.         ( B == 0xF3 ) ||
  2476.         ( B == 0x66 ) ||
  2477.         ( B == 0x67 ) ||
  2478.         ( B == 0x0F )
  2479.     ) {
  2480.    
  2481.         DisAsm_Inc()
  2482.        
  2483.         return true
  2484.    
  2485.     }
  2486.    
  2487.     return false
  2488.  
  2489. }
  2490. stock DisAsm_Read_CmdOne( B ) {
  2491.  
  2492.     if (
  2493.         ( ( B >= 0x40 ) && ( B <= 0x61 ) ) ||
  2494.         ( ( B >= 0x9B ) && ( B <= 0x9F ) ) ||
  2495.         ( ( B >= 0x90 ) && ( B <= 0x99 ) ) ||
  2496.         ( ( B >= 0x6C ) && ( B <= 0x6F ) ) ||
  2497.         ( ( B >= 0xA4 ) && ( B <= 0xA7 ) ) ||
  2498.         ( ( B >= 0xAA ) && ( B <= 0xAF ) ) ||
  2499.         ( ( B >= 0xEC ) && ( B <= 0xF5 ) ) ||
  2500.         ( ( B >= 0xF8 ) && ( B <= 0xFD ) ) ||
  2501.         ( B == 0x06 ) ||
  2502.         ( B == 0x07 ) ||
  2503.         ( B == 0x0E ) ||
  2504.         ( B == 0x16 ) ||
  2505.         ( B == 0x17 ) ||
  2506.         ( B == 0x1E ) ||
  2507.         ( B == 0x1F ) ||
  2508.         ( B == 0x27 ) ||
  2509.         ( B == 0x2F ) ||
  2510.         ( B == 0x37 ) ||
  2511.         ( B == 0x3F ) ||
  2512.         ( B == 0xC3 ) ||
  2513.         ( B == 0xC9 ) ||
  2514.         ( B == 0xCB ) ||
  2515.         ( B == 0xCC ) ||
  2516.         ( B == 0xCE ) ||
  2517.         ( B == 0xCF ) ||
  2518.         ( B == 0xD6 ) ||
  2519.         ( B == 0xD7 )
  2520.     ) {
  2521.    
  2522.         DisAsm_Inc()
  2523.        
  2524.         return true
  2525.    
  2526.     }
  2527.    
  2528.     return false
  2529.  
  2530. }
  2531. stock DisAsm_Read_CmdMrmOrigin( B ) {
  2532.  
  2533.     if (
  2534.         ( ( B >= 0x00 ) && ( B <= 0x03 ) ) ||
  2535.         ( ( B >= 0x08 ) && ( B <= 0x0B ) ) ||
  2536.         ( ( B >= 0x10 ) && ( B <= 0x13 ) ) ||
  2537.         ( ( B >= 0x18 ) && ( B <= 0x1B ) ) ||
  2538.         ( ( B >= 0x20 ) && ( B <= 0x23 ) ) ||
  2539.         ( ( B >= 0x28 ) && ( B <= 0x2B ) ) ||
  2540.         ( ( B >= 0x30 ) && ( B <= 0x33 ) ) ||
  2541.         ( ( B >= 0x38 ) && ( B <= 0x3B ) ) ||
  2542.         ( ( B >= 0x62 ) && ( B <= 0x63 ) ) ||
  2543.         ( ( B >= 0x84 ) && ( B <= 0x8E ) ) ||
  2544.         ( ( B >= 0xC4 ) && ( B <= 0xC5 ) )
  2545.     ) {
  2546.  
  2547.         DisAsm_Inc()
  2548.        
  2549.         DisAsm_ProcessMRM()
  2550.        
  2551.         return true
  2552.  
  2553.     }
  2554.    
  2555.     return false
  2556.  
  2557. }
  2558. stock DisAsm_Read_CmdData1( B ) {
  2559.  
  2560.     if (
  2561.         ( ( B >= 0xB0) && ( B <= 0xB7 ) ) ||
  2562.         ( ( B >= 0xE0) && ( B <= 0xE7 ) ) ||
  2563.         ( ( B >= 0x70) && ( B <= 0x7F ) ) ||
  2564.         ( B == 0x04 ) ||
  2565.         ( B == 0x0C ) ||
  2566.         ( B == 0x14 ) ||
  2567.         ( B == 0x1C ) ||
  2568.         ( B == 0x24 ) ||
  2569.         ( B == 0x2C ) ||
  2570.         ( B == 0x34 ) ||
  2571.         ( B == 0x3C ) ||
  2572.         ( B == 0x6A ) ||
  2573.         ( B == 0xA8 ) ||
  2574.         ( B == 0xCD )
  2575.     ) {
  2576.    
  2577.         DisAsm_Inc()
  2578.  
  2579.         DisAsm_Inc()
  2580.        
  2581.         return true
  2582.    
  2583.     }
  2584.    
  2585.     return false
  2586.  
  2587. }
  2588. stock DisAsm_Read_CmdData2i4( B ) {
  2589.  
  2590.     if (
  2591.         ( ( B >= 0xA0 ) && ( B <= 0xA3 ) ) ||
  2592.         ( ( B >= 0xB8 ) && ( B <= 0xBF ) ) ||
  2593.         ( B == 0x05 ) ||
  2594.         ( B == 0x0D ) ||
  2595.         ( B == 0x15 ) ||
  2596.         ( B == 0x1D ) ||
  2597.         ( B == 0x25 ) ||
  2598.         ( B == 0x2D ) ||
  2599.         ( B == 0x35 ) ||
  2600.         ( B == 0x3D ) ||
  2601.         ( B == 0x68 ) ||
  2602.         ( B == 0xA9 ) ||
  2603.         ( B == 0xE8 ) ||
  2604.         ( B == 0xE9 )
  2605.     ) {
  2606.  
  2607.         DisAsm_Inc()
  2608.            
  2609.         DisAsm_Inc( 4 )
  2610.  
  2611.         return true
  2612.        
  2613.     }
  2614.    
  2615.     return false
  2616.    
  2617. }
  2618. stock DisAsm_Read_CmdMrmData1( B ) {
  2619.  
  2620.     if ( B == 0x69 ) {
  2621.  
  2622.         DisAsm_Inc()
  2623.  
  2624.         DisAsm_ProcessMRM()
  2625.        
  2626.         DisAsm_Inc( 4 )
  2627.        
  2628.         return true
  2629.        
  2630.     }
  2631.  
  2632.     return false
  2633.  
  2634. }
  2635. stock DisAsm_Read_CmdNnnData1( B ) {
  2636.  
  2637.     if (
  2638.         ( B == 0x80 ) ||
  2639.         ( B == 0x82 ) ||
  2640.         ( B == 0x83 ) ||
  2641.         ( B == 0xC0 ) ||
  2642.         ( B == 0xC1 ) ||
  2643.         ( B == 0xC6 )
  2644.     ) {
  2645.    
  2646.         DisAsm_Inc()
  2647.  
  2648.         DisAsm_ProcessMRM()
  2649.        
  2650.         DisAsm_Inc()
  2651.        
  2652.         return true
  2653.    
  2654.     }
  2655.    
  2656.     return false
  2657.  
  2658. }
  2659. stock DisAsm_Read_CmdNnnData2i4( B ) {
  2660.  
  2661.     if (
  2662.             ( B == 0x81 ) ||
  2663.             ( B == 0xC7 )
  2664.         ) {
  2665.    
  2666.         DisAsm_Inc()
  2667.  
  2668.         static MRM[ MRM_SIZE ]
  2669.        
  2670.         static SIB[ SIB_SIZE ]
  2671.        
  2672.         DisAsm_GetMRM( MRM )
  2673.  
  2674.         if ( MRM[ MRM_MOD ] == 0 ) {
  2675.            
  2676.             if ( MRM[ MRM_RM ] == 4 ) {
  2677.            
  2678.                 DisAsm_GetSIB( SIB )
  2679.                    
  2680.                 if ( SIB[ SIB_BASE ] == 5 )
  2681.                    
  2682.                     DisAsm_Inc( 4 )
  2683.        
  2684.             } else
  2685.                
  2686.                 DisAsm_Inc( 4 )
  2687.        
  2688.         } else
  2689.         if  ( MRM[ MRM_MOD ] == 1 ) {
  2690.            
  2691.             if ( MRM[ MRM_RM ] == 4 ) {
  2692.            
  2693.                 DisAsm_GetSIB( SIB )
  2694.            
  2695.                 DisAsm_Inc()
  2696.            
  2697.             } else
  2698.                
  2699.                 DisAsm_Inc()
  2700.        
  2701.         } else
  2702.         if  ( MRM[ MRM_MOD ] == 2 ) {
  2703.        
  2704.             if ( MRM[ MRM_RM ] == 4 ) {
  2705.            
  2706.                 DisAsm_GetSIB( SIB )
  2707.            
  2708.                 DisAsm_Inc( 4 )
  2709.                
  2710.             } else
  2711.            
  2712.                 DisAsm_Inc( 4 )
  2713.                
  2714.         } else
  2715.         if  ( MRM[ MRM_MOD ] == 3 ) {
  2716.        
  2717.        
  2718.         }
  2719.  
  2720.         DisAsm_Inc( 4 )
  2721.        
  2722.         return true
  2723.        
  2724.     }
  2725.    
  2726.     return false
  2727.    
  2728. }
  2729.  
  2730. stock DisAsm_Reset() {
  2731.    
  2732.     DisAsm_CmdSize = 0
  2733.  
  2734. }
  2735. stock DisAsm_Init( Addr ) {
  2736.  
  2737.     DisAsm_Channel = Addr
  2738.     DisAsm_ReadLength = 0
  2739.     DisAsm_Reset()
  2740.  
  2741. }
  2742. stock DisAsm_DebugShow( t ) {
  2743.  
  2744.     if ( DisAsm_IsDebug ) {
  2745.        
  2746.         if ( t == 0 ) {
  2747.  
  2748.             server_print( "[OST] ---------------------------------------------" )
  2749.             server_print( "[OST] Addr   = 0x%s" , GetDWordHex( DisAsm_Channel ) )
  2750.             server_print( "[OST] Opcode = 0x%s" , GetDWordHex( rByte(DisAsm_Channel) ) )
  2751.        
  2752.         } else
  2753.        
  2754.         if ( t == 1 ) {
  2755.        
  2756.             server_print( "[OST] Size cmd = 0x%s" , GetDWordHex( DisAsm_CmdSize ) )
  2757.             server_print( "[OST] Milc cmd = 0x%s" , GetDWordHex( DisAsm_ReadLength ) )
  2758.        
  2759.         }
  2760.        
  2761.         if ( t == 2 ) {
  2762.        
  2763.             server_print( "[OST] Size cmd = 0x%s" , GetDWordHex( DisAsm_CmdSize ) )
  2764.             server_print( "[OST] Milc cmd = 0x%s" , GetDWordHex( DisAsm_ReadLength ) )
  2765.  
  2766.             server_print( "[OST] ---------------------------------------------" )
  2767.             server_print( "[OST] Addr   = 0x%s" , GetDWordHex( DisAsm_Channel ) )
  2768.             server_print( "[OST] Opcode = 0x%s" , GetDWordHex( rByte(DisAsm_Channel) ) )
  2769.        
  2770.         }
  2771.        
  2772.     }
  2773.  
  2774. }
  2775. stock DisAsm_Read_Cmd() {
  2776.  
  2777.     DisAsm_Reset()
  2778.  
  2779.     while( DisAsm_Read_Prefix() ) {}
  2780.    
  2781.     new Cmd = DisAsm_GetByte()
  2782.  
  2783.     if (
  2784.         ( DisAsm_Read_CmdOne( Cmd )        ) ||
  2785.         ( DisAsm_Read_CmdMrmOrigin( Cmd )  ) ||
  2786.         ( DisAsm_Read_CmdData1( Cmd )      ) ||
  2787.         ( DisAsm_Read_CmdData2i4( Cmd )    ) ||
  2788.         ( DisAsm_Read_CmdMrmData1( Cmd )   ) ||
  2789.         ( DisAsm_Read_CmdNnnData1( Cmd )   ) ||
  2790.         ( DisAsm_Read_CmdNnnData2i4( Cmd ) )
  2791.     )
  2792.    
  2793.             return true;
  2794.  
  2795.     return false;
  2796.  
  2797. }
  2798. stock DisAsm_GetMinLen( Addr , Len = 5 ) {
  2799.  
  2800.     DisAsm_Init( Addr )
  2801.    
  2802.     DisAsm_DebugShow( 0 )
  2803.  
  2804.     while( DisAsm_Read_Cmd() ) {
  2805.    
  2806.         if ( DisAsm_ReadLength >= Len ) {
  2807.        
  2808.             DisAsm_DebugShow( 1 )
  2809.            
  2810.             return DisAsm_ReadLength
  2811.            
  2812.         }
  2813.  
  2814.         DisAsm_DebugShow( 2 )
  2815.    
  2816.     }
  2817.    
  2818.     return -1;
  2819.  
  2820. }
  2821.  
  2822. #define DETOURS_DATA_MAX    1024
  2823. enum detours_t {
  2824.     detours_t_valid ,
  2825.     detours_t_base ,
  2826.     detours_t_size ,
  2827.     detours_t_origin
  2828. }
  2829. static Detours_Data[ DETOURS_DATA_MAX ][ detours_t ]
  2830. static Derouts_Cursor = 0
  2831. stock Detours_Attach( Addr , NewAddr ) {
  2832.  
  2833.     new MinLength = DisAsm_GetMinLen( Addr )
  2834.  
  2835.     if ( MinLength == -1 )
  2836.  
  2837.         return 0;
  2838.  
  2839.     new Gate = Malloc( MinLength + 5 )
  2840.  
  2841.     new i
  2842.  
  2843.     for ( i = 0; i < MinLength; i++ )
  2844.  
  2845.         wByte( Gate + i , rByte( Addr + i ) )
  2846.  
  2847.  
  2848.  
  2849.     wByte( Gate + MinLength , 0xE9 )
  2850.  
  2851.     wDWord( Gate + MinLength + 1 , (Addr + MinLength) - (Gate + MinLength + 1) - 4 )
  2852.  
  2853.  
  2854.  
  2855.     wByteEng( Addr , 0xE9 )
  2856.  
  2857.     wDWordEng( (Addr + 1) , NewAddr - (Addr + 1) - 4 )
  2858.  
  2859.  
  2860.    
  2861.     for( i = 0; i < Derouts_Cursor; i++ )
  2862.  
  2863.         if ( !( Detours_Data[ i ][ detours_t_valid ] ) ) {
  2864.        
  2865.             Detours_Data[ i ][ detours_t_valid ]    =   true
  2866.             Detours_Data[ i ][ detours_t_base ]     =   Addr
  2867.             Detours_Data[ i ][ detours_t_size ]     =   MinLength
  2868.             Detours_Data[ i ][ detours_t_origin ]   =   Gate
  2869.            
  2870.             return Gate
  2871.        
  2872.         }
  2873.  
  2874.     if ( Derouts_Cursor >= DETOURS_DATA_MAX ) {
  2875.  
  2876.         NewError( "Detours data is full" )
  2877.  
  2878.         return Gate
  2879.  
  2880.     }
  2881.  
  2882.     Detours_Data[ Derouts_Cursor ][ detours_t_valid ]   =   true
  2883.     Detours_Data[ Derouts_Cursor ][ detours_t_base ]    =   Addr
  2884.     Detours_Data[ Derouts_Cursor ][ detours_t_size ]    =   MinLength
  2885.     Detours_Data[ Derouts_Cursor ][ detours_t_origin ]  =   Gate
  2886.  
  2887.     Derouts_Cursor++
  2888.  
  2889.     return Gate
  2890.  
  2891. }
  2892. stock Detours_Deatch( Addr ) {
  2893.  
  2894.     new i
  2895.    
  2896.     for( i = 0; i < Derouts_Cursor; i++ )
  2897.  
  2898.         if ( ( Detours_Data[ i ][ detours_t_valid ] ) && ( Detours_Data[ i ][ detours_t_base ] == Addr ) ) {
  2899.        
  2900.             new j
  2901.            
  2902.             for( j = 0; j < 5; j++ )
  2903.            
  2904.                 wByteEng( Detours_Data[ i ][ detours_t_base ] + j , rByte( Detours_Data[ i ][ detours_t_origin ] + j ) )
  2905.        
  2906.             Detours_Data[ i ][ detours_t_valid ]    =   false
  2907.            
  2908.             return true
  2909.        
  2910.         }
  2911.        
  2912.     return false
  2913.  
  2914. }
  2915. stock Detours_DeatchAll() {
  2916.  
  2917.     new i
  2918.    
  2919.     for( i = 0; i < Derouts_Cursor; i++ )
  2920.  
  2921.         if ( Detours_Data[ i ][ detours_t_valid ] ) {
  2922.        
  2923.             new j
  2924.            
  2925.             for( j = 0; j < 5; j++ )
  2926.            
  2927.                 wByteEng( Detours_Data[ i ][ detours_t_base ] + j , rByte( Detours_Data[ i ][ detours_t_origin ] + j ) )
  2928.        
  2929.             Detours_Data[ i ][ detours_t_valid ]    =   false
  2930.  
  2931.         }
  2932.  
  2933.     return true
  2934.  
  2935. }
  2936.  
  2937.  
  2938.  
  2939.  
  2940. /*    ############################################################## Try Files ##############################################################   */
  2941. /*
  2942.  
  2943.  
  2944. function __CopyBegin: Cardinal;
  2945. asm
  2946.  db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF
  2947.  db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF
  2948. end;
  2949. {****************************************************************************************************************}
  2950. {****************************************************************************************************************}
  2951. {****************************************************************************************************************}
  2952. {****************************************************************************************************************}
  2953. {****************************************************************************************************************}
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962. const
  2963.   MAX_FILE_NAME       = 64;
  2964.   SIZE_MD5            = 16;
  2965.   SIZE_RESERVED       = 32;
  2966.   COUNT_RESOURCE      = $500;
  2967.   MAX_PLAYER_NAME     = 32;
  2968.  
  2969. type
  2970.  filename_s = ^filename_t;
  2971.  filename_t = Array[0..(MAX_FILE_NAME-1)] of AnsiChar;
  2972.  
  2973. type
  2974.  resourcetype_t = (t_sound, t_skin, t_model, t_decal, t_generic, t_eventscript, t_world);
  2975.  
  2976. type
  2977.  md5hash_s = ^md5hash_t;
  2978.  md5hash_t = Array[0..(SIZE_MD5-1)] of Byte;
  2979.  
  2980. type
  2981.  reserved_s = ^reserved_t;
  2982.  reserved_t = Array[0..(SIZE_RESERVED-1)] of Byte;
  2983.  
  2984. type
  2985.  resource_s = ^resource_t;
  2986.  resource_t = Record
  2987.   FileName:     filename_t;
  2988.   ResourceType: resourcetype_t;
  2989.   Index:        Cardinal;
  2990.   DownloadSize: Cardinal;
  2991.   Flags:        Byte;
  2992.   MD5Hash:      md5hash_t;
  2993.   PlayerNum:    Byte;
  2994.   Reserved:     reserved_t;
  2995.   pNext:        resource_s;
  2996.   pPrev:        resource_s;
  2997.  End;
  2998.  
  2999. type
  3000.  sizebuf_s = ^sizebuf_t;
  3001.  sizebuf_t = Record
  3002.   AllowOverflow, Overflowed: Longint;
  3003.   Data: PByte;
  3004.   MaxSize, CurrentSize: Longint;
  3005.  End;
  3006.  
  3007.  
  3008. type
  3009.  array_resource_s = ^array_resource_t;
  3010.  array_resource_t = Array[0..(COUNT_RESOURCE-1)] of resource_t;
  3011.  
  3012. function __strlen(s: Cardinal): Cardinal;
  3013. asm
  3014.   push EDI
  3015.   pushf
  3016.  
  3017.   mov EDI , EAX
  3018.   xor AL , AL
  3019.   mov ECX , 65536
  3020.   cld
  3021.   repne scasb
  3022.   je @_return
  3023.   mov EAX , 0
  3024.  
  3025.   popf
  3026.   pop EDI
  3027.   ret
  3028.  
  3029. @_return:
  3030.   mov EAX , 65535
  3031.   sub EAX , ECX
  3032.  
  3033.   popf
  3034.   pop EDI
  3035. end;
  3036. function __copy(d, s, size: Cardinal): Cardinal;
  3037. asm
  3038.   push ESI
  3039.   push EDI
  3040.   push EBX
  3041.   pushf
  3042.  
  3043.   mov EBX , ECX
  3044.   and ECX , $FFFFFFFC
  3045.   sub EBX , ECX
  3046.   shr ECX , 2
  3047.  
  3048.   mov EDI , EAX
  3049.   mov ESI , EDX
  3050.   cld
  3051.   rep movsd
  3052.  
  3053.   mov ECX , EBX
  3054.   rep movsb
  3055.  
  3056.   popf
  3057.   pop EBX
  3058.   pop EDI
  3059.   pop ESI
  3060. end;
  3061. function __equal(m1, m2, size: Cardinal): Cardinal;
  3062. asm
  3063.   push ESI
  3064.   push EDI
  3065.   push EBX
  3066.   pushf
  3067.  
  3068.   mov EBX , ECX
  3069.   and ECX , $FFFFFFFC
  3070.   sub EBX , ECX
  3071.   shr ECX , 2
  3072.  
  3073.   mov EDI , EAX
  3074.   mov ESI , EDX
  3075.   cld
  3076.   repe cmpsd
  3077.   jnz @_not_equal
  3078.  
  3079.   mov ECX , EBX
  3080.   repe cmpsb
  3081.   jnz @_not_equal
  3082.  
  3083.   mov EAX , 1
  3084.   jmp @_exit
  3085.  
  3086. @_not_equal:
  3087.   xor EAX , EAX
  3088.  
  3089. @_exit:
  3090.  
  3091.   popf
  3092.   pop EBX
  3093.   pop EDI
  3094.   pop ESI
  3095. end;
  3096. function __fill( symbol , base , size : Cardinal ): Cardinal;
  3097. asm
  3098.   push EDI
  3099.   push EBX
  3100.   pushf
  3101.  
  3102.   and EAX , $FF
  3103.   mov EDI , EAX
  3104.   shl EDI , 8
  3105.   or EAX , EDI
  3106.   shl EDI , 8
  3107.   or EAX , EDI
  3108.   shl EDI , 8
  3109.   or EAX , EDI
  3110.  
  3111.   mov EBX , ECX
  3112.   and ECX , $FFFFFFFC
  3113.   sub EBX , ECX
  3114.   shr ECX , 2
  3115.  
  3116.   mov EDI , EDX
  3117.   cld
  3118.   rep stosd
  3119.  
  3120.   mov ECX , EBX
  3121.   rep stosb
  3122.  
  3123.   popf
  3124.   pop EBX
  3125.   pop EDI
  3126. end;
  3127. function __find(m_base, m_end, p_base, p_size, offset: Cardinal): Cardinal;
  3128. var
  3129.   i, _c, _p: Cardinal;
  3130. begin
  3131.  
  3132.   Dec(m_end, p_size);
  3133.  
  3134.   _p := p_size;
  3135.   Dec(_p);
  3136.  
  3137.   for m_base := m_base to m_end do
  3138.   begin
  3139.  
  3140.     for i := 0 to _p do
  3141.     begin
  3142.  
  3143.       _c := PByte(p_base + i)^;
  3144.  
  3145.       if (_c = $FF) then
  3146.         continue;
  3147.  
  3148.       if (not(_c = PByte(m_base + i)^)) then
  3149.         break;
  3150.  
  3151.     end;
  3152.  
  3153.     if (i = p_size) then
  3154.     begin
  3155.       Result := m_base + offset;
  3156.       Exit;
  3157.     end;
  3158.  
  3159.   end;
  3160.  
  3161.   Result := 0;
  3162.   Exit;
  3163.  
  3164. end;
  3165.  
  3166. type
  3167.  buffer_s = ^buffer_t;
  3168.  buffer_t = Record
  3169.   Mem:    Cardinal;
  3170.   Size:   Cardinal;
  3171.   Cursor: PCardinal;
  3172.   WrByte: Cardinal;
  3173.   WrBits: Cardinal;
  3174.   WrSize: Cardinal;
  3175.  End;
  3176.  
  3177. procedure MSG_WriteStart( Buf: buffer_s; Mem , Size: Cardinal );
  3178. begin
  3179.  
  3180.  Buf^.Mem    := Mem;
  3181.  Buf^.Cursor := Pointer(Mem);
  3182.  Buf^.Size   := Size;
  3183.  Buf^.WrByte := 0;
  3184.  Buf^.WrBits := 0;
  3185.  
  3186.  __fill( 0 , Mem , Size );
  3187.  
  3188. end;
  3189. procedure MSG_WriteBitsEnd( Buf: buffer_s );
  3190. begin
  3191.  if ( Buf^.WrBits > 0 ) then
  3192.   begin
  3193.    Buf^.WrBits := 0;
  3194.    Inc( Cardinal( Buf^.Cursor ) );
  3195.   end;
  3196. end;
  3197. procedure MSG_WriteEnd( Buf: buffer_s );
  3198. begin
  3199.  
  3200.  MSG_WriteBitsEnd( Buf );
  3201.  
  3202.  Buf^.WrSize := Cardinal(Buf^.Cursor) - Buf^.Mem;
  3203.  
  3204. end;
  3205. procedure MSG_WriteBits( Buf: buffer_s; Bit , n: Cardinal );
  3206. begin
  3207.  
  3208.  if ( n > 24 ) then
  3209.   begin
  3210.    MSG_WriteBits( Buf , Bit , 24 );
  3211.    MSG_WriteBits( Buf , Bit shr 24 , n - 24 );
  3212.    Exit;
  3213.   end;
  3214.  
  3215.  Bit := Bit and ( ( 1 shl n ) - 1 );
  3216.  
  3217.  Buf^.Cursor^ := Buf^.Cursor^ or ( Bit shl Buf^.WrBits );
  3218.  
  3219.  Inc( Buf^.WrBits , n );
  3220.  
  3221.  Inc( Cardinal( Buf^.Cursor ) , Buf^.WrBits shr 3 );
  3222.  
  3223.  Buf^.WrBits := Buf^.WrBits and (8-1);
  3224.  
  3225. end;
  3226. procedure MSG_WriteBuffer( Buf: buffer_s; Mem , Size: Cardinal );
  3227. var
  3228.  i , size3: Cardinal;
  3229. begin
  3230.  
  3231.  i := 0;
  3232.  
  3233.  if ( Size >= 3 ) then
  3234.   begin
  3235.  
  3236.    size3 := Size - ( Size mod 3 );
  3237.  
  3238.    while( not( i = size3 ) ) do
  3239.     begin
  3240.      MSG_WriteBits( Buf , PCardinal(Mem + i)^ , 24 );
  3241.      Inc( i , 3 );
  3242.     end;
  3243.  
  3244.   end;
  3245.  
  3246.  while( not( i = Size ) ) do
  3247.   begin
  3248.    MSG_WriteBits( Buf , PByte(Mem + i)^ , 8 );
  3249.    Inc( i );
  3250.   end;
  3251.  
  3252. end;
  3253. procedure MSG_WritePString( Buf: buffer_s; Mem: Cardinal; MaxLen: Cardinal = 65536 );
  3254. var
  3255.  len: Cardinal;
  3256. begin
  3257.  
  3258.  len := __strlen( Mem );
  3259.  
  3260.  if ( len > MaxLen ) then
  3261.  
  3262.   len := MaxLen;
  3263.  
  3264.  MSG_WriteBuffer( Buf , Mem , len );
  3265.  
  3266.  MSG_WriteBits( Buf , 0 , 8 );
  3267.  
  3268. end;
  3269. procedure MSG_WriteByte( Buf: buffer_s; B: Cardinal );
  3270. begin
  3271.  MSG_WriteBits( Buf , B , 8 );
  3272. end;
  3273. procedure MSG_WriteWord( Buf: buffer_s; W: Cardinal );
  3274. begin
  3275.  MSG_WriteBits( Buf , W , 16 );
  3276. end;
  3277. procedure MSG_WriteDWord( Buf: buffer_s; DW: Cardinal );
  3278. begin
  3279.  MSG_WriteBits( Buf , DW , 32 );
  3280. end;
  3281.  
  3282. type
  3283.  memory_s = ^memory_t;
  3284.  memory_t = Record
  3285.   Memory:   Cardinal;
  3286.   MaxSize:  Cardinal;
  3287.   CurrSize: Cardinal;
  3288.  End;
  3289.  
  3290. const
  3291.  MAX_SCRIPTS = 1024;
  3292.  SI_NORMAL   = 0;
  3293.  SI_INVERT   = 1;
  3294.  SM_PREV     = 0;
  3295.  SM_CONST    = 1;
  3296.  SM_ALL      = 2;
  3297.  
  3298. type
  3299.  script_player_item_s = ^script_player_item_t;
  3300.  script_player_item_t = Record
  3301.   si_data: Cardinal;
  3302.   sm_data: Cardinal;
  3303.   md_data: Cardinal;
  3304.  End;
  3305.  
  3306. type
  3307.  script_player_list_s = ^script_player_list_t;
  3308.  script_player_list_t = Record
  3309.   Exec:        Cardinal;
  3310.   ScriptCount: Cardinal;
  3311.   Scripts: Array[0..(MAX_SCRIPTS-1)] of script_player_item_t;
  3312.  End;
  3313.  
  3314. type
  3315.  script_files_s = ^script_files_t;
  3316.  script_files_t = Array[0..(COUNT_RESOURCE-1)] of script_player_list_s;
  3317.  
  3318. type
  3319.  TCbuf_AddText = procedure( Text: Cardinal ); cdecl;
  3320. type
  3321.  info_s = ^info_t;
  3322.  info_t = Record
  3323.   Resources_Base:     array_resource_s;
  3324.   Resources_Count:    PCardinal;
  3325.   ConsiData_Count:    PCardinal;
  3326.  
  3327.   Site:               Cardinal;
  3328.  
  3329.   TryFileName:        Cardinal;
  3330.  
  3331.   CheckFilesCount:    Cardinal;
  3332.   FristIndex:         Cardinal;
  3333.   EndIndex:           Cardinal;
  3334.  
  3335.   Host_CL:            PCardinal;
  3336.   Name_Offset:        Cardinal;
  3337.   IfConsData_Offset:  Cardinal;
  3338.   ServerCount:        PCardinal;
  3339.  
  3340.   FirstSwap:          Cardinal;
  3341.  
  3342.   Scripts:            script_files_s;
  3343.  
  3344.   TempString:         Cardinal;
  3345.  
  3346.   LastIndex:          Cardinal;
  3347.   LastMD5:            Cardinal;
  3348.  
  3349.   Cbuf_AddText:       TCbuf_AddText;
  3350.  
  3351.   Memory:             memory_t;
  3352.  
  3353.  
  3354.   MSG_Buffer:         buffer_t;
  3355.  End;
  3356.  
  3357. procedure SearchTryIndex( Info: info_s );
  3358. var
  3359.  i , Count: Cardinal;
  3360. begin
  3361.  
  3362.  Count := Info^.Resources_Count^ - 1;
  3363.  
  3364.  for i := 0 to Count do
  3365.   if ( __equal( Info^.TryFileName , Cardinal(@(Info^.Resources_Base^[i].FileName[0])) , MAX_FILE_NAME ) <> 0 ) then
  3366.    begin
  3367.     Info^.FristIndex  := i;
  3368.     Info^.EndIndex    := i + Info^.CheckFilesCount + 1;
  3369.     Exit;
  3370.    end;
  3371.  
  3372.  Info^.FristIndex := $FFFFFFFF;
  3373.  
  3374. end;
  3375. procedure SwapResources( Info: info_s );
  3376. var
  3377.  MSG_Buffer:  buffer_s;
  3378.  i: Int32;
  3379.  Count: Int32;
  3380.  Temp: Cardinal;
  3381.  TempSUB: Cardinal;
  3382.  Resource: resource_s;
  3383.  NullReserved: reserved_t;
  3384. begin
  3385.  
  3386.  __fill( 0 , Cardinal(@(NullReserved[0])) , SIZE_RESERVED );
  3387.  
  3388.  MSG_Buffer  := @Info^.MSG_Buffer;
  3389.  
  3390.  MSG_WriteStart( MSG_Buffer , Info^.Memory.Memory , Info^.Memory.MaxSize );
  3391.  
  3392.  MSG_WriteByte(  MSG_Buffer , $2D                );
  3393.  MSG_WriteDWord( MSG_Buffer , Info^.ServerCount^ );
  3394.  MSG_WriteDWord( MSG_Buffer , 0                  );
  3395.  
  3396.  if ( Info^.Site = 0 ) then
  3397.   MSG_WriteByte(  MSG_Buffer , $2B                )
  3398.  else
  3399.   begin
  3400.    MSG_WriteByte(  MSG_Buffer , $38                );
  3401.    MSG_WritePString( MSG_Buffer , Info^.Site );
  3402.    MSG_WriteByte(  MSG_Buffer , $2B                );
  3403.   end;
  3404.  
  3405.  MSG_WriteBits(  MSG_Buffer , Info^.Resources_Count^ , $0C );
  3406.  
  3407.  Count := Info^.Resources_Count^-1;
  3408.  
  3409.  for i := 0 to Count do
  3410.   begin
  3411.  
  3412.    Resource := @( Info^.Resources_Base^[ i ] );
  3413.  
  3414.    MSG_WriteBits( MSG_Buffer , Byte( Resource^.ResourceType ) , 4 );
  3415.  
  3416.    MSG_WritePString( MSG_Buffer , Cardinal(@(Resource^.FileName[0])) , MAX_FILE_NAME );
  3417.  
  3418.    MSG_WriteBits( MSG_Buffer , Resource^.Index , $0C );
  3419.  
  3420.    MSG_WriteBits( MSG_Buffer , Resource^.DownloadSize , $18 );
  3421.  
  3422.    MSG_WriteBits( MSG_Buffer , Resource^.Flags , $3 );
  3423.  
  3424.    if ( ( Resource^.Flags and 4 ) <> 0 ) then
  3425.     MSG_WriteBuffer( MSG_Buffer , Cardinal(@(Resource^.MD5Hash[0])) , $10 );
  3426.  
  3427.    if ( __equal( Cardinal(@(Resource^.Reserved[0])) , Cardinal(@(NullReserved[0])) , SIZE_RESERVED ) = 0 ) then
  3428.     begin
  3429.      MSG_WriteBits( MSG_Buffer , 1 , 1 );
  3430.      MSG_WriteBuffer( MSG_Buffer , Cardinal(@(Resource^.Reserved[0])) , $20 );
  3431.     end
  3432.    else
  3433.      MSG_WriteBits( MSG_Buffer , 0 , 1 );
  3434.  
  3435.   end;
  3436.  
  3437.  
  3438.  if ( Info^.ConsiData_Count^ = 0 ) then
  3439.   begin
  3440.    PByte( Info^.Host_CL^ + Info^.IfConsData_Offset )^ := 0;
  3441.  
  3442.    MSG_WriteBits( MSG_Buffer , 0 , 1 );
  3443.   end
  3444.  else
  3445.   begin
  3446.    PByte( Info^.Host_CL^ + Info^.IfConsData_Offset )^ := 1;
  3447.  
  3448.    MSG_WriteBits( MSG_Buffer , 1 , 1 );
  3449.  
  3450.    Temp := 0;
  3451.  
  3452.    Count := Info^.Resources_Count^ - 1;
  3453.  
  3454.    for i := 0 to Count do
  3455.     begin
  3456.  
  3457.      if ( ( Info^.Resources_Base^[i].Flags and $80 ) = 0 ) then
  3458.       continue;
  3459.  
  3460.      TempSUB := i - Temp;
  3461.      Temp := i;
  3462.  
  3463.      MSG_WriteBits( MSG_Buffer , 1 , 1 );
  3464.  
  3465.      if ( TempSUB > $1F ) then
  3466.       begin
  3467.        MSG_WriteBits( MSG_Buffer , 0 , 1 );
  3468.        MSG_WriteBits( MSG_Buffer , Temp , $0A );
  3469.       end
  3470.      else
  3471.       begin
  3472.        MSG_WriteBits( MSG_Buffer , 1 , 1 );
  3473.        MSG_WriteBits( MSG_Buffer , TempSUB , 5 );
  3474.       end;
  3475.  
  3476.     end;
  3477.  
  3478.    MSG_WriteBits( MSG_Buffer , 0 , 1 );
  3479.  
  3480.   end;
  3481.  
  3482.  MSG_WriteEnd( MSG_Buffer );
  3483.  
  3484.  Info^.Memory.CurrSize := Info^.MSG_Buffer.WrSize;
  3485.  
  3486.  
  3487.  
  3488. end;
  3489.  
  3490. procedure SV_SendResources( sz: sizebuf_s ); cdecl;
  3491. var
  3492.  Info: info_s;
  3493. begin
  3494.  
  3495.  Info := Pointer( $11111111 );
  3496.  
  3497.  if ( not( Info^.FirstSwap = 0 ) ) then
  3498.   begin
  3499.    SearchTryIndex( Info );
  3500.    SwapResources( Info );
  3501.    Info^.FirstSwap := 0;
  3502.   end;
  3503.  
  3504.  sz^.Data        := Pointer( Info^.Memory.Memory );
  3505.  sz^.CurrentSize := Info^.Memory.CurrSize - 3;
  3506.  
  3507. end;
  3508.  
  3509. procedure ReplaceAllName( PlayerName , Base , Size: Cardinal );
  3510. var
  3511.  Buffer: Array[0..(4096*4)] of Byte;
  3512.  PlayerNameLength: Cardinal;
  3513.  i: Cardinal;
  3514.  Predel: Cardinal;
  3515. begin
  3516.  
  3517.  PlayerNameLength := __strlen( PlayerName );
  3518.  
  3519.  if ( PlayerNameLength > MAX_PLAYER_NAME ) then
  3520.   PlayerNameLength := MAX_PLAYER_NAME;
  3521.  
  3522.  Predel := Base + Size - 2;
  3523.  
  3524.  i := Base;
  3525.  
  3526.  while( i <= Predel ) do
  3527.   begin
  3528.  
  3529.     if ( PWord( i )^ = $6E25 ) then    //  search %n
  3530.      begin
  3531.       __copy( Cardinal(@(Buffer[0])) , i + 2 , Predel - i );
  3532.       __copy( i , PlayerName , PlayerNameLength );
  3533.       __copy( i + PlayerNameLength , Cardinal(@(Buffer[0])) , Predel - i );
  3534.       Inc( i , PlayerNameLength );
  3535.       Inc( Predel , PlayerNameLength );
  3536.      end
  3537.     else
  3538.      Inc( i );
  3539.  
  3540.   end;
  3541.  
  3542. end;
  3543. procedure ReplaceAllMD5( MD5 , Base , Size: Cardinal );
  3544. var
  3545.  Buffer: Array[0..(4096*4)] of Byte;
  3546.  i: Cardinal;
  3547.  Predel: Cardinal;
  3548. begin
  3549.  
  3550.  Predel := Base + Size - 2;
  3551.  
  3552.  i := Base;
  3553.  
  3554.  while( i <= Predel ) do
  3555.   begin
  3556.  
  3557.     if ( PWord( i )^ = $6D25 ) then    //  search %m
  3558.      begin
  3559.       __copy( Cardinal(@(Buffer[0])) , i + 2 , Predel - i );
  3560.       __copy( i , Cardinal(@(MD5)) , 4 );
  3561.       __copy( i + 4 , Cardinal(@(Buffer[0])) , Predel - i );
  3562.       Inc( i , 4 );
  3563.       Inc( Predel , 4 );
  3564.      end
  3565.     else
  3566.      Inc( i );
  3567.  
  3568.   end;
  3569.  
  3570. end;
  3571. procedure RJ_Player( Info: info_s; MD5 , ExecString , TempString: Cardinal );
  3572. var
  3573.  Length:  Cardinal;
  3574.  PosName: Cardinal;
  3575.  PosMD5:  Cardinal;
  3576. begin
  3577.  
  3578.  Length := __strlen( ExecString );
  3579.  
  3580.  __copy( TempString , ExecString , Length );
  3581.  
  3582.  ReplaceAllName( Info^.Host_CL^ + Info^.Name_Offset , TempString , Length );
  3583.  
  3584.  Length := __strlen( TempString );
  3585.  
  3586.  ReplaceAllMD5( MD5 , TempString , Length );
  3587.  
  3588.  Info^.Cbuf_AddText( TempString );
  3589.  
  3590. end;
  3591. procedure TryScript( Info: info_s; MD5 , Exec: Cardinal; Script: script_player_item_s );
  3592. begin
  3593.  
  3594.  if ( Script^.si_data = SI_NORMAL ) then
  3595.   begin
  3596.    RJ_Player( Info , MD5 , Exec , Info^.TempString );
  3597.    Exit;
  3598.   end;
  3599.  
  3600.  if ( Script^.si_data = SI_INVERT ) then
  3601.   begin
  3602.    Exit;
  3603.   end;
  3604.  
  3605. end;
  3606. procedure PlayerProcess( Info: info_s; Index: Cardinal; MD5: Cardinal );
  3607. var
  3608.  ScriptList: script_player_list_s;
  3609.  Script: script_player_item_s;
  3610.  Count: Int32;
  3611.  i: Int32;
  3612.  MD5Prev: Cardinal;
  3613. begin
  3614.  
  3615.  if ( Cardinal(Index) >= COUNT_RESOURCE ) then
  3616.   Exit;
  3617.  
  3618.  ScriptList := Info^.Scripts[ Index ];
  3619.  
  3620.  if ( ScriptList = nil ) then
  3621.   Exit;
  3622.  
  3623.  MD5Prev := Info^.LastMD5;
  3624.  
  3625.  Count := ScriptList.ScriptCount - 1;
  3626.  
  3627.  for i := 0 to Count do
  3628.   begin
  3629.  
  3630.    Script := @(ScriptList.Scripts[ i ]);
  3631.  
  3632.    if ( Script^.sm_data = SM_PREV ) then
  3633.     begin
  3634.  
  3635.         if ( MD5 = MD5Prev ) then
  3636.          begin
  3637.           TryScript( Info , MD5 , ScriptList^.Exec , Script );
  3638.           continue;
  3639.          end;
  3640.  
  3641.     end;
  3642.  
  3643.    if ( Script^.sm_data = SM_CONST ) then
  3644.     begin
  3645.  
  3646.         if ( MD5 = Script^.md_data ) then
  3647.          begin
  3648.           TryScript( Info , MD5 , ScriptList^.Exec , Script );
  3649.           continue;
  3650.          end;
  3651.  
  3652.     end;
  3653.  
  3654.    if ( Script^.sm_data = SM_ALL ) then
  3655.     begin
  3656.  
  3657.         TryScript( Info , MD5 , ScriptList^.Exec , Script );
  3658.         continue;
  3659.  
  3660.     end;
  3661.  
  3662.   end;
  3663.  
  3664. end;
  3665.  
  3666. function MSG_ReadBits_Gate( n: Cardinal ): Cardinal;
  3667. asm
  3668.  push EAX
  3669.  db$E8 db$22 db$22 db$22 db$22
  3670.  add ESP , 4
  3671. end;
  3672. function MSG_ReadBitsProcess( n: Cardinal ): Cardinal;
  3673. var
  3674.  Info: info_s;
  3675.  Index: Cardinal;
  3676. begin
  3677.  
  3678.  Result := MSG_ReadBits_Gate( n );
  3679.  
  3680.  Info := Pointer( $11111111 );
  3681.  
  3682.  if ( Info^.FristIndex = $FFFFFFFF ) then
  3683.   Exit;
  3684.  
  3685.  if ( n = $0C ) then
  3686.   begin
  3687.    Info^.LastIndex := Result;
  3688.    Exit;
  3689.   end;
  3690.  
  3691.  if ( n <> $20 ) then
  3692.   begin
  3693.    PCardinal($21212121)^ := 0;
  3694.    Exit;
  3695.   end;
  3696.  
  3697.  
  3698.  
  3699.  Index := Info^.LastIndex;
  3700.  
  3701.  if ( Index = Info^.FristIndex ) then
  3702.   begin
  3703.    Info^.LastMD5 := Result;
  3704.    Result := 0;
  3705.    Exit;
  3706.   end;
  3707.  
  3708.  if ( Index = Info^.EndIndex ) then
  3709.   begin
  3710.    PCardinal($21212121)^ := 0;
  3711.    Result := 0;
  3712.    Exit;
  3713.   end;
  3714.  
  3715.  if ( ( Index < Info^.FristIndex ) or ( Index > Info^.EndIndex ) ) then
  3716.   begin
  3717.    Exit;
  3718.   end;
  3719.  
  3720.  PlayerProcess( Info , Index , Result );
  3721.  
  3722.  Info^.LastMD5 := Result;
  3723.  
  3724.  Result := 0;
  3725.  
  3726. end;
  3727.  
  3728. procedure SV_ParseConsistencyResponse();
  3729. asm
  3730.  mov [ $21212121 ] , 1
  3731.  db$E9 db$23 db$23 db$23 db$23
  3732. end;
  3733. function MSG_ReadBits( n: Cardinal ): Cardinal;
  3734. asm
  3735.  test[ $21212121 ] , 0
  3736.  je @__MSG_ReadBitsProcess
  3737.  db$E9 db$22 db$22 db$22 db$22
  3738.  
  3739.  @__MSG_ReadBitsProcess:
  3740.  mov EAX , [ESP + 4]
  3741.  call MSG_ReadBitsProcess
  3742. end;
  3743.  
  3744. //  Replace:
  3745. //    $11111111 - to Info Structure
  3746. //    $21212121 - to To PDWord
  3747. //    $22222222 - to Relative EntryPoint MSG_ReadBits_Gate
  3748. //    $23232323 - to Relative EntryPoint SV_ParseConsistencyResponse_Gate
  3749. //    $24242424 - to Relative EntryPoint MSG_EndBitReading_Gate
  3750.  
  3751.  
  3752.  
  3753. {****************************************************************************************************************}
  3754. {****************************************************************************************************************}
  3755. {****************************************************************************************************************}
  3756. {****************************************************************************************************************}
  3757. {****************************************************************************************************************}
  3758. function __CopyEnd: Cardinal;
  3759. asm
  3760.  db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF
  3761.  db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF db $FF
  3762. end;
  3763.  
  3764.  
  3765.  
  3766.  
  3767.  
  3768.  
  3769.  
  3770. type empty_t = procedure;
  3771. procedure ShowCode( Memo: TMemo; FunctBegin , FunctEnd: Pointer;
  3772.   EntryPoint1:Pointer=nil;EntryPoint2:Pointer=nil;EntryPoint3:Pointer=nil;
  3773.   NeedFunct11:empty_t=nil;NeedFunct21:empty_t=nil;NeedFunct31:empty_t=nil;
  3774.   NeedFunct12:empty_t=nil;NeedFunct22:empty_t=nil;NeedFunct32:empty_t=nil;
  3775.   NeedFunct13:empty_t=nil;NeedFunct23:empty_t=nil;NeedFunct33:empty_t=nil;
  3776.   NeedFunct14:empty_t=nil;NeedFunct24:empty_t=nil;NeedFunct34:empty_t=nil;
  3777.   NeedFunct15:empty_t=nil;NeedFunct25:empty_t=nil;NeedFunct35:empty_t=nil;
  3778.   NeedFunct16:empty_t=nil;NeedFunct26:empty_t=nil;NeedFunct36:empty_t=nil;
  3779.   NeedFunct17:empty_t=nil;NeedFunct27:empty_t=nil;NeedFunct37:empty_t=nil;
  3780.   NeedFunct18:empty_t=nil;NeedFunct28:empty_t=nil;NeedFunct38:empty_t=nil;
  3781.   NeedFunct19:empty_t=nil;NeedFunct29:empty_t=nil;NeedFunct39:empty_t=nil );
  3782. var
  3783.   f: Cardinal;
  3784.   i, v, c: Cardinal;
  3785.   s: AnsiString;
  3786.   Temp: Cardinal;
  3787.   m, cc: Cardinal;
  3788. begin
  3789.  
  3790.  s := '';
  3791.  
  3792.  m := Cardinal(FunctBegin);
  3793.  i := m;
  3794.  
  3795.  cc := 0;
  3796.  while( i <= (Cardinal(FunctEnd)+4) ) do
  3797.   begin
  3798.    c := PCardinal(i)^;
  3799.  
  3800.    v := i - m;
  3801.  
  3802.    c := v XOR ( c XOR ( ( v shl 3 ) + 78963 ) - 13523 );
  3803.  
  3804.    s := s + '0x'+IntToHex( c , 8 ) + ',';
  3805.  
  3806.    Inc(cc);
  3807.    if ( cc = 16 ) then
  3808.     begin
  3809.      cc := 0;
  3810.      Memo.lines.add( s );
  3811.      s := '';
  3812.     end;
  3813.  
  3814.  
  3815.    Inc( i , 4 );
  3816.  
  3817.   end;
  3818.  
  3819.  Memo.lines.add( s );
  3820.  
  3821.  Memo.lines.add( '' );
  3822.  
  3823.  if ( EntryPoint1 <> nil ) then
  3824.   Memo.lines.add( 'EntryPoint1 offset: 0x' + IntToHex( Cardinal(EntryPoint1) - m , 8 ) );
  3825.  
  3826.  if ( EntryPoint2 <> nil ) then
  3827.   Memo.lines.add( 'EntryPoint2 offset: 0x' + IntToHex( Cardinal(EntryPoint2) - m , 8 ) );
  3828.  
  3829.  if ( EntryPoint3 <> nil ) then
  3830.   Memo.lines.add( 'EntryPoint3 offset: 0x' + IntToHex( Cardinal(EntryPoint3) - m , 8 ) );
  3831.  
  3832. end;
  3833.  
  3834.  
  3835.  
  3836.  
  3837.  
  3838.  
  3839. procedure TForm1.Button1Click(Sender: TObject);
  3840. begin
  3841.  
  3842.  ShowCode( Memo1 , @__CopyBegin , @__CopyEnd , @SV_SendResources , @SV_ParseConsistencyResponse , @MSG_ReadBits );
  3843.  
  3844. end;
  3845.  
  3846. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement