mirror of
https://github.com/darlinghq/darlingserver.git
synced 2024-11-23 04:19:44 +00:00
GetExecutablePath: Write the path out to the correct process
We were writing out the path to the target process (i.e. the one we're looking up), but we should instead write it out to the process who made the call.
This commit is contained in:
parent
2d64a44c85
commit
814434f139
27
src/call.cpp
27
src/call.cpp
@ -950,17 +950,26 @@ void DarlingServer::Call::GetExecutablePath::processCall() {
|
||||
int code = 0;
|
||||
uint64_t fullLength;
|
||||
|
||||
if (auto maybeTargetProcess = processRegistry().lookupEntryByNSID(_body.pid)) {
|
||||
auto targetProcess = *maybeTargetProcess;
|
||||
auto path = targetProcess->executablePath();
|
||||
auto len = std::min(path.length() + 1, _body.buffer_size);
|
||||
if (!targetProcess->writeMemory((uintptr_t)_body.buffer, path.data(), len, &code)) {
|
||||
code = -code;
|
||||
if (auto callingThread = _thread.lock()) {
|
||||
if (auto callingProcess = callingThread->process()) {
|
||||
if (auto maybeTargetProcess = processRegistry().lookupEntryByNSID(_body.pid)) {
|
||||
auto targetProcess = *maybeTargetProcess;
|
||||
auto path = targetProcess->executablePath();
|
||||
auto len = std::min(path.length() + 1, _body.buffer_size);
|
||||
if (!callingProcess->writeMemory((uintptr_t)_body.buffer, path.c_str(), len, &code)) {
|
||||
code = -code;
|
||||
}
|
||||
fullLength = path.length();
|
||||
} else {
|
||||
// not negated because this is an acceptable case.
|
||||
// e.g. the target process may have died before the call was processed.
|
||||
code = ESRCH;
|
||||
}
|
||||
} else {
|
||||
code = -ESRCH;
|
||||
}
|
||||
fullLength = path.length();
|
||||
|
||||
} else {
|
||||
code = ESRCH;
|
||||
code = -ESRCH;
|
||||
}
|
||||
|
||||
_sendReply(code, fullLength);
|
||||
|
Loading…
Reference in New Issue
Block a user