Advertisement
MudockYatho

Call Encryption

Jan 23rd, 2017
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #define LUAVM_DAX_ME 0x1C6B438
  2. #define LUAVM_DAX_AO 0x1A7D575
  3. #define LUAVM_DAX_MO 0x1451AFB
  4.  
  5. static uint32_t rbxDaxEncodeOp(uint32_t x, uint32_t mulEven, uint32_t addEven, uint32_t mulOdd, uint32_t addOdd)
  6. {
  7.    uint32_t result      = 0;
  8.    uint32_t mask        = 1;
  9.    for (size_t i = 0; i < 8*sizeof(uint32_t); ++i)
  10.    {
  11.        uint32_t bitDesired = mask & x;
  12.        uint32_t bitOdd     = mask & (result*mulOdd + addOdd);
  13.        uint32_t bitEven    = mask & (result*mulEven + addEven);
  14.        if ((bitEven ^ bitOdd) != bitDesired)
  15.        {
  16.            result |= mask;
  17.        }
  18.        mask <<= 1;
  19.    }
  20.    return result;
  21. }
  22.  
  23. unsigned int DaxTranslateCode(unsigned int i, int pc, unsigned int key){
  24.    Instruction enc = i;
  25.    BYTE op = GET_OPCODE(i);
  26.    switch(op){
  27.       case OP_CALL:
  28.       case OP_TAILCALL:
  29.       case OP_RETURN:
  30.       case OP_CLOSURE:
  31.          enc = rbxDaxEncodeOp(i, LUAVM_DAX_ME, pc, LUAVM_DAX_MO, LUAVM_DAX_AO);
  32.          SET_OPCODE(enc, GET_OPCODE(i));
  33.          break;
  34.       case OP_MOVE:
  35.          SETARG_C(enc, (PC | 1));
  36.       default:
  37.          break;
  38.    }
  39.    return LUAVM_ENCODEINSN(enc, key);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement