The only way would be to implement it as a C function to call with calldll or with Encryption calldll.
The only doubt I have is about mRandom which is not clear if it's a 64bit or not, indeed I guess the script will not work correctly:
Code:
set MEMORY_FILE10 string "
long long mRandom = 0;
int Math_min(int a, int b) {
if(a < b) return a;
return b;
}
int Math_max(int a, int b) {
if(a > b) return a;
return b;
}
int getNextRandom() {
mRandom ^= mRandom << (long long)21;
mRandom ^= (unsigned long long)mRandom >> (unsigned long long)35;
mRandom ^= mRandom << (long long)4;
if (mRandom < 0)
mRandom &= 2147483647;
return mRandom / 2147483647;
}
void decryptPackage(unsigned char *view, int view_byteLength) {
//int view = new DataView(bytes);
int i;
mRandom = 56895 & 25147 >> 1;
for (i = Math_min(view_byteLength, 65536) - 1; i >= 0; i -= 2)
view[i] -= (getNextRandom() * 255);
for (i = view_byteLength - 1; i >= 0; i -= (getNextRandom() * 255))
view[i] -= (getNextRandom() * 255);
for (i = view_byteLength - 1; i >= Math_max(view_byteLength, 65536) - 65536; i -= 2)
view[i] -= (getNextRandom() * 255);
mRandom = 0;
}
"
get SIZE asize
log MEMORY_FILE 0 SIZE
calldll MEMORY_FILE10 decryptPackage tcc RET MEMORY_FILE SIZE
log "dump.dat" 0 SIZE MEMORY_FILE