Scygnus

RPGMaker VX/Ace CE hack

Mar 3rd, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. alloc(TypeName,256)
  2. alloc(ByteSize,4)
  3. alloc(PreferedAlignment, 4)
  4. alloc(ConvertRoutine,1024)
  5. alloc(ConvertBackRoutine,1024)
  6.  
  7. TypeName:
  8. db 'RPG VX type',0
  9.  
  10. ByteSize:
  11. dd 4
  12.  
  13. PreferedAlignment:
  14. dd 1
  15.  
  16.  
  17. //The convert routine should hold a routine that converts the data to an nteger (in eax)
  18. //function declared as: stdcall int ConvertRoutine(unsigned char *input);
  19.  
  20. //Note: Keep in mind that this routine can be called by multiple threads at the same time.
  21.  
  22. ConvertRoutine:
  23. [32-bit]
  24. push ebp
  25. mov ebp,esp
  26. push ecx
  27. mov ecx,[ebp+8]
  28. [/32-bit]
  29.  
  30. //at this point ecx contains the address where the bytes are stored
  31.  
  32. //put the bytes into the eax register
  33. mov eax,[ecx] //second fun fact, addressing with 32-bit registers doesn't work in 64-bit, it becomes a 64-bit automatically (most of the time)
  34. shr eax,1 //shift right by 1 bit (divide by 2)
  35.  
  36. //and now exit the routine
  37. [64-bit]
  38. ret
  39. [/64-bit]
  40. [32-bit]
  41. pop ecx
  42. pop ebp
  43. ret 4
  44. [/32-bit]
  45.  
  46. //The convert back routine should hold a routine that converts the given integer back to a row of bytes (e.g when the user wats to write a new value)
  47. //function declared as: stdcall void ConvertBackRoutine(int i, unsigned char *output);
  48. ConvertBackRoutine:
  49. [32-bit]
  50. push ebp
  51. mov ebp,esp
  52. push edx //save the registers
  53. push ecx
  54. mov edx,[ebp+0c]
  55. mov ecx,[ebp+08]
  56. [/32-bit]
  57.  
  58. //at this point edx contains the address to write the value to
  59. //and ecx contains the value
  60.  
  61. push eax
  62. push edx
  63.  
  64.  
  65. mov edx,[edx] //edx now contains the original value
  66. and edx,1 //only save the first bit
  67.  
  68. mov eax,ecx //eax gets the user input value
  69. shl eax,1 //shift left by 1 bit (multiply by 2)
  70. or eax,edx //add the bits of the original value
  71.  
  72. pop edx
  73. mov [edx],eax //write the new value into the old value
  74. pop eax
  75.  
  76. [64-bit]
  77. //everything is back to what it was, so exit
  78. ret
  79. [/64-bit]
  80.  
  81. [32-bit]
  82. //cleanup first
  83. pop ecx
  84. pop edx
  85. pop ebp
  86. ret 8
  87. [/32-bit]
Add Comment
Please, Sign In to add comment