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
package/src/addon.cc DELETED
@@ -1,78 +0,0 @@
1
- #include "application.h"
2
- #include "bus.h"
3
- #include "cancellable.h"
4
- #include "child.h"
5
- #include "crash.h"
6
- #include "device.h"
7
- #include "device_manager.h"
8
- #include "endpoint_parameters.h"
9
- #include "glib_context.h"
10
- #include "iostream.h"
11
- #include "portal_membership.h"
12
- #include "portal_service.h"
13
- #include "process.h"
14
- #include "relay.h"
15
- #include "runtime.h"
16
- #include "script.h"
17
- #include "service.h"
18
- #include "session.h"
19
- #include "signals.h"
20
- #include "spawn.h"
21
- #include "uv_context.h"
22
-
23
- using v8::Context;
24
- using v8::Local;
25
- using v8::Object;
26
- using v8::Value;
27
-
28
- namespace frida {
29
-
30
- static void DisposeAll(void* data);
31
-
32
- static void InitAll(Local<Object> exports,
33
- Local<Value> module,
34
- Local<Context> context) {
35
- frida_init();
36
-
37
- auto uv_context = new UVContext(uv_default_loop());
38
- auto glib_context = new GLibContext(frida_get_main_context());
39
- auto runtime = new Runtime(uv_context, glib_context);
40
-
41
- Signals::Init(exports, runtime);
42
-
43
- DeviceManager::Init(exports, runtime);
44
- Device::Init(exports, runtime);
45
- Application::Init(exports, runtime);
46
- Process::Init(exports, runtime);
47
- Spawn::Init(exports, runtime);
48
- Child::Init(exports, runtime);
49
- Crash::Init(exports, runtime);
50
- Bus::Init(exports, runtime);
51
- Service::Init(exports, runtime);
52
- Session::Init(exports, runtime);
53
- Script::Init(exports, runtime);
54
- Relay::Init(exports, runtime);
55
- PortalMembership::Init(exports, runtime);
56
- PortalService::Init(exports, runtime);
57
- EndpointParameters::Init(exports, runtime);
58
- IOStream::Init(exports, runtime);
59
- Cancellable::Init(exports, runtime);
60
-
61
- #if NODE_VERSION_AT_LEAST(11, 0, 0)
62
- node::AddEnvironmentCleanupHook(context->GetIsolate(), DisposeAll, runtime);
63
- #else
64
- node::AtExit(DisposeAll, runtime);
65
- #endif
66
- }
67
-
68
- static void DisposeAll(void* data) {
69
- auto runtime = static_cast<Runtime*>(data);
70
-
71
- DeviceManager::Dispose(runtime);
72
-
73
- delete runtime;
74
- }
75
-
76
- }
77
-
78
- NODE_MODULE_CONTEXT_AWARE(frida_binding, frida::InitAll)
@@ -1,148 +0,0 @@
1
- #include "application.h"
2
-
3
- #include <cstring>
4
-
5
- #define APPLICATION_DATA_CONSTRUCTOR "application:ctor"
6
-
7
- using std::strcmp;
8
- using v8::DEFAULT;
9
- using v8::External;
10
- using v8::Function;
11
- using v8::Integer;
12
- using v8::Isolate;
13
- using v8::Local;
14
- using v8::Object;
15
- using v8::Persistent;
16
- using v8::ReadOnly;
17
- using v8::String;
18
- using v8::Value;
19
-
20
- namespace frida {
21
-
22
- Application::Application(FridaApplication* handle, Runtime* runtime)
23
- : GLibObject(handle, runtime) {
24
- g_object_ref(handle_);
25
- }
26
-
27
- Application::~Application() {
28
- g_object_unref(handle_);
29
- }
30
-
31
- void Application::Init(Local<Object> exports, Runtime* runtime) {
32
- auto isolate = Isolate::GetCurrent();
33
-
34
- auto name = Nan::New("Application").ToLocalChecked();
35
- auto tpl = CreateTemplate(name, Application::New, runtime);
36
-
37
- auto instance_tpl = tpl->InstanceTemplate();
38
- auto data = Local<Value>();
39
- Nan::SetAccessor(instance_tpl, Nan::New("parameters").ToLocalChecked(),
40
- GetParameters, 0, data, DEFAULT, ReadOnly);
41
- Nan::SetAccessor(instance_tpl, Nan::New("pid").ToLocalChecked(),
42
- GetPid, 0, data, DEFAULT, ReadOnly);
43
- Nan::SetAccessor(instance_tpl, Nan::New("name").ToLocalChecked(),
44
- GetName, 0, data, DEFAULT, ReadOnly);
45
- Nan::SetAccessor(instance_tpl, Nan::New("identifier").ToLocalChecked(),
46
- GetIdentifier, 0, data, DEFAULT, ReadOnly);
47
-
48
- auto ctor = Nan::GetFunction(tpl).ToLocalChecked();
49
- Nan::Set(exports, name, ctor);
50
- runtime->SetDataPointer(APPLICATION_DATA_CONSTRUCTOR,
51
- new Persistent<Function>(isolate, ctor));
52
- }
53
-
54
- Local<Object> Application::New(gpointer handle, Runtime* runtime) {
55
- auto ctor = Nan::New<Function>(
56
- *static_cast<Persistent<Function>*>(
57
- runtime->GetDataPointer(APPLICATION_DATA_CONSTRUCTOR)));
58
-
59
- const int argc = 1;
60
- Local<Value> argv[argc] = { Nan::New<External>(handle) };
61
- return Nan::NewInstance(ctor, argc, argv).ToLocalChecked();
62
- }
63
-
64
- NAN_METHOD(Application::New) {
65
- if (!info.IsConstructCall()) {
66
- Nan::ThrowError("Use the `new` keyword to create a new instance");
67
- return;
68
- }
69
-
70
- if (info.Length() != 1 || !info[0]->IsExternal()) {
71
- Nan::ThrowTypeError("Bad argument, expected raw handle");
72
- return;
73
- }
74
-
75
- auto runtime = GetRuntimeFromConstructorArgs(info);
76
-
77
- auto handle = static_cast<FridaApplication*>(
78
- Local<External>::Cast(info[0])->Value());
79
- auto wrapper = new Application(handle, runtime);
80
- auto obj = info.This();
81
- wrapper->Wrap(obj);
82
-
83
- info.GetReturnValue().Set(obj);
84
- }
85
-
86
- NAN_PROPERTY_GETTER(Application::GetIdentifier) {
87
- auto handle = ObjectWrap::Unwrap<Application>(
88
- info.Holder())->GetHandle<FridaApplication>();
89
-
90
- info.GetReturnValue().Set(
91
- Nan::New(frida_application_get_identifier(handle)).ToLocalChecked());
92
- }
93
-
94
- NAN_PROPERTY_GETTER(Application::GetName) {
95
- auto handle = ObjectWrap::Unwrap<Application>(
96
- info.Holder())->GetHandle<FridaApplication>();
97
-
98
- info.GetReturnValue().Set(
99
- Nan::New(frida_application_get_name(handle)).ToLocalChecked());
100
- }
101
-
102
- NAN_PROPERTY_GETTER(Application::GetPid) {
103
- auto isolate = info.GetIsolate();
104
- auto handle = ObjectWrap::Unwrap<Application>(
105
- info.Holder())->GetHandle<FridaApplication>();
106
-
107
- info.GetReturnValue().Set(
108
- Integer::NewFromUnsigned(isolate, frida_application_get_pid(handle)));
109
- }
110
-
111
- NAN_PROPERTY_GETTER(Application::GetParameters) {
112
- auto wrapper = ObjectWrap::Unwrap<Application>(info.Holder());
113
- auto handle = wrapper->GetHandle<FridaApplication>();
114
-
115
- GHashTable* parameters = frida_application_get_parameters(handle);
116
- info.GetReturnValue().Set(ParseParameters(parameters));
117
- }
118
-
119
- Local<Value> Application::ParseParameters(GHashTable* dict) {
120
- auto result = Nan::New<Object>();
121
-
122
- GHashTableIter iter;
123
- gpointer raw_key, raw_value;
124
-
125
- g_hash_table_iter_init(&iter, dict);
126
-
127
- while (g_hash_table_iter_next(&iter, &raw_key, &raw_value)) {
128
- char* canonicalized_key =
129
- Runtime::ParameterNameFromC(static_cast<char*>(raw_key));
130
- GVariant* var_value = static_cast<GVariant*>(raw_value);
131
-
132
- Local<String> key = Nan::New(canonicalized_key).ToLocalChecked();
133
- Local<Value> value;
134
- if (strcmp(canonicalized_key, "started") == 0 &&
135
- g_variant_is_of_type(var_value, G_VARIANT_TYPE_STRING)) {
136
- value = Runtime::ValueFromDatetime(g_variant_get_string(var_value, NULL));
137
- } else {
138
- value = Runtime::ValueFromVariant(var_value);
139
- }
140
- Nan::Set(result, key, value);
141
-
142
- g_free(canonicalized_key);
143
- }
144
-
145
- return result;
146
- }
147
-
148
- }
package/src/application.h DELETED
@@ -1,31 +0,0 @@
1
- #ifndef FRIDANODE_APPLICATION_H
2
- #define FRIDANODE_APPLICATION_H
3
-
4
- #include "glib_object.h"
5
-
6
- #include <frida-core.h>
7
-
8
- namespace frida {
9
-
10
- class Application : 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 Application(FridaApplication* handle, Runtime* runtime);
17
- ~Application();
18
-
19
- static NAN_METHOD(New);
20
-
21
- static NAN_PROPERTY_GETTER(GetIdentifier);
22
- static NAN_PROPERTY_GETTER(GetName);
23
- static NAN_PROPERTY_GETTER(GetPid);
24
- static NAN_PROPERTY_GETTER(GetParameters);
25
-
26
- static v8::Local<v8::Value> ParseParameters(GHashTable* dict);
27
- };
28
-
29
- }
30
-
31
- #endif
@@ -1,174 +0,0 @@
1
- #include "authentication.h"
2
-
3
- using frida::Runtime;
4
- using v8::External;
5
- using v8::Function;
6
- using v8::Isolate;
7
- using v8::Local;
8
- using v8::Object;
9
- using v8::Persistent;
10
- using v8::String;
11
- using v8::Value;
12
-
13
- struct _FridaNodeAuthenticationService {
14
- GObject parent;
15
- Persistent<Function>* callback;
16
- Runtime* runtime;
17
- };
18
-
19
- static void frida_node_authentication_service_iface_init(gpointer g_iface,
20
- gpointer iface_data);
21
- static void frida_node_authentication_service_dispose(GObject* object);
22
- static void frida_node_authentication_service_authenticate(
23
- FridaAuthenticationService* service, const gchar* token,
24
- GCancellable* cancellable, GAsyncReadyCallback callback,
25
- gpointer user_data);
26
- static gchar* frida_node_authentication_service_authenticate_finish(
27
- FridaAuthenticationService* service, GAsyncResult* result, GError** error);
28
-
29
- G_DEFINE_TYPE_EXTENDED(
30
- FridaNodeAuthenticationService,
31
- frida_node_authentication_service,
32
- G_TYPE_OBJECT,
33
- 0,
34
- G_IMPLEMENT_INTERFACE(FRIDA_TYPE_AUTHENTICATION_SERVICE,
35
- frida_node_authentication_service_iface_init))
36
-
37
- FridaAuthenticationService* frida_node_authentication_service_new(
38
- Local<Function> callback, Runtime* runtime) {
39
- auto service = static_cast<FridaNodeAuthenticationService*>(
40
- g_object_new(FRIDA_TYPE_NODE_AUTHENTICATION_SERVICE, NULL));
41
- service->callback = new Persistent<Function>(Isolate::GetCurrent(), callback);
42
- service->runtime = runtime;
43
- return FRIDA_AUTHENTICATION_SERVICE(service);
44
- }
45
-
46
- static void frida_node_authentication_service_class_init(
47
- FridaNodeAuthenticationServiceClass* klass)
48
- {
49
- GObjectClass* object_class = G_OBJECT_CLASS(klass);
50
-
51
- object_class->dispose = frida_node_authentication_service_dispose;
52
- }
53
-
54
- static void frida_node_authentication_service_iface_init(gpointer g_iface,
55
- gpointer iface_data) {
56
- auto iface = static_cast<FridaAuthenticationServiceIface*>(g_iface);
57
-
58
- iface->authenticate =
59
- frida_node_authentication_service_authenticate;
60
- iface->authenticate_finish =
61
- frida_node_authentication_service_authenticate_finish;
62
- }
63
-
64
- static void frida_node_authentication_service_init(
65
- FridaNodeAuthenticationService* self) {
66
- }
67
-
68
- static void frida_node_authentication_service_dispose(GObject* object) {
69
- auto self = FRIDA_NODE_AUTHENTICATION_SERVICE(object);
70
-
71
- Persistent<Function>* callback = self->callback;
72
- if (callback != NULL) {
73
- self->callback = NULL;
74
- self->runtime->GetUVContext()->Schedule([=]() {
75
- delete callback;
76
- });
77
- }
78
-
79
- G_OBJECT_CLASS(frida_node_authentication_service_parent_class)->dispose(
80
- object);
81
- }
82
-
83
- static NAN_METHOD(OnAuthenticationSuccess) {
84
- auto task = static_cast<GTask*>(info.Data().As<External>()->Value ());
85
- auto self = static_cast<FridaNodeAuthenticationService*>(
86
- g_task_get_source_object(task));
87
-
88
- gchar* session_info = NULL;
89
- if (info.Length() >= 1) {
90
- auto val = info[0];
91
- if (val->IsObject() && !val->IsNull()) {
92
- Local<String> json = self->runtime->ValueToJson(val);
93
- Nan::Utf8String str(json);
94
- session_info = g_strdup(*str);
95
- }
96
- }
97
-
98
- if (session_info != NULL) {
99
- g_task_return_pointer(task, session_info, g_free);
100
- } else {
101
- g_task_return_new_error(task, FRIDA_ERROR, FRIDA_ERROR_INVALID_ARGUMENT,
102
- "Internal error");
103
- }
104
-
105
- g_object_unref(task);
106
- }
107
-
108
- static NAN_METHOD(OnAuthenticationFailure) {
109
- auto task = static_cast<GTask*>(info.Data().As<External>()->Value ());
110
-
111
- Local<Value> fallback_message = Nan::New("Internal error").ToLocalChecked();
112
- Local<Value> message = fallback_message;
113
- if (info.Length() >= 1) {
114
- auto error_value = info[0];
115
- if (error_value->IsObject()) {
116
- message = Nan::Get(error_value.As<Object>(),
117
- Nan::New("message").ToLocalChecked()).FromMaybe(fallback_message);
118
- }
119
- }
120
-
121
- Nan::Utf8String str(message);
122
- g_task_return_new_error(task, FRIDA_ERROR, FRIDA_ERROR_INVALID_ARGUMENT,
123
- "%s", *str);
124
-
125
- g_object_unref(task);
126
- }
127
-
128
- static void frida_node_authentication_service_authenticate(
129
- FridaAuthenticationService* service, const gchar* token,
130
- GCancellable* cancellable, GAsyncReadyCallback callback,
131
- gpointer user_data) {
132
- auto self = FRIDA_NODE_AUTHENTICATION_SERVICE(service);
133
-
134
- auto task = g_task_new(self, cancellable, callback, user_data);
135
- g_task_set_task_data(task, g_strdup(token), g_free);
136
-
137
- self->runtime->GetUVContext()->Schedule([=]() {
138
- auto context = Isolate::GetCurrent()->GetCurrentContext();
139
-
140
- bool scheduled = false;
141
- Local<Value> no_result = Nan::Undefined();
142
-
143
- auto callback = Nan::New<Function>(*self->callback);
144
- Local<Value> token_value = Nan::New(static_cast<gchar*>(
145
- g_task_get_task_data(task))).ToLocalChecked();
146
-
147
- Local<Value> promise_value = callback->Call(context, Nan::Undefined(), 1,
148
- &token_value).FromMaybe(no_result);
149
- if (promise_value->IsObject()) {
150
- auto promise = promise_value.As<Object>();
151
- auto then = Nan::Get(promise, Nan::New("then").ToLocalChecked())
152
- .FromMaybe(no_result);
153
- if (then->IsFunction()) {
154
- Local<Value> argv[] = {
155
- Nan::New<Function>(OnAuthenticationSuccess, Nan::New<External>(task)),
156
- Nan::New<Function>(OnAuthenticationFailure, Nan::New<External>(task)),
157
- };
158
- scheduled = !then.As<Function>()->Call(context, promise_value,
159
- G_N_ELEMENTS(argv), argv).IsEmpty();
160
- }
161
- }
162
-
163
- if (!scheduled) {
164
- g_task_return_new_error(task, FRIDA_ERROR, FRIDA_ERROR_INVALID_ARGUMENT,
165
- "Internal error");
166
- g_object_unref(task);
167
- }
168
- });
169
- }
170
-
171
- static gchar* frida_node_authentication_service_authenticate_finish(
172
- FridaAuthenticationService* service, GAsyncResult* result, GError** error) {
173
- return static_cast<gchar*>(g_task_propagate_pointer(G_TASK(result), error));
174
- }
@@ -1,24 +0,0 @@
1
- #ifndef FRIDANODE_AUTHENTICATION_H
2
- #define FRIDANODE_AUTHENTICATION_H
3
-
4
- #include "runtime.h"
5
-
6
- #include <frida-core.h>
7
- #include <node.h>
8
-
9
- G_BEGIN_DECLS
10
-
11
- #define FRIDA_TYPE_NODE_AUTHENTICATION_SERVICE (frida_node_authentication_service_get_type())
12
- G_DECLARE_FINAL_TYPE(
13
- FridaNodeAuthenticationService,
14
- frida_node_authentication_service,
15
- FRIDA,
16
- NODE_AUTHENTICATION_SERVICE,
17
- GObject)
18
-
19
- FridaAuthenticationService* frida_node_authentication_service_new(
20
- v8::Local<v8::Function> callback, frida::Runtime* runtime);
21
-
22
- G_END_DECLS
23
-
24
- #endif
package/src/bus.cc DELETED
@@ -1,167 +0,0 @@
1
- #include "bus.h"
2
-
3
- #include "operation.h"
4
- #include "signals.h"
5
- #include "usage_monitor.h"
6
-
7
- #include <cstring>
8
-
9
- #define BUS_DATA_CONSTRUCTOR "bus:ctor"
10
-
11
- using std::strcmp;
12
- using v8::External;
13
- using v8::Function;
14
- using v8::Isolate;
15
- using v8::Local;
16
- using v8::Object;
17
- using v8::Persistent;
18
- using v8::Value;
19
-
20
- namespace frida {
21
-
22
- Bus::Bus(FridaBus* handle, Runtime* runtime)
23
- : GLibObject(handle, runtime) {
24
- g_object_ref(handle_);
25
- }
26
-
27
- Bus::~Bus() {
28
- g_object_unref(handle_);
29
- }
30
-
31
- void Bus::Init(Local<Object> exports, Runtime* runtime) {
32
- auto isolate = Isolate::GetCurrent();
33
-
34
- auto name = Nan::New("Bus").ToLocalChecked();
35
- auto tpl = CreateTemplate(name, New, runtime);
36
-
37
- Nan::SetPrototypeMethod(tpl, "attach", Attach);
38
- Nan::SetPrototypeMethod(tpl, "post", Post);
39
-
40
- auto ctor = Nan::GetFunction(tpl).ToLocalChecked();
41
- Nan::Set(exports, name, ctor);
42
- runtime->SetDataPointer(BUS_DATA_CONSTRUCTOR,
43
- new Persistent<Function>(isolate, ctor));
44
- }
45
-
46
- Local<Object> Bus::New(gpointer handle, Runtime* runtime) {
47
- auto ctor = Nan::New<Function>(
48
- *static_cast<Persistent<Function>*>(
49
- runtime->GetDataPointer(BUS_DATA_CONSTRUCTOR)));
50
- const int argc = 1;
51
- Local<Value> argv[argc] = { Nan::New<External>(handle) };
52
- return Nan::NewInstance(ctor, argc, argv).ToLocalChecked();
53
- }
54
-
55
- NAN_METHOD(Bus::New) {
56
- if (!info.IsConstructCall()) {
57
- Nan::ThrowError("Use the `new` keyword to create a new instance");
58
- return;
59
- }
60
-
61
- if (info.Length() != 1 || !info[0]->IsExternal()) {
62
- Nan::ThrowTypeError("Bad argument, expected raw handle");
63
- return;
64
- }
65
-
66
- auto runtime = GetRuntimeFromConstructorArgs(info);
67
-
68
- auto handle = static_cast<FridaBus*>(
69
- Local<External>::Cast(info[0])->Value());
70
- auto wrapper = new Bus(handle, runtime);
71
- auto obj = info.This();
72
- wrapper->Wrap(obj);
73
- auto signals_obj = Signals::New(handle, runtime, TransformSignal, runtime);
74
-
75
- Nan::Set(obj, Nan::New("signals").ToLocalChecked(), signals_obj);
76
-
77
- auto signals_wrapper = ObjectWrap::Unwrap<Signals>(signals_obj);
78
- signals_wrapper->SetConnectCallback(OnConnect, runtime);
79
- signals_wrapper->SetDisconnectCallback(OnDisconnect, runtime);
80
-
81
- info.GetReturnValue().Set(obj);
82
- }
83
-
84
- namespace {
85
-
86
- class AttachOperation : public Operation<FridaBus> {
87
- protected:
88
- void Begin() {
89
- frida_bus_attach(handle_, cancellable_, OnReady, this);
90
- }
91
-
92
- void End(GAsyncResult* result, GError** error) {
93
- frida_bus_attach_finish(handle_, result, error);
94
- }
95
-
96
- Local<Value> Result(Isolate* isolate) {
97
- return Nan::Undefined();
98
- }
99
- };
100
-
101
- }
102
-
103
- NAN_METHOD(Bus::Attach) {
104
- auto isolate = info.GetIsolate();
105
- auto wrapper = ObjectWrap::Unwrap<Bus>(info.Holder());
106
-
107
- auto operation = new AttachOperation();
108
- operation->Schedule(isolate, wrapper, info);
109
-
110
- info.GetReturnValue().Set(operation->GetPromise(isolate));
111
- }
112
-
113
- NAN_METHOD(Bus::Post) {
114
- auto wrapper = ObjectWrap::Unwrap<Bus>(info.Holder());
115
-
116
- auto num_args = info.Length();
117
- if (num_args < 2) {
118
- Nan::ThrowTypeError("Expected message and data");
119
- return;
120
- }
121
-
122
- Nan::Utf8String message(wrapper->runtime_->ValueToJson(info[0]));
123
-
124
- GBytes* data = NULL;
125
- auto buffer = info[1];
126
- if (!buffer->IsNull()) {
127
- if (!node::Buffer::HasInstance(buffer)) {
128
- Nan::ThrowTypeError("Expected a buffer");
129
- return;
130
- }
131
- data = g_bytes_new(node::Buffer::Data(buffer),
132
- node::Buffer::Length(buffer));
133
- }
134
-
135
- frida_bus_post(wrapper->GetHandle<FridaBus>(), *message, data);
136
-
137
- g_bytes_unref(data);
138
- }
139
-
140
- Local<Value> Bus::TransformSignal(const gchar* name, guint index,
141
- const GValue* value, gpointer user_data) {
142
- if (index != 0 || strcmp(name, "message") != 0)
143
- return Local<Value>();
144
- auto runtime = static_cast<Runtime*>(user_data);
145
- auto json = Nan::New(g_value_get_string(value)).ToLocalChecked();
146
- return runtime->ValueFromJson(json);
147
- }
148
-
149
- void Bus::OnConnect(const gchar* name, gpointer user_data) {
150
- auto runtime = static_cast<Runtime*>(user_data);
151
-
152
- if (ShouldStayAliveToEmit(name))
153
- runtime->GetUVContext()->IncreaseUsage();
154
- }
155
-
156
- void Bus::OnDisconnect(const gchar* name, gpointer user_data) {
157
- auto runtime = static_cast<Runtime*>(user_data);
158
-
159
- if (ShouldStayAliveToEmit(name))
160
- runtime->GetUVContext()->DecreaseUsage();
161
- }
162
-
163
- bool Bus::ShouldStayAliveToEmit(const gchar* name) {
164
- return strcmp(name, "detached") == 0 || strcmp(name, "message") == 0;
165
- }
166
-
167
- }
package/src/bus.h DELETED
@@ -1,33 +0,0 @@
1
- #ifndef FRIDANODE_BUS_H
2
- #define FRIDANODE_BUS_H
3
-
4
- #include "glib_object.h"
5
-
6
- #include <frida-core.h>
7
-
8
- namespace frida {
9
-
10
- class Bus : 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 Bus(FridaBus* handle, Runtime* runtime);
17
- ~Bus();
18
-
19
- static NAN_METHOD(New);
20
-
21
- static NAN_METHOD(Attach);
22
- static NAN_METHOD(Post);
23
-
24
- static v8::Local<v8::Value> TransformSignal(const gchar* name, guint index,
25
- const GValue* value, gpointer user_data);
26
- static void OnConnect(const gchar* signal, gpointer user_data);
27
- static void OnDisconnect(const gchar* signal, gpointer user_data);
28
- static bool ShouldStayAliveToEmit(const gchar* signal);
29
- };
30
-
31
- }
32
-
33
- #endif