Exemple #1
0
    public static AntiDecryptResult TssSdkDecrypt(byte[] src, uint src_len, ref byte[] tar, ref uint tar_len)
    {
        AntiDecryptResult result  = AntiDecryptResult.ANTI_DECRYPT_FAIL;
        GCHandle          handle  = GCHandle.Alloc(src, GCHandleType.Pinned);
        GCHandle          handle2 = GCHandle.Alloc(tar, GCHandleType.Pinned);

        if (handle.IsAllocated && handle2.IsAllocated)
        {
            DecryptPkgInfo info = new DecryptPkgInfo {
                encrypt_data_    = handle.AddrOfPinnedObject(),
                encrypt_data_len = src_len,
                game_pkg_        = handle2.AddrOfPinnedObject(),
                game_pkg_len_    = tar_len
            };
            result  = tss_sdk_decryptpacket(info);
            tar_len = info.game_pkg_len_;
        }
        if (handle.IsAllocated)
        {
            handle.Free();
        }
        if (handle2.IsAllocated)
        {
            handle2.Free();
        }
        return(result);
    }
    public static AntiDecryptResult TssSdkDecrypt(/*[in]*/ byte[] src, /*[in]*/ uint src_len,
                                                  /*[out]*/ ref byte[] tar, /*[out]*/ ref uint tar_len)
    {
        AntiDecryptResult ret        = AntiDecryptResult.ANTI_DECRYPT_FAIL;
        GCHandle          src_handle = GCHandle.Alloc(src, GCHandleType.Pinned);
        GCHandle          tar_handle = GCHandle.Alloc(tar, GCHandleType.Pinned);

        if (src_handle.IsAllocated && tar_handle.IsAllocated)
        {
            DecryptPkgInfo info = new DecryptPkgInfo();
            info.encrypt_data_    = src_handle.AddrOfPinnedObject();
            info.encrypt_data_len = src_len;
            info.game_pkg_        = tar_handle.AddrOfPinnedObject();
            info.game_pkg_len_    = tar_len;
            ret     = tss_sdk_decryptpacket(info);
            tar_len = info.game_pkg_len_;
        }
        if (src_handle.IsAllocated)
        {
            src_handle.Free();
        }
        if (tar_handle.IsAllocated)
        {
            tar_handle.Free();
        }
        return(ret);
    }