frida 16.7.14 → 16.7.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +1 -10
  2. package/build/BSDmakefile +6 -0
  3. package/build/Makefile +10 -0
  4. package/build/src/frida.d.ts +364 -0
  5. package/build/src/frida.js +962 -0
  6. package/build/src/frida_binding.d.ts +938 -0
  7. package/meson.build +34 -67
  8. package/package.json +30 -20
  9. package/scripts/fetch-abi-bits.py +15 -65
  10. package/scripts/install.js +5 -4
  11. package/src/addon.def +3 -0
  12. package/src/addon.symbols +2 -1
  13. package/src/addon.version +4 -0
  14. package/src/frida_bindgen/__init__.py +0 -0
  15. package/src/frida_bindgen/__main__.py +4 -0
  16. package/src/frida_bindgen/__pycache__/__init__.cpython-312.pyc +0 -0
  17. package/src/frida_bindgen/__pycache__/__main__.cpython-312.pyc +0 -0
  18. package/src/frida_bindgen/__pycache__/cli.cpython-312.pyc +0 -0
  19. package/src/frida_bindgen/__pycache__/codegen.cpython-312.pyc +0 -0
  20. package/src/frida_bindgen/__pycache__/customization.cpython-312.pyc +0 -0
  21. package/src/frida_bindgen/__pycache__/loader.cpython-312.pyc +0 -0
  22. package/src/frida_bindgen/__pycache__/model.cpython-312.pyc +0 -0
  23. package/src/frida_bindgen/assets/codegen_helpers.c +1970 -0
  24. package/src/frida_bindgen/assets/codegen_helpers.ts +100 -0
  25. package/src/frida_bindgen/assets/codegen_prototypes.h +78 -0
  26. package/src/frida_bindgen/assets/codegen_types.h +57 -0
  27. package/src/frida_bindgen/assets/customization_facade.exports +13 -0
  28. package/src/frida_bindgen/assets/customization_facade.ts +157 -0
  29. package/src/frida_bindgen/assets/customization_helpers.imports +2 -0
  30. package/src/frida_bindgen/assets/customization_helpers.ts +396 -0
  31. package/src/frida_bindgen/cli.py +96 -0
  32. package/src/frida_bindgen/codegen.py +2233 -0
  33. package/src/frida_bindgen/customization.py +924 -0
  34. package/src/frida_bindgen/loader.py +60 -0
  35. package/src/frida_bindgen/model.py +1357 -0
  36. package/src/meson.build +92 -27
  37. package/{lib/build.py → src/tsc.py} +12 -12
  38. package/src/win_delay_load_hook.c +56 -0
  39. package/subprojects/frida-core.wrap +1 -1
  40. package/test/data/index.ts +2 -2
  41. package/test/device.ts +1 -2
  42. package/test/device_manager.ts +1 -2
  43. package/test/labrat.ts +2 -2
  44. package/test/script.ts +12 -12
  45. package/test/session.ts +3 -3
  46. package/tsconfig.json +6 -11
  47. package/dist/application.d.ts +0 -81
  48. package/dist/application.js +0 -2
  49. package/dist/authentication.d.ts +0 -3
  50. package/dist/authentication.js +0 -2
  51. package/dist/bus.d.ts +0 -16
  52. package/dist/bus.js +0 -23
  53. package/dist/cancellable.d.ts +0 -15
  54. package/dist/cancellable.js +0 -41
  55. package/dist/child.d.ts +0 -16
  56. package/dist/child.js +0 -9
  57. package/dist/crash.d.ts +0 -10
  58. package/dist/crash.js +0 -2
  59. package/dist/device.d.ts +0 -156
  60. package/dist/device.js +0 -188
  61. package/dist/device_manager.d.ts +0 -25
  62. package/dist/device_manager.js +0 -42
  63. package/dist/endpoint_parameters.d.ts +0 -26
  64. package/dist/endpoint_parameters.js +0 -24
  65. package/dist/icon.d.ts +0 -14
  66. package/dist/icon.js +0 -2
  67. package/dist/index.d.ts +0 -161
  68. package/dist/index.js +0 -170
  69. package/dist/iostream.d.ts +0 -13
  70. package/dist/iostream.js +0 -73
  71. package/dist/native.d.ts +0 -1
  72. package/dist/native.js +0 -11
  73. package/dist/portal_membership.d.ts +0 -6
  74. package/dist/portal_membership.js +0 -12
  75. package/dist/portal_service.d.ts +0 -48
  76. package/dist/portal_service.js +0 -52
  77. package/dist/process.d.ts +0 -47
  78. package/dist/process.js +0 -2
  79. package/dist/relay.d.ts +0 -22
  80. package/dist/relay.js +0 -32
  81. package/dist/script.d.ts +0 -70
  82. package/dist/script.js +0 -266
  83. package/dist/service.d.ts +0 -16
  84. package/dist/service.js +0 -26
  85. package/dist/session.d.ts +0 -45
  86. package/dist/session.js +0 -73
  87. package/dist/signals.d.ts +0 -20
  88. package/dist/signals.js +0 -40
  89. package/dist/socket_address.d.ts +0 -25
  90. package/dist/socket_address.js +0 -2
  91. package/dist/spawn.d.ts +0 -4
  92. package/dist/spawn.js +0 -2
  93. package/dist/system_parameters.d.ts +0 -84
  94. package/dist/system_parameters.js +0 -2
  95. package/lib/application.ts +0 -98
  96. package/lib/authentication.ts +0 -3
  97. package/lib/bus.ts +0 -30
  98. package/lib/cancellable.ts +0 -48
  99. package/lib/child.ts +0 -15
  100. package/lib/crash.ts +0 -11
  101. package/lib/device.ts +0 -331
  102. package/lib/device_manager.ts +0 -69
  103. package/lib/endpoint_parameters.ts +0 -56
  104. package/lib/icon.ts +0 -15
  105. package/lib/index.ts +0 -316
  106. package/lib/iostream.ts +0 -78
  107. package/lib/meson.build +0 -53
  108. package/lib/native.ts +0 -9
  109. package/lib/portal_membership.ts +0 -10
  110. package/lib/portal_service.ts +0 -105
  111. package/lib/process.ts +0 -57
  112. package/lib/relay.ts +0 -44
  113. package/lib/script.ts +0 -361
  114. package/lib/service.ts +0 -34
  115. package/lib/session.ts +0 -113
  116. package/lib/signals.ts +0 -45
  117. package/lib/socket_address.ts +0 -35
  118. package/lib/spawn.ts +0 -4
  119. package/lib/system_parameters.ts +0 -103
  120. package/meson.options +0 -11
  121. package/src/addon.cc +0 -78
  122. package/src/application.cc +0 -148
  123. package/src/application.h +0 -31
  124. package/src/authentication.cc +0 -174
  125. package/src/authentication.h +0 -24
  126. package/src/bus.cc +0 -167
  127. package/src/bus.h +0 -33
  128. package/src/cancellable.cc +0 -117
  129. package/src/cancellable.h +0 -31
  130. package/src/child.cc +0 -150
  131. package/src/child.h +0 -32
  132. package/src/crash.cc +0 -122
  133. package/src/crash.h +0 -30
  134. package/src/device.cc +0 -1350
  135. package/src/device.h +0 -56
  136. package/src/device_manager.cc +0 -362
  137. package/src/device_manager.h +0 -35
  138. package/src/endpoint_parameters.cc +0 -171
  139. package/src/endpoint_parameters.h +0 -28
  140. package/src/glib_context.cc +0 -62
  141. package/src/glib_context.h +0 -29
  142. package/src/glib_object.cc +0 -25
  143. package/src/glib_object.h +0 -37
  144. package/src/iostream.cc +0 -243
  145. package/src/iostream.h +0 -30
  146. package/src/operation.h +0 -94
  147. package/src/portal_membership.cc +0 -100
  148. package/src/portal_membership.h +0 -26
  149. package/src/portal_service.cc +0 -401
  150. package/src/portal_service.h +0 -40
  151. package/src/process.cc +0 -135
  152. package/src/process.h +0 -30
  153. package/src/relay.cc +0 -139
  154. package/src/relay.h +0 -31
  155. package/src/runtime.cc +0 -568
  156. package/src/runtime.h +0 -69
  157. package/src/script.cc +0 -301
  158. package/src/script.h +0 -36
  159. package/src/service.cc +0 -224
  160. package/src/service.h +0 -36
  161. package/src/session.cc +0 -860
  162. package/src/session.h +0 -42
  163. package/src/signals.cc +0 -334
  164. package/src/signals.h +0 -47
  165. package/src/spawn.cc +0 -95
  166. package/src/spawn.h +0 -27
  167. package/src/usage_monitor.h +0 -117
  168. package/src/uv_context.cc +0 -118
  169. package/src/uv_context.h +0 -40
  170. package/src/win_delay_load_hook.cc +0 -63
  171. package/subprojects/nan.wrap +0 -9
  172. package/subprojects/packagefiles/nan.patch +0 -13
