ISecurityGuardOpenLiteVMService.h 5.2 KB

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