SHARE
TWEET

memory_fs.pwn

BigETI Jul 11th, 2013 535 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #include <memory> // http://pastebin.com/4A8qLB5Z
  3.  
  4. MEM::struct TEST_STRUCT
  5. {
  6.         TEST_1,
  7.         TEST_2,
  8.         TEST_3,
  9.         TEST_4
  10. }
  11.  
  12. public OnFilterScriptInit()
  13. {
  14.         print("\n==========================================");
  15.         print("= Memory access plugin test filterscript =");
  16.         print("=                         Made by BigETI =");
  17.         print("= Loaded!                                =");
  18.         print("==========================================\n");
  19.        
  20.         // Get AMX pointer
  21.         printf("AMX pointer: 0x%x", _:MEM::amx_ptr());
  22.        
  23.         // Allocate memory
  24.         new Pointer:foo = MEM_malloc(TEST_STRUCT);
  25.  
  26.         //If failed
  27.         if(_:foo == NULL)
  28.         {
  29.                 print("Failed to allocate memory for \"foo\" pointer.");
  30.                 return 1;
  31.         }
  32.        
  33.         // Print the pointer of the allocated memory
  34.         printf("Allocated memory is located at 0x%x", _:foo);
  35.  
  36.         // Set values using pointers as destination
  37.         MEM::set_val(foo, TEST_1, 10);
  38.         MEM::set_val(foo, TEST_2, 9);
  39.         MEM::set_val(foo, TEST_3, 8);
  40.         MEM::set_val(foo, TEST_4, 7);
  41.  
  42.         // Print the values by getting values from pointers
  43.         printf("MEM_EX::get_val(foo->TEST_1) = %d | MEM_EX::get_val(foo->TEST_2) = %d | MEM_EX::get_val(foo->TEST_3) = %d | MEM_EX::get_val(foo->TEST_4) = %d", MEM_EX::get_val(foo->TEST_1), MEM_EX::get_val(foo->TEST_2), MEM_EX::get_val(foo->TEST_3), MEM_EX::get_val(foo->TEST_4));
  44.        
  45.         // Print the memory results
  46.         MEM_EX::foreach(TEST_STRUCT, foo_i)
  47.         {
  48.             printf("MEM_EX::foreach test: ( address = 0x%x | value = %d )", _:MEM_EX::get_ptr(foo->foo_i), MEM_EX::get_val(foo->foo_i));
  49.         }
  50.        
  51.         // Sort the memory
  52.         MEM::sort(foo, _, TEST_STRUCT);
  53.        
  54.         // Print the memory results
  55.         MEM_EX::foreach(TEST_STRUCT, foo_i)
  56.         {
  57.             printf("MEM_EX::foreach test: ( address = 0x%x | value = %d )", _:MEM_EX::get_ptr(foo->foo_i), MEM_EX::get_val(foo->foo_i));
  58.         }
  59.        
  60.         //Sort the memory by reversed order
  61.         MEM::sort(foo, _, TEST_STRUCT, MEM_ENUM::sort_reverse);
  62.        
  63.         // Print the memory results
  64.         MEM_EX::foreach(TEST_STRUCT, foo_it)
  65.         {
  66.             printf("MEM_EX::foreach test: ( address = 0x%x | value = %d )", _:MEM_EX::get_ptr(foo->foo_it), MEM_EX::get_val(foo->foo_it));
  67.         }
  68.        
  69.         // Mix the memory
  70.         MEM::mix(foo, _, TEST_STRUCT);
  71.  
  72.         // Print the memory results
  73.         MEM_EX::foreach(TEST_STRUCT, foo_it)
  74.         {
  75.             printf("MEM_EX::foreach test: ( address = 0x%x | value = %d )", _:MEM_EX::get_ptr(foo->foo_it), MEM_EX::get_val(foo->foo_it));
  76.         }
  77.  
  78.         // Free memory (IMPORTANT!)
  79.         MEM::free(foo);
  80.        
  81.         // Get variable address and value by address
  82.         new test_var = 1337;
  83.         printf("\"test_var\" address: 0x%x | \"test_var\" value by address: %d", _:MEM::get_addr(test_var), MEM::get_val(MEM::get_addr(test_var)));
  84.         return 1;
  85. }
  86.  
  87. public OnFilterScriptExit()
  88. {
  89.         print("\n==========================================");
  90.         print("= Memory access plugin test filterscript =");
  91.         print("=                         Made by BigETI =");
  92.         print("= Unloaded!                              =");
  93.         print("==========================================\n");
  94.         return 1;
  95. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top