Skip to content

Commit

Permalink
gumjs: Fix runtime serialization not handling unicode (#714)
Browse files Browse the repository at this point in the history
And also support building without source maps.
  • Loading branch information
milahu committed Feb 10, 2023
1 parent cd20e03 commit acaec42
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bindings/gumjs/generate-runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def generate_runtime_quick(runtime_name, output_dir, output, inputs, quickcompil

modules.append((input_bytecode_identifier, bytecode_size, input_source_map_identifier))
else:
output_file.write("\nstatic const gchar {0}[1] = {{ 0 }};\n".format(input_source_map_identifier))
modules.append((input_bytecode_identifier, bytecode_size, "NULL"))

output_file.write("\nstatic const GumQuickRuntimeModule gumjs_{0}_modules[] =\n{{".format(runtime_name))
Expand Down Expand Up @@ -199,6 +200,7 @@ def generate_runtime_v8(runtime_name, output_dir, output, inputs):

modules.append((input_name, input_source_code_identifier, input_source_map_identifier))
else:
output_file.write("\nstatic const gchar {0}[1] = {{ 0 }};\n".format(input_source_map_identifier))
modules.append((input_name, input_source_code_identifier, "NULL"))

output_file.write("\nstatic const GumV8RuntimeModule gumjs_{0}_modules[] =\n{{".format(runtime_name))
Expand Down Expand Up @@ -383,6 +385,7 @@ def to_canonical_source_path(path):


def write_bytes(data, sink):
"Write bytes as signed integers between -128 and 127."
sink.write("\n ")
line_length = 0
offset = 0
Expand All @@ -393,6 +396,9 @@ def write_bytes(data, sink):
if line_length >= 70:
sink.write("\n ")
line_length = 0
# Convert unsigned to signed for UTF-8.
if b >= 128:
b -= 256
token = str(b)
sink.write(token)

Expand Down

0 comments on commit acaec42

Please sign in to comment.