Skip to content

Commit 66b8593

Browse files
committed
test
1 parent 3df1b77 commit 66b8593

6 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/DOpusScriptingExtensions/DOpusScriptingExtensions.idl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,14 @@ interface IUCharDet : IDispatch
6666
};
6767

6868
[object, uuid(D64C510E-343B-46EE-97B8-C42D195705DE), dual, nonextensible, pointer_default(unique)]
69-
interface ILockingProcess : IDispatch
69+
interface IProcessInfo : IDispatch
7070
{
7171
[propget, id(1)] HRESULT Pid([out, retval] UINT* val);
7272
[propget, id(2)] HRESULT ExecutablePath([out, retval] BSTR* val);
73+
[propget, id(3)] HRESULT DomainName([out, retval] BSTR* val);
74+
[propget, id(4)] HRESULT UserName([out, retval] BSTR* val);
75+
[propget, id(5)] HRESULT LockedFiles([out, retval] BSTR* val);
76+
[propget, id(5)] HRESULT Modules([out, retval] BSTR* val);
7377
};
7478

7579
[object, uuid(6ACCC77B-D411-48C1-B8EF-6BBC5555D1E0), dual, nonextensible, pointer_default(unique)]

src/DOpusScriptingExtensions/pch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@
3636
#include <magic.h>
3737
#include <MediaInfo/MediaInfo.h>
3838
#include <uchardet/uchardet.h>
39+
#include <CsLibGuarded/cs_lock_guards.h>

src/ProcessHandlesService/LockedFilesProvider.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class LockedFilesProvider final : boost::noncopyable {
8282

8383
auto processFullName = GetProcessFullName(openedProcess.get());
8484
if (processFullName) {
85-
processInfo.set_executable_full_name(ToUtf8(*processFullName));
85+
processInfo.set_executable_path(ToUtf8(*processFullName));
8686
}
8787

8888
auto userAndDomainName = GetUserAndDomainName(openedProcess.get());
@@ -218,7 +218,19 @@ class LockedFilesProvider final : boost::noncopyable {
218218
continue;
219219
}
220220

221-
return std::wstring(buffer.get(), size);
221+
std::wstring_view path(buffer.get(), size);
222+
223+
// Some path contain '\\?\' at the beginning.
224+
// Remove it to convert a path like '\\?\C:\path' to 'C:\path'
225+
if (path.size() >= 7 &&
226+
path.starts_with(LR"(\\?\)") &&
227+
((path[4] >= L'A' && path[4] <= L'Z') || (path[4] >= L'a' && path[4] <= L'z')) &&
228+
path[5] == L':' &&
229+
path[6] == L'\\') {
230+
return std::wstring(path.substr(4));
231+
}
232+
233+
return std::wstring(path);
222234
}
223235
}
224236
};

src/Shared/ProcessHandlesService.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import "google/protobuf/empty.proto";
66

77
message ProcessInfo {
88
uint64 process_id = 1;
9-
optional string executable_full_name = 2;
9+
optional string executable_path = 2;
1010
optional string domain_name = 3;
1111
optional string user_name = 4;
1212
repeated string locked_files = 5;

src/UnitTest/LockedFilesProviderTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ TEST_CASE("ProcessHandlesServiceGrpcServer test") {
4444
REQUIRE(response.process_infos_size() > 0);
4545
REQUIRE(response.process_infos().contains(4)); // Contains "System" process
4646

47+
std::cout << response.DebugString() << std::endl;
48+
4749
AssertContainsProcess(response,
48-
[](const ProcessHandlesService::ProcessInfo& info) { return info.executable_full_name() == "C:\\Windows\\System32\\backgroundTaskHost.exe"; },
50+
[](const ProcessHandlesService::ProcessInfo& info) { return info.executable_path() == "C:\\Windows\\System32\\backgroundTaskHost.exe"; },
4951
"Should have process 'C:\\Windows\\System32\\backgroundTaskHost.exe'");
5052

5153
AssertContainsProcess(response,

vcpkg.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"grpc",
2828
"abseil",
2929
"spdlog",
30+
"libguarded",
3031
"doctest"
3132
]
3233
}

0 commit comments

Comments
 (0)