@@ -1,29 +0,0 @@
1
- #ifndef FRIDANODE_GLIB_CONTEXT_H
2
- #define FRIDANODE_GLIB_CONTEXT_H
3
-
4
- #include <frida-core.h>
5
-
6
- #include <functional>
7
-
8
- namespace frida {
9
-
10
- class GLibContext {
11
- public:
12
- GLibContext(GMainContext* main_context);
13
- ~GLibContext();
14
-
15
- void Schedule(std::function<void ()> f);
16
- void Perform(std::function<void ()> f);
17
-
18
- private:
19
- static gboolean InvokeCallback(gpointer data);
20
- static void DestroyCallback(gpointer data);
21
-
22
- GMainContext* main_context_;
23
- GMutex mutex_;
24
- GCond cond_;
25
- };
26
-
27
- }
28
-
29
- #endif
@@ -1,25 +0,0 @@
1
- #include "glib_object.h"
2
-
3
- using v8::External;
4
- using v8::FunctionTemplate;
5
- using v8::Local;
6
- using v8::String;
7
- using v8::Value;
8
-
9
- namespace frida {
10
-
11
- Local<FunctionTemplate> GLibObject::CreateTemplate(Local<String> name,
12
- Nan::FunctionCallback callback, Runtime* runtime) {
13
- Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(callback,
14
- Nan::New<External>(runtime));
15
- tpl->SetClassName(name);
16
- tpl->InstanceTemplate()->SetInternalFieldCount(1);
17
- return tpl;
18
- }
19
-
20
- Runtime* GLibObject::GetRuntimeFromConstructorArgs(
21
- const Nan::FunctionCallbackInfo<Value>& args) {
22
- return static_cast<Runtime*>(args.Data().As<External>()->Value ());
23
- }
24
-
25
- }
package/src/glib_object.h DELETED
@@ -1,37 +0,0 @@
1
- #ifndef FRIDANODE_GLIB_OBJECT_H
2
- #define FRIDANODE_GLIB_OBJECT_H
3
-
4
- #include "runtime.h"
5
-
6
- #include <glib.h>
7
- #include <nan.h>
8
- #include <node_object_wrap.h>
9
-
10
- namespace frida {
11
-
12
- class GLibObject : public node::ObjectWrap {
13
- protected:
14
- GLibObject(gpointer handle, Runtime* runtime)
15
- : handle_(handle),
16
- runtime_(runtime) {
17
- }
18
-
19
- static v8::Local<v8::FunctionTemplate> CreateTemplate(v8::Local<v8::String> name,
20
- Nan::FunctionCallback callback, Runtime* runtime);
21
- static Runtime* GetRuntimeFromConstructorArgs(
22
- const Nan::FunctionCallbackInfo<v8::Value>& info);
23
-
24
- public:
25
- template<typename T>
26
- T* GetHandle() const { return static_cast<T*>(handle_); }
27
-
28
- Runtime* GetRuntime() const { return runtime_; }
29
-
30
- protected:
31
- gpointer handle_;
32
- Runtime* runtime_;
33
- };
34
-
35
- }
36
-
37
- #endif
package/src/iostream.cc DELETED
@@ -1,243 +0,0 @@
1
- #include "iostream.h"
2
-
3
- #include "operation.h"
4
- #include "signals.h"
5
-
6
- #define IOSTREAM_DATA_CONSTRUCTOR "iostream:ctor"
7
-
8
- using v8::DEFAULT;
9
- using v8::External;
10
- using v8::Function;
11
- using v8::Isolate;
12
- using v8::Local;
13
- using v8::Number;
14
- using v8::Object;
15
- using v8::Persistent;
16
- using v8::ReadOnly;
17
- using v8::Value;
18
-
19
- namespace frida {
20
-
21
- static void UnrefGBytes(char* data, void* hint);
22
-
23
- IOStream::IOStream(GIOStream* handle, Runtime* runtime)
24
- : GLibObject(handle, runtime) {
25
- g_object_ref(handle_);
26
- }
27
-
28
- IOStream::~IOStream() {
29
- g_object_unref(handle_);
30
- }
31
-
32
- void IOStream::Init(Local<Object> exports, Runtime* runtime) {
33
- auto isolate = Isolate::GetCurrent();
34
-
35
- auto name = Nan::New("IOStream").ToLocalChecked();
36
- auto tpl = CreateTemplate(name, New, runtime);
37
-
38
- auto instance_tpl = tpl->InstanceTemplate();
39
- auto data = Local<Value>();
40
- Nan::SetAccessor(instance_tpl, Nan::New("isClosed").ToLocalChecked(),
41
- IsClosed, 0, data, DEFAULT, ReadOnly);
42
-
43
- Nan::SetPrototypeMethod(tpl, "close", Close);
44
- Nan::SetPrototypeMethod(tpl, "read", Read);
45
- Nan::SetPrototypeMethod(tpl, "write", Write);
46
-
47
- auto ctor = Nan::GetFunction(tpl).ToLocalChecked();
48
- Nan::Set(exports, name, ctor);
49
- runtime->SetDataPointer(IOSTREAM_DATA_CONSTRUCTOR,
50
- new Persistent<Function>(isolate, ctor));
51
- }
52
-
53
- Local<Object> IOStream::New(gpointer handle, Runtime* runtime) {
54
- auto ctor = Nan::New<Function>(
55
- *static_cast<Persistent<Function>*>(
56
- runtime->GetDataPointer(IOSTREAM_DATA_CONSTRUCTOR)));
57
- const int argc = 1;
58
- Local<Value> argv[argc] = { Nan::New<External>(handle) };
59
- return Nan::NewInstance(ctor, argc, argv).ToLocalChecked();
60
- }
61
-
62
- NAN_METHOD(IOStream::New) {
63
- if (!info.IsConstructCall()) {
64
- Nan::ThrowError("Use the `new` keyword to create a new instance");
65
- return;
66
- }
67
-
68
- if (info.Length() != 1 || !info[0]->IsExternal()) {
69
- Nan::ThrowTypeError("Bad argument, expected raw handle");
70
- return;
71
- }
72
-
73
- auto runtime = GetRuntimeFromConstructorArgs(info);
74
-
75
- auto handle = static_cast<GIOStream*>(
76
- Local<External>::Cast(info[0])->Value());
77
- auto wrapper = new IOStream(handle, runtime);
78
- auto obj = info.This();
79
- wrapper->Wrap(obj);
80
- Nan::Set(obj, Nan::New("signals").ToLocalChecked(),
81
- Signals::New(handle, runtime));
82
-
83
- info.GetReturnValue().Set(obj);
84
- }
85
-
86
- NAN_PROPERTY_GETTER(IOStream::IsClosed) {
87
- auto handle = ObjectWrap::Unwrap<IOStream>(
88
- info.Holder())->GetHandle<GIOStream>();
89
-
90
- info.GetReturnValue().Set(
91
- static_cast<bool>(g_io_stream_is_closed(handle)));
92
- }
93
-
94
- namespace {
95
-
96
- class CloseOperation : public Operation<GIOStream> {
97
- protected:
98
- void Begin() {
99
- g_io_stream_close_async(handle_, G_PRIORITY_DEFAULT, cancellable_,
100
- OnReady, this);
101
- }
102
-
103
- void End(GAsyncResult* result, GError** error) {
104
- g_io_stream_close_finish(handle_, result, error);
105
- }
106
-
107
- Local<Value> Result(Isolate* isolate) {
108
- return Nan::Undefined();
109
- }
110
- };
111
-
112
- }
113
-
114
- NAN_METHOD(IOStream::Close) {
115
- auto isolate = info.GetIsolate();
116
- auto wrapper = ObjectWrap::Unwrap<IOStream>(info.Holder());
117
-
118
- auto operation = new CloseOperation();
119
- operation->Schedule(isolate, wrapper, info);
120
-
121
- info.GetReturnValue().Set(operation->GetPromise(isolate));
122
- }
123
-
124
- namespace {
125
-
126
- class ReadOperation : public Operation<GIOStream> {
127
- public:
128
- ReadOperation(gsize count)
129
- : stream_(NULL),
130
- count_(count),
131
- bytes_(NULL) {
132
- }
133
-
134
- protected:
135
- void Begin() {
136
- stream_ = g_io_stream_get_input_stream(handle_);
137
-
138
- g_input_stream_read_bytes_async(stream_, count_, G_PRIORITY_DEFAULT,
139
- cancellable_, OnReady, this);
140
- }
141
-
142
- void End(GAsyncResult* result, GError** error) {
143
- bytes_ = g_input_stream_read_bytes_finish(stream_, result, error);
144
- }
145
-
146
- Local<Value> Result(Isolate* isolate) {
147
- gsize size;
148
- auto data = g_bytes_get_data(bytes_, &size);
149
- return Nan::NewBuffer(static_cast<char*>(const_cast<void*>(data)), size,
150
- UnrefGBytes, bytes_).ToLocalChecked();
151
- }
152
-
153
- private:
154
- GInputStream* stream_;
155
- gsize count_;
156
- GBytes* bytes_;
157
- };
158
-
159
- }
160
-
161
- NAN_METHOD(IOStream::Read) {
162
- auto isolate = info.GetIsolate();
163
- auto wrapper = ObjectWrap::Unwrap<IOStream>(info.Holder());
164
-
165
- if (info.Length() < 1 || !info[0]->IsNumber()) {
166
- Nan::ThrowTypeError("Bad argument, expected amount to read");
167
- return;
168
- }
169
- auto count = Nan::To<int32_t>(info[0]).FromMaybe(-1);
170
- if (count <= 0) {
171
- Nan::ThrowTypeError("Bad argument, expected amount to read");
172
- return;
173
- }
174
-
175
- auto operation = new ReadOperation(count);
176
- operation->Schedule(isolate, wrapper, info);
177
-
178
- info.GetReturnValue().Set(operation->GetPromise(isolate));
179
- }
180
-
181
- namespace {
182
-
183
- class WriteOperation : public Operation<GIOStream> {
184
- public:
185
- WriteOperation(Isolate* isolate, Local<Value> buffer)
186
- : stream_(NULL),
187
- data_(node::Buffer::Data(buffer)),
188
- count_(node::Buffer::Length(buffer)) {
189
- buffer_.Reset(buffer);
190
- }
191
-
192
- protected:
193
- void Begin() {
194
- stream_ = g_io_stream_get_output_stream(handle_);
195
-
196
- g_output_stream_write_all_async(stream_, data_, count_, G_PRIORITY_DEFAULT,
197
- cancellable_, OnReady, this);
198
- }
199
-
200
- void End(GAsyncResult* result, GError** error) {
201
- g_output_stream_write_all_finish(stream_, result, NULL, error);
202
- }
203
-
204
- Local<Value> Result(Isolate* isolate) {
205
- return Nan::Undefined();
206
- }
207
-
208
- private:
209
- GOutputStream* stream_;
210
- Nan::Persistent<Value, Nan::CopyablePersistentTraits<Value>> buffer_;
211
- const void* data_;
212
- gsize count_;
213
- };
214
-
215
- }
216
-
217
- NAN_METHOD(IOStream::Write) {
218
- auto isolate = info.GetIsolate();
219
- auto wrapper = ObjectWrap::Unwrap<IOStream>(info.Holder());
220
-
221
- auto num_args = info.Length();
222
- if (num_args < 1) {
223
- Nan::ThrowTypeError("Expected a buffer");
224
- return;
225
- }
226
-
227
- auto buffer = info[0];
228
- if (!node::Buffer::HasInstance(buffer)) {
229
- Nan::ThrowTypeError("Expected a buffer");
230
- return;
231
- }
232
-
233
- auto operation = new WriteOperation(isolate, buffer);
234
- operation->Schedule(isolate, wrapper, info);
235
-
236
- info.GetReturnValue().Set(operation->GetPromise(isolate));
237
- }
238
-
239
- static void UnrefGBytes(char* data, void* hint) {
240
- g_bytes_unref(static_cast<GBytes*>(hint));
241
- }
242
-
243
- }
package/src/iostream.h DELETED
@@ -1,30 +0,0 @@
1
- #ifndef FRIDANODE_IOSTREAM_H
2
- #define FRIDANODE_IOSTREAM_H
3
-
4
- #include "glib_object.h"
5
-
6
- #include <gio/gio.h>
7
-
8
- namespace frida {
9
-
10
- class IOStream : public GLibObject {
11
- public:
12
- static void Init(v8::Local<v8::Object> exports, Runtime* runtime);
13
- static v8::Local<v8::Object> New(gpointer handle, Runtime* runtime);
14
-
15
- private:
16
- explicit IOStream(GIOStream* handle, Runtime* runtime);
17
- ~IOStream();
18
-
19
- static NAN_METHOD(New);
20
-
21
- static NAN_PROPERTY_GETTER(IsClosed);
22
-
23
- static NAN_METHOD(Close);
24
- static NAN_METHOD(Read);
25
- static NAN_METHOD(Write);
26
- };
27
-
28
- }
29
-
30
- #endif
package/src/operation.h DELETED
@@ -1,94 +0,0 @@
1
- #ifndef FRIDANODE_OPERATION_H
2
- #define FRIDANODE_OPERATION_H
3
-
4
- #include "cancellable.h"
5
- #include "runtime.h"
6
-
7
- namespace frida {
8
-
9
- template<class T>
10
- class Operation {
11
- public:
12
- void Schedule(v8::Isolate* isolate, GLibObject* parent,
13
- const Nan::FunctionCallbackInfo<v8::Value>& info) {
14
- wrapper_ = parent;
15
- parent_.Reset(isolate, parent->handle(isolate));
16
- handle_ = parent->GetHandle<T>();
17
- resolver_.Reset(isolate,
18
- v8::Promise::Resolver::New(isolate->GetCurrentContext())
19
- .ToLocalChecked());
20
- runtime_ = parent->GetRuntime();
21
-
22
- auto num_args = info.Length();
23
- if (num_args >= 1) {
24
- cancellable_ = Cancellable::TryParse(info[num_args - 1], runtime_);
25
- }
26
-
27
- runtime_->GetUVContext()->IncreaseUsage();
28
- runtime_->GetGLibContext()->Schedule([=]() { Begin(); });
29
- }
30
-
31
- v8::Local<v8::Promise> GetPromise(v8::Isolate* isolate) {
32
- return v8::Local<v8::Promise::Resolver>::New(isolate, resolver_)->GetPromise();
33
- }
34
-
35
- protected:
36
- Operation()
37
- : wrapper_(NULL),
38
- handle_(NULL),
39
- cancellable_(NULL),
40
- runtime_(NULL),
41
- error_(NULL) {
42
- }
43
-
44
- virtual ~Operation() {
45
- if (error_ != NULL) {
46
- g_error_free(error_);
47
- }
48
- resolver_.Reset();
49
- parent_.Reset();
50
- }
51
-
52
- virtual void Begin() = 0;
53
- virtual void End(GAsyncResult* result, GError** error) = 0;
54
- virtual v8::Local<v8::Value> Result(v8::Isolate* isolate) = 0;
55
-
56
- template<typename W>
57
- W* GetWrapper() const { return static_cast<W*>(wrapper_); }
58
-
59
- static void OnReady(GObject* source_object, GAsyncResult* result, gpointer user_data) {
60
- static_cast<Operation<T>*>(user_data)->PerformEnd(result);
61
- }
62
-
63
- void* wrapper_;
64
- v8::Persistent<v8::Value> parent_;
65
- T* handle_;
66
- GCancellable* cancellable_;
67
- v8::Persistent<v8::Promise::Resolver> resolver_;
68
- Runtime* runtime_;
69
-
70
- private:
71
- void PerformEnd(GAsyncResult* result) {
72
- End(result, &error_);
73
- runtime_->GetUVContext()->Schedule([=]() { Deliver(); });
74
- }
75
-
76
- void Deliver() {
77
- auto isolate = v8::Isolate::GetCurrent();
78
- auto context = isolate->GetCurrentContext();
79
- auto resolver = v8::Local<v8::Promise::Resolver>::New(isolate, resolver_);
80
- if (error_ == NULL) {
81
- resolver->Resolve(context, Result(isolate)).FromJust();
82
- } else {
83
- resolver->Reject(context, Nan::Error(error_->message)).FromJust();
84
- }
85
- runtime_->GetUVContext()->DecreaseUsage();
86
- delete this;
87
- }
88
-
89
- GError* error_;
90
- };
91
-
92
- }
93
-
94
- #endif
@@ -1,100 +0,0 @@
1
- #include "portal_membership.h"
2
-
3
- #include "operation.h"
4
-
5
- #define PORTAL_MEMBERSHIP_DATA_CONSTRUCTOR "portal_membership:ctor"
6
-
7
- using v8::External;
8
- using v8::Function;
9
- using v8::Isolate;
10
- using v8::Local;
11
- using v8::Object;
12
- using v8::Persistent;
13
- using v8::Value;
14
-
15
- namespace frida {
16
-
17
- PortalMembership::PortalMembership(FridaPortalMembership* handle, Runtime* runtime)
18
- : GLibObject(handle, runtime) {
19
- g_object_ref(handle_);
20
- }
21
-
22
- PortalMembership::~PortalMembership() {
23
- frida_unref(handle_);
24
- }
25
-
26
- void PortalMembership::Init(Local<Object> exports, Runtime* runtime) {
27
- auto isolate = Isolate::GetCurrent();
28
-
29
- auto name = Nan::New("PortalMembership").ToLocalChecked();
30
- auto tpl = CreateTemplate(name, New, runtime);
31
-
32
- Nan::SetPrototypeMethod(tpl, "terminate", Terminate);
33
-
34
- auto ctor = Nan::GetFunction(tpl).ToLocalChecked();
35
- Nan::Set(exports, name, ctor);
36
- runtime->SetDataPointer(PORTAL_MEMBERSHIP_DATA_CONSTRUCTOR,
37
- new Persistent<Function>(isolate, ctor));
38
- }
39
-
40
- Local<Object> PortalMembership::New(gpointer handle, Runtime* runtime) {
41
- auto ctor = Nan::New<Function>(
42
- *static_cast<Persistent<Function>*>(
43
- runtime->GetDataPointer(PORTAL_MEMBERSHIP_DATA_CONSTRUCTOR)));
44
- const int argc = 1;
45
- Local<Value> argv[argc] = { Nan::New<External>(handle) };
46
- return Nan::NewInstance(ctor, argc, argv).ToLocalChecked();
47
- }
48
-
49
- NAN_METHOD(PortalMembership::New) {
50
- if (!info.IsConstructCall()) {
51
- Nan::ThrowError("Use the `new` keyword to create a new instance");
52
- return;
53
- }
54
-
55
- if (info.Length() != 1 || !info[0]->IsExternal()) {
56
- Nan::ThrowTypeError("Bad argument, expected raw handle");
57
- return;
58
- }
59
-
60
- auto runtime = GetRuntimeFromConstructorArgs(info);
61
-
62
- auto handle = static_cast<FridaPortalMembership*>(
63
- Local<External>::Cast(info[0])->Value());
64
- auto wrapper = new PortalMembership(handle, runtime);
65
- auto obj = info.This();
66
- wrapper->Wrap(obj);
67
-
68
- info.GetReturnValue().Set(obj);
69
- }
70
-
71
- namespace {
72
-
73
- class TerminateOperation : public Operation<FridaPortalMembership> {
74
- protected:
75
- void Begin() {
76
- frida_portal_membership_terminate(handle_, cancellable_, OnReady, this);
77
- }
78
-
79
- void End(GAsyncResult* result, GError** error) {
80
- frida_portal_membership_terminate_finish(handle_, result, error);
81
- }
82
-
83
- Local<Value> Result(Isolate* isolate) {
84
- return Nan::Undefined();
85
- }
86
- };
87
-
88
- }
89
-
90
- NAN_METHOD(PortalMembership::Terminate) {
91
- auto isolate = info.GetIsolate();
92
- auto wrapper = ObjectWrap::Unwrap<PortalMembership>(info.Holder());
93
-
94
- auto operation = new TerminateOperation();
95
- operation->Schedule(isolate, wrapper, info);
96
-
97
- info.GetReturnValue().Set(operation->GetPromise(isolate));
98
- }
99
-
100
- }
@@ -1,26 +0,0 @@
1
- #ifndef FRIDANODE_PORTAL_MEMBERSHIP_H
2
- #define FRIDANODE_PORTAL_MEMBERSHIP_H
3
-
4
- #include "glib_object.h"
5
-
6
- #include <frida-core.h>
7
-
8
- namespace frida {
9
-
10
- class PortalMembership : public GLibObject {
11
- public:
12
- static void Init(v8::Local<v8::Object> exports, Runtime* runtime);
13
- static v8::Local<v8::Object> New(gpointer handle, Runtime* runtime);
14
-
15
- private:
16
- explicit PortalMembership(FridaPortalMembership* handle, Runtime* runtime);
17
- ~PortalMembership();
18
-
19
- static NAN_METHOD(New);
20
-
21
- static NAN_METHOD(Terminate);
22
- };
23
-
24
- }
25
-
26
- #endif