{
NTSTATUS Status;
ANSI_STRING DllName;
- UNICODE_STRING TempString;
+ UNICODE_STRING TempString, ErrorString;
+ ULONG_PTR Parameters[2];
HANDLE hServerDll = NULL;
ULONG Size;
PCSR_SERVER_DLL ServerDll;
STRING EntryPointString;
PCSR_SERVER_DLL_INIT_CALLBACK ServerDllInitProcedure;
+ ULONG Response;
/* Check if it's beyond the maximum we support */
- if (ServerId >= CSR_SERVER_DLL_MAX) return(STATUS_TOO_MANY_NAMES);
+ if (ServerId >= CSR_SERVER_DLL_MAX) return STATUS_TOO_MANY_NAMES;
/* Check if it's already been loaded */
- if (CsrLoadedServerDll[ServerId]) return(STATUS_INVALID_PARAMETER);
+ if (CsrLoadedServerDll[ServerId]) return STATUS_INVALID_PARAMETER;
/* Convert the name to Unicode */
+ ASSERT(DllString != NULL);
RtlInitAnsiString(&DllName, DllString);
Status = RtlAnsiStringToUnicodeString(&TempString, &DllName, TRUE);
+ if (!NT_SUCCESS(Status)) return Status;
/* If we are loading ourselves, don't actually load us */
if (ServerId != CSR_SRV_SERVER)
{
/* Load the DLL */
Status = LdrLoadDll(NULL, 0, &TempString, &hServerDll);
-
- /* Get rid of the string */
- RtlFreeUnicodeString(&TempString);
if (!NT_SUCCESS(Status))
{
- return Status;
+ /* Setup error parameters */
+ Parameters[0] = (ULONG_PTR)&TempString;
+ Parameters[1] = (ULONG_PTR)&ErrorString;
+ RtlInitUnicodeString(&ErrorString, L"Default Load Path");
+
+ /* Send a hard error */
+ NtRaiseHardError(Status,
+ 2,
+ 3,
+ Parameters,
+ OptionOk,
+ &Response);
}
+
+ /* Get rid of the string */
+ RtlFreeUnicodeString(&TempString);
+ if (!NT_SUCCESS(Status)) return Status;
}
/* Allocate a CSR DLL Object */
Size = sizeof(CSR_SERVER_DLL) + DllName.MaximumLength;
- if (!(ServerDll = RtlAllocateHeap(CsrHeap, HEAP_ZERO_MEMORY, Size)))
+ ServerDll = RtlAllocateHeap(CsrHeap, HEAP_ZERO_MEMORY, Size);
+ if (!ServerDll)
{
if (hServerDll) LdrUnloadDll(hServerDll);
return STATUS_NO_MEMORY;
if (hServerDll)
{
/* Initialize a string for the entrypoint, or use the default */
- RtlInitAnsiString(&EntryPointString,
+ RtlInitAnsiString(&EntryPointString,
!(EntryPoint) ? "ServerDllInitialization" :
EntryPoint);
NTSTATUS Status;
PCSR_CLIENT_CONNECT ClientConnect;
PCSR_SERVER_DLL ServerDll;
+ PCSR_PROCESS CurrentProcess = ((PCSR_THREAD)NtCurrentTeb()->CsrClientThread)->Process;
/* Load the Message, set default reply */
ClientConnect = (PCSR_CLIENT_CONNECT)&ApiMessage->CsrClientConnect;
if (ServerDll->ConnectCallback)
{
/* Call the callback */
- Status = (ServerDll->ConnectCallback)(((PCSR_THREAD)NtCurrentTeb()->CsrClientThread)->Process,
+ Status = (ServerDll->ConnectCallback)(CurrentProcess,
ClientConnect->ConnectionInfo,
&ClientConnect->ConnectionInfoSize);
}
ULONG ViewSize = 0;
PPEB Peb = NtCurrentPeb();
+ /* If there's no parameter, fail */
+ if (ParameterValue) return STATUS_INVALID_PARAMETER;
+
/* Find the first comma, and null terminate */
while (*SizeValue)
{
if (*SizeValue == ',')
{
- *SizeValue++ = '\0';
+ *SizeValue++ = ANSI_NULL;
break;
}
else
}
/* Make sure it's valid */
- if (!*SizeValue) return(STATUS_INVALID_PARAMETER);
+ if (!*SizeValue) return STATUS_INVALID_PARAMETER;
/* Convert it to an integer */
- Status = RtlCharToInteger(SizeValue,
- 0,
- &Size);
+ Status = RtlCharToInteger(SizeValue, 0, &Size);
if (!NT_SUCCESS(Status)) return Status;
/* Multiply by 1024 entries and round to page size */
ViewUnmap,
MEM_TOP_DOWN,
PAGE_EXECUTE_READWRITE);
- if(!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
{
/* Fail */
NtClose(CsrSrvSharedSection);
CsrSrvSharedSectionHeap = CsrSrvSharedSectionBase;
/* Create the heap */
- if (!(RtlCreateHeap(HEAP_ZERO_MEMORY,
+ if (!(RtlCreateHeap(HEAP_ZERO_MEMORY | HEAP_CLASS_7,
CsrSrvSharedSectionHeap,
CsrSrvSharedSectionSize,
PAGE_SIZE,
0)))
{
/* Failure, unmap section and return */
- NtUnmapViewOfSection(NtCurrentProcess(),
- CsrSrvSharedSectionBase);
+ NtUnmapViewOfSection(NtCurrentProcess(), CsrSrvSharedSectionBase);
NtClose(CsrSrvSharedSection);
return STATUS_NO_MEMORY;
}
0,
CSR_SERVER_DLL_MAX *
sizeof(PVOID));
+ if (!CsrSrvSharedStaticServerData) return STATUS_NO_MEMORY;
/* Write the values to the PEB */
Peb->ReadOnlySharedMemoryBase = CsrSrvSharedSectionBase;
(DebuggerInfo.KernelDebuggerEnabled))
{
/* Call the Unhandled Exception Filter */
- if ((Result = RtlUnhandledExceptionFilter(ExceptionInfo)) !=
+ if ((Result = RtlUnhandledExceptionFilter(ExceptionInfo)) !=
EXCEPTION_CONTINUE_EXECUTION)
{
/* We're going to raise an error. Get Shutdown Privilege first */
OptionShutdownSystem,
&Response);
}
-
+
/* Just terminate us */
NtTerminateProcess(NtCurrentProcess(),
ExceptionInfo->ExceptionRecord->ExceptionCode);