launcher, launchctl: refactoring

This commit is contained in:
Bill Zissimopoulos 2016-05-13 09:55:27 -07:00
parent 35d2b3f626
commit 2c51251cb7
2 changed files with 18 additions and 8 deletions

View File

@ -80,8 +80,15 @@ static int call_pipe_and_report(PWSTR PipeBuf, ULONG SendSize, ULONG RecvSize)
{ {
for (PWSTR P = PipeBuf, PipeBufEnd = P + BytesTransferred / sizeof(WCHAR); for (PWSTR P = PipeBuf, PipeBufEnd = P + BytesTransferred / sizeof(WCHAR);
PipeBufEnd > P; P++) PipeBufEnd > P; P++)
if (L'\0' == *P) switch (*P)
{
case L'\0':
*P = L'\n'; *P = L'\n';
break;
case L'\1':
*P = L' ';
break;
}
if (BytesTransferred < RecvSize) if (BytesTransferred < RecvSize)
PipeBuf[BytesTransferred / sizeof(WCHAR)] = L'\0'; PipeBuf[BytesTransferred / sizeof(WCHAR)] = L'\0';

View File

@ -378,9 +378,12 @@ NTSTATUS SvcInstanceGetInfo(HANDLE ClientToken,
PWSTR ClassName, PWSTR InstanceName, PWSTR Buffer, PULONG PSize) PWSTR ClassName, PWSTR InstanceName, PWSTR Buffer, PULONG PSize)
{ {
SVC_INSTANCE *SvcInstance; SVC_INSTANCE *SvcInstance;
PWSTR P = Buffer;
ULONG ClassNameSize, InstanceNameSize, CommandLineSize; ULONG ClassNameSize, InstanceNameSize, CommandLineSize;
NTSTATUS Result; NTSTATUS Result;
*PSize = 0;
EnterCriticalSection(&SvcInstanceLock); EnterCriticalSection(&SvcInstanceLock);
SvcInstance = SvcInstanceLookup(ClassName, InstanceName); SvcInstance = SvcInstanceLookup(ClassName, InstanceName);
@ -404,12 +407,11 @@ NTSTATUS SvcInstanceGetInfo(HANDLE ClientToken,
goto exit; goto exit;
} }
memcpy(Buffer, SvcInstance->ClassName, memcpy(P, SvcInstance->ClassName, ClassNameSize * sizeof(WCHAR)); P += ClassNameSize;
ClassNameSize * sizeof(WCHAR)); memcpy(P, SvcInstance->InstanceName, InstanceNameSize * sizeof(WCHAR)); P += InstanceNameSize;
memcpy(Buffer + ClassNameSize, SvcInstance->InstanceName, memcpy(P, SvcInstance->CommandLine, CommandLineSize * sizeof(WCHAR)); P += CommandLineSize;
InstanceNameSize * sizeof(WCHAR));
memcpy(Buffer + ClassNameSize + InstanceNameSize, SvcInstance->CommandLine, *PSize = (ULONG)(P - Buffer);
CommandLineSize * sizeof(WCHAR));
Result = STATUS_SUCCESS; Result = STATUS_SUCCESS;
@ -441,8 +443,9 @@ NTSTATUS SvcInstanceGetNameList(HANDLE ClientToken,
if (BufferEnd < P + ClassNameSize + InstanceNameSize) if (BufferEnd < P + ClassNameSize + InstanceNameSize)
break; break;
ClassNameSize--;
memcpy(P, SvcInstance->ClassName, ClassNameSize * sizeof(WCHAR)); P += ClassNameSize; memcpy(P, SvcInstance->ClassName, ClassNameSize * sizeof(WCHAR)); P += ClassNameSize;
*Buffer++ = L' '; *Buffer++ = L'\1';
memcpy(P, SvcInstance->InstanceName, InstanceNameSize * sizeof(WCHAR)); P += InstanceNameSize; memcpy(P, SvcInstance->InstanceName, InstanceNameSize * sizeof(WCHAR)); P += InstanceNameSize;
} }