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);
PipeBufEnd > P; P++)
if (L'\0' == *P)
switch (*P)
{
case L'\0':
*P = L'\n';
break;
case L'\1':
*P = L' ';
break;
}
if (BytesTransferred < RecvSize)
PipeBuf[BytesTransferred / sizeof(WCHAR)] = L'\0';

View File

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