From 6f32a08382f440d3fe0d64d975a5b8ed1c87ba1c Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Sun, 17 Mar 2024 15:51:28 +0100 Subject: [PATCH] feat: implement `modulerefs` in `dotnet` module. --- lib/src/modules/dotnet/parser.rs | 11 +++++++++++ ...a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out | 6 +++++- ...87fbb187e07985a2f69fe1b94f3a83cfbba4e4104c2b26.out | 1 + ...3e0ad1162bd542e5cb948d1a4ea5a575a14d6b9d6ee849.out | 1 + ...b2c00b48030a62d286de5493c25c000a00f5fbc6e7b746.out | 1 + ...1b468ef9358c1068950f849c612ab808225b359db0bb8c.out | 1 + ...fb57db4f940e98d03e054ca2b88ef5a41f72b5787841b3.out | 1 + ...7b366863af2092af954dad65df534bff603b9afcb49cd4.out | 6 +++++- lib/src/modules/protos/dotnet.proto | 7 ++++--- 9 files changed, 30 insertions(+), 5 deletions(-) diff --git a/lib/src/modules/dotnet/parser.rs b/lib/src/modules/dotnet/parser.rs index fa865091e..9c0d8e80a 100644 --- a/lib/src/modules/dotnet/parser.rs +++ b/lib/src/modules/dotnet/parser.rs @@ -2689,6 +2689,13 @@ impl From> for protos::dotnet::Dotnet { dotnet.assembly_refs.iter().map(protos::dotnet::AssemblyRef::from), ); + result.modulerefs.extend( + dotnet + .module_refs + .iter() + .filter_map(|module_ref| module_ref.map(|s| s.to_string())), + ); + result.streams.extend( dotnet.stream_headers.iter().map(protos::dotnet::Stream::from), ); @@ -2728,6 +2735,10 @@ impl From> for protos::dotnet::Dotnet { result.constants.len().try_into().unwrap(), ); + result.set_number_of_modulerefs( + result.modulerefs.len().try_into().unwrap(), + ); + result } } diff --git a/lib/src/modules/dotnet/tests/testdata/0224ad9739f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out b/lib/src/modules/dotnet/tests/testdata/0224ad9739f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out index 69f54f5ee..357a64d96 100644 --- a/lib/src/modules/dotnet/tests/testdata/0224ad9739f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out +++ b/lib/src/modules/dotnet/tests/testdata/0224ad9739f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out @@ -6,6 +6,7 @@ number_of_guids: 1 number_of_resources: 1 number_of_classes: 4 number_of_assembly_refs: 4 +number_of_modulerefs: 2 number_of_user_strings: 10 number_of_constants: 3 typelib: "286e82a5-8e28-4288-b175-0099b68f4880" @@ -410,4 +411,7 @@ user_strings: - "*\000=\000L\000o\000a\000d\000 \000D\000N\000G\000u\000a\000r\000d\000 \000R\000u\000n\000t\000i\000m\000e\000 \000l\000i\000b\000r\000a\000r\000y\000 \000f\000a\000i\000l\000e\000d\000,\000 \000r\000u\000n\000t\000i\000m\000e\000 \000l\000i\000b\000r\000a\000r\000y\000 \000n\000o\000t\000 \000f\000o\000u\000n\000d\000 \000o\000r\000 \000A\000c\000c\000e\000s\000s\000 \000D\000e\000n\000i\000e\000d\000.\000=\000*\000[\000O\000c\000t\000o\000p\000u\000s\000R\000P\000A\000.\000C\000s\000v\000.\000d\000l\000l\000]\000" - "E\000r\000r\000o\000r\000,\000 \000D\000N\000G\000u\000a\000r\000d\000 \000R\000u\000n\000t\000i\000m\000e\000 \000l\000i\000b\000r\000a\000r\000y\000 \000n\000o\000t\000 \000l\000o\000a\000d\000e\000d\000!\000" - "A\000 \000n\000e\000w\000e\000r\000 \000v\000e\000r\000s\000i\000o\000n\000 \000o\000f\000 \000D\000N\000G\000u\000a\000r\000d\000 \000R\000u\000n\000t\000i\000m\000e\000 \000l\000i\000b\000r\000a\000r\000y\000 \000i\000s\000 \000n\000e\000e\000d\000e\000d\000 \000t\000o\000 \000r\000u\000n\000 \000t\000h\000i\000s\000 \000a\000p\000p\000l\000i\000c\000a\000t\000i\000o\000n\000.\000" - - "[\000*\000=\000*\000]\000T\000h\000i\000s\000 \000a\000p\000p\000l\000i\000c\000a\000t\000i\000o\000n\000 \000i\000s\000 \000e\000x\000p\000i\000r\000e\000d\000 \000!\000[\000*\000=\000*\000]\000" \ No newline at end of file + - "[\000*\000=\000*\000]\000T\000h\000i\000s\000 \000a\000p\000p\000l\000i\000c\000a\000t\000i\000o\000n\000 \000i\000s\000 \000e\000x\000p\000i\000r\000e\000d\000 \000!\000[\000*\000=\000*\000]\000" +modulerefs: + - "OctopusRPA.Common.dll" + - "OctopusRPA.Common64.dll" \ No newline at end of file diff --git a/lib/src/modules/dotnet/tests/testdata/4a8e3e00ce7fd88da587fbb187e07985a2f69fe1b94f3a83cfbba4e4104c2b26.out b/lib/src/modules/dotnet/tests/testdata/4a8e3e00ce7fd88da587fbb187e07985a2f69fe1b94f3a83cfbba4e4104c2b26.out index 93e079fd2..a2a060957 100644 --- a/lib/src/modules/dotnet/tests/testdata/4a8e3e00ce7fd88da587fbb187e07985a2f69fe1b94f3a83cfbba4e4104c2b26.out +++ b/lib/src/modules/dotnet/tests/testdata/4a8e3e00ce7fd88da587fbb187e07985a2f69fe1b94f3a83cfbba4e4104c2b26.out @@ -6,6 +6,7 @@ number_of_guids: 1 number_of_resources: 0 number_of_classes: 8 number_of_assembly_refs: 3 +number_of_modulerefs: 0 number_of_user_strings: 8 number_of_constants: 0 streams: diff --git a/lib/src/modules/dotnet/tests/testdata/605ebe5b5f4b94e1a73e0ad1162bd542e5cb948d1a4ea5a575a14d6b9d6ee849.out b/lib/src/modules/dotnet/tests/testdata/605ebe5b5f4b94e1a73e0ad1162bd542e5cb948d1a4ea5a575a14d6b9d6ee849.out index 4966c27b4..611359f4c 100644 --- a/lib/src/modules/dotnet/tests/testdata/605ebe5b5f4b94e1a73e0ad1162bd542e5cb948d1a4ea5a575a14d6b9d6ee849.out +++ b/lib/src/modules/dotnet/tests/testdata/605ebe5b5f4b94e1a73e0ad1162bd542e5cb948d1a4ea5a575a14d6b9d6ee849.out @@ -6,6 +6,7 @@ number_of_guids: 1 number_of_resources: 0 number_of_classes: 24 number_of_assembly_refs: 1 +number_of_modulerefs: 0 number_of_user_strings: 1 number_of_constants: 0 typelib: "63ca6b3c-208c-47ef-9294-fbc91c947d15" diff --git a/lib/src/modules/dotnet/tests/testdata/6d72a599724c4ff367b2c00b48030a62d286de5493c25c000a00f5fbc6e7b746.out b/lib/src/modules/dotnet/tests/testdata/6d72a599724c4ff367b2c00b48030a62d286de5493c25c000a00f5fbc6e7b746.out index 7ca0fa993..a0274b3ed 100644 --- a/lib/src/modules/dotnet/tests/testdata/6d72a599724c4ff367b2c00b48030a62d286de5493c25c000a00f5fbc6e7b746.out +++ b/lib/src/modules/dotnet/tests/testdata/6d72a599724c4ff367b2c00b48030a62d286de5493c25c000a00f5fbc6e7b746.out @@ -5,6 +5,7 @@ number_of_guids: 1 number_of_resources: 0 number_of_classes: 0 number_of_assembly_refs: 0 +number_of_modulerefs: 0 number_of_user_strings: 10 number_of_constants: 0 streams: diff --git a/lib/src/modules/dotnet/tests/testdata/86a1e48cfc843eabfe1b468ef9358c1068950f849c612ab808225b359db0bb8c.out b/lib/src/modules/dotnet/tests/testdata/86a1e48cfc843eabfe1b468ef9358c1068950f849c612ab808225b359db0bb8c.out index 2b32511f1..de24f4d98 100644 --- a/lib/src/modules/dotnet/tests/testdata/86a1e48cfc843eabfe1b468ef9358c1068950f849c612ab808225b359db0bb8c.out +++ b/lib/src/modules/dotnet/tests/testdata/86a1e48cfc843eabfe1b468ef9358c1068950f849c612ab808225b359db0bb8c.out @@ -6,6 +6,7 @@ number_of_guids: 1 number_of_resources: 0 number_of_classes: 12 number_of_assembly_refs: 1 +number_of_modulerefs: 0 number_of_user_strings: 0 number_of_constants: 40 streams: diff --git a/lib/src/modules/dotnet/tests/testdata/88d0d0692e675cd5fafb57db4f940e98d03e054ca2b88ef5a41f72b5787841b3.out b/lib/src/modules/dotnet/tests/testdata/88d0d0692e675cd5fafb57db4f940e98d03e054ca2b88ef5a41f72b5787841b3.out index 533db7db9..0541963e2 100644 --- a/lib/src/modules/dotnet/tests/testdata/88d0d0692e675cd5fafb57db4f940e98d03e054ca2b88ef5a41f72b5787841b3.out +++ b/lib/src/modules/dotnet/tests/testdata/88d0d0692e675cd5fafb57db4f940e98d03e054ca2b88ef5a41f72b5787841b3.out @@ -6,6 +6,7 @@ number_of_guids: 16 number_of_resources: 1 number_of_classes: 297 number_of_assembly_refs: 4 +number_of_modulerefs: 0 number_of_user_strings: 0 number_of_constants: 0 streams: diff --git a/lib/src/modules/dotnet/tests/testdata/984750efd1cb94e5ca7b366863af2092af954dad65df534bff603b9afcb49cd4.out b/lib/src/modules/dotnet/tests/testdata/984750efd1cb94e5ca7b366863af2092af954dad65df534bff603b9afcb49cd4.out index a02dddac5..6040bb1c7 100644 --- a/lib/src/modules/dotnet/tests/testdata/984750efd1cb94e5ca7b366863af2092af954dad65df534bff603b9afcb49cd4.out +++ b/lib/src/modules/dotnet/tests/testdata/984750efd1cb94e5ca7b366863af2092af954dad65df534bff603b9afcb49cd4.out @@ -6,6 +6,7 @@ number_of_guids: 1 number_of_resources: 1 number_of_classes: 31 number_of_assembly_refs: 2 +number_of_modulerefs: 2 number_of_user_strings: 45 number_of_constants: 0 streams: @@ -2085,4 +2086,7 @@ user_strings: - "w\000s\0002\000_\0003\0002\000.\000d\000l\000l\000" - "G\000e\000t\000A\000d\000d\000r\000I\000n\000f\000o\000E\000x\000C\000a\000n\000c\000e\000l\000" - "G\000e\000t\000A\000d\000d\000r\000I\000n\000f\000o\000E\000x\000C\000a\000n\000c\000e\000l\000 \000r\000e\000t\000u\000r\000n\000e\000d\000 \000e\000r\000r\000o\000r\000 \000{\0000\000}\000" - - "R\000e\000g\000i\000s\000t\000e\000r\000F\000o\000r\000C\000a\000n\000c\000e\000l\000l\000a\000t\000i\000o\000n\000" \ No newline at end of file + - "R\000e\000g\000i\000s\000t\000e\000r\000F\000o\000r\000C\000a\000n\000c\000e\000l\000l\000a\000t\000i\000o\000n\000" +modulerefs: + - "kernel32.dll" + - "ws2_32.dll" \ No newline at end of file diff --git a/lib/src/modules/protos/dotnet.proto b/lib/src/modules/protos/dotnet.proto index 6eb817ce2..0bdebb44c 100644 --- a/lib/src/modules/protos/dotnet.proto +++ b/lib/src/modules/protos/dotnet.proto @@ -14,7 +14,7 @@ message Dotnet { optional bool is_dotnet = 1; optional string module_name = 2; optional bytes version = 3; // TODO: should be string? - + optional uint64 number_of_streams = 4; optional uint64 number_of_guids = 5; optional uint64 number_of_resources = 6; @@ -32,11 +32,12 @@ message Dotnet { repeated string guids = 18; repeated bytes constants = 19; optional Assembly assembly = 20; - repeated AssemblyRef assembly_refs = 21; + repeated AssemblyRef assembly_refs = 21; repeated Resource resources = 22; repeated Class classes = 23; repeated uint32 field_offsets = 24; repeated bytes user_strings = 25; + repeated string modulerefs = 26; } message Assembly { @@ -90,7 +91,7 @@ message Method { optional string name = 1; optional string visibility = 2; required bool abstract = 3; - required bool static= 4; + required bool static = 4; required bool virtual = 5; required bool final = 6; optional string return_type = 7;