developer
2023-05-20 e12c7b4c22df631ebdcd16b2f98fbef8f738f92f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//
//  ISecurityGuardOpenLiteVMService.h
//  SecurityGuardMain
//
//  Created by lifengzhong on 15/12/17.
//  Copyright © 2015年 Li Fengzhong. All rights reserved.
//
 
#ifndef ISecurityGuardOpenLiteVMService_h
#define ISecurityGuardOpenLiteVMService_h
 
#if TARGET_OS_WATCH
#import <SecurityGuardSDKWatch/Open/IOpenSecurityGuardPlugin.h>
#else
#import <SecurityGuardSDK/Open/IOpenSecurityGuardPlugin.h>
#endif
 
@class LiteVMInstance;
 
 
 
/**
 LVM参数封装类,目前支持 char、unsigned char、int、unsigned int、long、
 unsigned long、long long、unsigned long long、NSString、NSData类型的入参
 */
@interface LiteVMParameterWrapper : NSObject
 
+ (LiteVMParameterWrapper*) createCharParameter: (char) value;
+ (LiteVMParameterWrapper*) createUnsignedCharParameter: (unsigned char) value;
 
+ (LiteVMParameterWrapper*) createIntParameter: (int) value;
+ (LiteVMParameterWrapper*) createUnsignedIntParameter: (unsigned int) value;
 
+ (LiteVMParameterWrapper*) createLongParameter: (long) value;
+ (LiteVMParameterWrapper*) createUnsignedLongParameter: (unsigned long) value;
 
+ (LiteVMParameterWrapper*) createLongLongParameter: (long long) value;
+ (LiteVMParameterWrapper*) createUnsignedLongLongParameter: (unsigned long long) value;
 
+ (LiteVMParameterWrapper*) createStringParameter: (NSString*) value;
+ (LiteVMParameterWrapper*) createDataParameter: (NSData*) value;
 
@end
 
 
 
/**
 LVM接口封装类
 */
@protocol ISecurityGuardOpenLiteVMService <NSObject, IOpenSecurityGuardPluginInterface>
 
 
/**
 创建LVM实例
 
 @param authCode 保镖为业务方分配的标识id,与bianry一一对应
 @param bizId 为binary code分配的name (一个binary中可以有多个binarycode,通过biz id来索引)
 @param binary 存储待执行的bianry code的二进制
 @param symbolArray binary code依赖符号的数组,可为空
 @param error 错误
 @return 根据bizId和binaryCode生成的vm实例
 */
- (LiteVMInstance*) createLiteVMInstanceWithAuthCode: (NSString*) authCode
                                               bizId: (NSString*) bizId
                                              binary: (NSData*) binary
                                      requiredSymbol: (NSArray*) symbolArray
                                               error: (NSError**) error;
 
 
/**
 让LVM实例重新加载binary code
 
 @param instance LVM实例
 @param binaryCode 需要重新加载的binary code
 @param error 错误
 */
- (void) reloadLiteVMInstance: (LiteVMInstance*) instance
                       binary: (NSData*) binaryCode
                        error: (NSError**) error;
 
 
/**
 销毁LVM实例
 
 @param instance LVM实例
 @param error 错误
 */
- (void) destroyLiteVMInstance: (LiteVMInstance*) instance
                         error: (NSError**) error;
 
 
 
/**
 调用无返回值的LVM函数
 
 @param instance LVM实例
 @param index 要调用的函数在binary code中的index (一个binary code中可以有多个函数,以0为开始的下标来标识)
 @param param 参数数组
 @param error 错误
 */
- (void) callLiteVMVoidMethod: (LiteVMInstance*) instance
                 funtionIndex: (int) index
                   paramArray: (NSArray<LiteVMParameterWrapper*>*) param
                        error: (NSError**) error;
 
 
/**
 调用返回值为long(整型)的LVM函数
 
 @param instance LVM实例
 @param index 要调用的函数在binary code中的index (一个binary code中可以有多个函数,以0为开始的下标来标识)
 @param param 参数数组
 @param error 错误
 @return long型结果
 */
- (long) callLiteVMLongMethod: (LiteVMInstance*) instance
                 funtionIndex: (int) index
                   paramArray: (NSArray<LiteVMParameterWrapper*>*) param
                        error: (NSError**) error;
/**
 调用返回值为NSString类型的LVM函数
 
 @param instance LVM实例
 @param index 要调用的函数在binary code中的index (一个binary code中可以有多个函数,以0为开始的下标来标识)
 @param param 参数数组
 @param error 错误
 @return NSString返回值
 */
- (NSString*) callLiteVMStringMethod: (LiteVMInstance*) instance
                        funtionIndex: (int) index
                          paramArray: (NSArray<LiteVMParameterWrapper*>*) param
                               error: (NSError**) error;
 
/**
 调用返回值为NSData类型的LVM函数
 
 @param instance LVM实例
 @param index 要调用的函数在binary code中的index (一个binary code中可以有多个函数,以0为开始的下标来标识)
 @param param 参数数组
 @param error 错误
 @return NSData返回值
 */
- (NSData*) callLiteVMByteMethod: (LiteVMInstance*) instance
                    funtionIndex: (int) index
                      paramArray: (NSArray<LiteVMParameterWrapper*>*) param
                           error: (NSError**) error;
 
@end
 
#endif /* ISecurityGuardOpenLiteVMService_h */