Advertisement
fastman92

asm_handling.txt

Mar 23rd, 2012
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 8.12 KB | None | 0 0
  1. :asm_PutOnAddressRelativeAddressToAddress
  2. {
  3.  Description:
  4.     Writes at the specified address a relative adress to second adress.
  5.  Type: SET
  6.  
  7.  Parameters:
  8.    Passed:
  9.      0@ - source adress
  10.      1@ - size of written adress (1, 2, 4)
  11.      2@ - source virtual protect
  12.      3@ - destination adress
  13.      
  14.  
  15.  Example:
  16.   0AB1: call_scm_func @asm_PutOnAddressRelativeAddressToAddress 4 source_adress 2@ source_size 4 source_virtual_protect true destination 0x004912DC    
  17. }
  18. 0062: 3@ -= 0@  // (int)
  19. 0062: 3@ -= 1@  // (int)
  20. 0A8C: write_memory 0@ size 1@ value 3@ virtual_protect 2@
  21. 0AB2: ret 0
  22.  
  23. :asm_PutOnAddressRelativeAddressToLabel
  24. {
  25.  Description:
  26.     Writes at the specified adress a relative adress to second adress.
  27.  Type: SET
  28.  
  29.  Parameters:
  30.    Passed:
  31.      0@ - adress of script content (current_thread_pointer + 0x10)
  32.      1@ - source adress
  33.      2@ - size of written adress (1, 2, 4)
  34.      3@ - source virtual protect
  35.      4@ - destination label
  36.      
  37.  
  38.  Example:
  39.   0AB1: call_scm_func @asm_PutOnAddressRelativeAddressToLabel 5 script_content 1@ source_adress 2@ source_size 4 source_virtual_protect true destination @label    
  40. }
  41. 0062: 0@ -= 4@  // (int)    // destination: label adress
  42. 0062: 0@ -= 1@  // (int)
  43.  
  44. 0062: 0@ -= 2@  // (int)
  45.                                    
  46. 0A8C: write_memory 1@ size 2@ value 0@ virtual_protect 3@
  47. 0AB2: ret 0
  48.  
  49. :asm_PutOnLabelRelativeAddressToAddress
  50. {
  51.  Description:
  52.     Writes at the specified label a relative adress to second adress.
  53.  Type: SET
  54.  
  55.  Parameters:
  56.    Passed:
  57.      0@ - adress of script content (current_thread_pointer + 0x10)  
  58.      1@ - source label
  59.      2@ - size of written adress (1, 2, 4)
  60.      3@ - destination adress    
  61.  
  62.  Example:
  63.   0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content 0@ source_label @function_adress source_size 4 destination 0x004912DC    
  64. }
  65. 0062: 0@ -= 1@  // (int)
  66. 0062: 3@ -= 0@  // (int)
  67. 0062: 3@ -= 2@  // (int)
  68. 0A8C: write_memory 0@ size 2@ value 3@ virtual_protect false
  69. 0AB2: ret 0
  70.  
  71. :asm_PutOnLabelRelativeAddressToLabel
  72. {
  73.  Description:
  74.     Writes at the specified label a relative adress to second label.
  75.  Type: SET
  76.  
  77.  Parameters:
  78.    Passed:
  79.      0@ - adress of script content (current_thread_pointer + 0x10)  
  80.      1@ - source label
  81.      2@ - size of written adress (1, 2, 4)
  82.      3@ - destination label    
  83.  
  84.  Example:
  85.   0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToLabel 4 script_content 0@ source_label @function_source source_size 4 destination @function_destination    
  86. }
  87. 0062: 0@ -= 1@  // (int)    // source adress
  88. 0062: 1@ -= 3@  // (int)    // difference
  89. 0062: 1@ -= 2@  // (int)    // -= size
  90.  
  91. 0A8C: write_memory 0@ size 2@ value 1@ virtual_protect false
  92. 0AB2: ret 0
  93.  
  94. :asm_PutOnAddressAbsoluteAddressToAddress
  95. :asm_PutOnAddressAnyValue
  96. {
  97.  Description:
  98.     Writes at the specified adress any adress/value
  99.  Type: SET
  100.  
  101.  Parameters:
  102.    Passed:
  103.      0@ - source adress
  104.      1@ - size of written adress (1, 2, 4)
  105.      2@ - source virtual protect
  106.      3@ - destination adress
  107.      
  108.  
  109.  Example:
  110.   0AB1: call_scm_func @asm_PutOnAddressAbsoluteAddressToAddress 4 source_adress 2@ source_size 4 source_virtual_protect true destination 0x004912DC    
  111. }
  112. 0A8C: write_memory 0@ size 1@ value 3@ virtual_protect 2@
  113. 0AB2: ret 0
  114.  
  115. :asm_PutOnAddressAbsoluteAddressToLabel
  116. {
  117.  Description:
  118.     Writes at the specified adress an absolute adress to label.
  119.  Type: SET
  120.  
  121.  Parameters:
  122.    Passed:
  123.      0@ - adress of script content (current_thread_pointer + 0x10)  
  124.      1@ - source adress
  125.      2@ - source virtual protect
  126.      3@ - destination label    
  127.  
  128.  Example:
  129.   0AB1: call_scm_func @asm_PutOnAddressAbsoluteAddressToLabel 4 script_content 0@ source_adress 0x466D44 source_virtual_protect true destination @function_destination    
  130. }
  131. 0062: 0@ -= 3@  // (int)    // destination adress
  132. 0A8C: write_memory 1@ size 4 value 0@ virtual_protect 2@
  133. 0AB2: ret 0
  134.  
  135. :asm_PutOnLabelAbsoluteAddressToLabel
  136. {
  137.  Description:
  138.     Writes at the specified label an absolute adress to label.
  139.  Type: SET
  140.  
  141.  Parameters:
  142.    Passed:
  143.      0@ - adress of script content (current_thread_pointer + 0x10)  
  144.      1@ - source label
  145.      2@ - destination label    
  146.  
  147.  Example:
  148.   0AB1: call_scm_func @asm_PutOnLabelAbsoluteAddressToLabel 3 script_content 0@ source_label @function_source destination @function_destination    
  149. }
  150. 0A8F: 2@ = 0@ - 2@ // int   // destination adress
  151. 0062: 0@ -= 1@  // (int)    // source adress
  152. 0A8C: write_memory 0@ size 4 value 2@ virtual_protect false
  153. 0AB2: ret 0
  154.  
  155. :asm_PutOnLabelAbsoluteAddressToAddress
  156. :asm_PutOnLabelAnyValue
  157. {
  158.  Description:
  159.     Writes at the specified label an absolute adress to second adress.
  160.  Type: SET
  161.  
  162.  Parameters:
  163.    Passed:
  164.      0@ - adress of script content (current_thread_pointer + 0x10)  
  165.      1@ - source label
  166.      2@ - size of written adress (1, 2, 4)
  167.      3@ - destination adress    
  168.  
  169.  Example:
  170.   0AB1: call_scm_func @asm_PutOnLabelAbsoluteAddressToAddress 4 script_content 0@ source_label @function_source source_size 4 destination 0x400000    
  171. }
  172. 0062: 0@ -= 1@  // (int)    // source adress
  173. 0A8C: write_memory 0@ size 2@ value 3@ virtual_protect false
  174. 0AB2: ret 0
  175.  
  176. :asm_GetStructOffsetLabeltoLabel
  177. {
  178.  Description:
  179.     Calculates offset between first and second lable
  180.  Type: SET
  181.  
  182.  Parameters:
  183.    Passed:
  184.      0@ - first label
  185.      1@ - second label
  186.  
  187.  Example:
  188.   0AB1: call_scm_func @asm_GetStructOffsetLabeltoLabel 2 base_label @vehicles second_label @vehicles_properties store_offset 5@
  189. }
  190. 0062: 0@ -= 1@  // (int)  
  191. 0AB2: ret 1 0@
  192.  
  193. :asm_PutOnAddressJmpFarToLabel
  194. {
  195.  Description:
  196.     Writes at the specified label ASM jmp far with relative address to label (0xE9 + relative address)
  197.  Type: SET
  198.  
  199.  Parameters:
  200.    Passed:
  201.      0@ - adress of script content (current_thread_pointer + 0x10)  
  202.      1@ - source address
  203.      2@ - source virtual protect
  204.      3@ - destination label    
  205.  
  206.  Example:
  207.   0AB1: call_scm_func @asm_PutOnAddressJmpFarToLabel 4 script_content 0@ source_address 2@ source_virtual_protect true destination @function_destination    
  208. }
  209. 0062: 0@ -= 3@  // (int)    // destination adress
  210. 0A8C: write_memory 1@ size 1 value 0xE9 virtual_protect 2@
  211. 1@ += 1
  212. 0062: 0@ -= 1@  // (int)    // difference
  213. 0@ -= 4
  214. 0A8C: write_memory 1@ size 4 value 0@ virtual_protect 2@
  215. 0AB2: ret 0
  216.  
  217. :asm_WriteMemoryValueOnAddressesPlacedOnLabel
  218. {
  219.  Description:
  220.     Writes value of 1, 2 or 4 bytes to memory addresses being put on label until 0 as DWORD terminates list of addresses.
  221.  Type: SET
  222.  
  223.  Parameters:
  224.    Passed:
  225.      0@ - adress of script content (current_thread_pointer + 0x10)  
  226.      1@ - label with 4-byte absolute addresses
  227.      2@ - virtual protect of addresses
  228.      3@ - size of written value (1, 2, 4)
  229.      4@ - value to be written  
  230.  
  231.  Example:
  232.   0AB1: call_scm_func @asm_WriteMemoryValueOnAddressesPlacedOnLabel 5 script_content 0@ label_with_addresses @addresses addresses_virtual_protect false size 4 value 666      
  233. }
  234. 0062: 0@ -= 1@  // (int)
  235.  
  236.     while true
  237.     0A8D: 5@ = read_memory 0@ size 4 virtual_protect false
  238.         if
  239.         5@ <> false
  240.         else_jump break
  241.  
  242.     0A8C: write_memory 5@ size 3@ value 4@ virtual_protect 2@
  243.        
  244.     0@ += 4    
  245.     end
  246.  
  247. 0AB2: ret 0
  248.  
  249. :asm_CopyMemoryFromStringVariableToLabel
  250. {
  251.  Description:
  252.     Copies memory from string variable to label.
  253.  Type: SET
  254.  
  255.  Parameters:
  256.    Passed:
  257.      0@ - CRunningScript* (current_thread_pointer)
  258.      1@ - destination label
  259.      2@+ - string variables terminated by NULL
  260.  
  261.  Example:
  262.   0AB1: call_scm_func @asm_CopyMemoryFromStringVariableToLabel 6 thread_pointer 0@ destination_label @text string 0@ 1@ 2@ 3@
  263. }
  264. 0A8E: 31@ = 0@ + 0x10 // int
  265. 0A8D: 31@ = read_memory 31@ size 4 virtual_protect false
  266. 0062: 31@ -= 1@  // (int)
  267.  
  268. 0@ += 68
  269.  
  270.     while true
  271.     0A8D: 1@ = read_memory 0@ size 1 virtual_protect false
  272.    
  273.         if
  274.         1@ <> false
  275.         else_jump break
  276.    
  277.     0A8C: write_memory 31@ size 1 value 1@ virtual_protect false
  278.     0@ += 1
  279.     31@ += 1
  280.     end
  281.  
  282. 0A8C: write_memory 31@ size 1 value 0x00 virtual_protect false
  283.  
  284. 0AB2: ret 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement