2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Base API Server DLL
4 * FILE: subsystems/win/basesrv/init.c
5 * PURPOSE: Initialization
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
10 /* INCLUDES *******************************************************************/
22 /* GLOBALS ********************************************************************/
24 HANDLE BaseSrvDllInstance
= NULL
;
25 extern UNICODE_STRING BaseSrvKernel32DllPath
;
28 HANDLE BaseSrvHeap
= NULL
; // Our own heap.
29 HANDLE BaseSrvSharedHeap
= NULL
; // Shared heap with CSR. (CsrSrvSharedSectionHeap)
30 PBASE_STATIC_SERVER_DATA BaseStaticServerData
= NULL
; // Data that we can share amongst processes. Initialized inside BaseSrvSharedHeap.
33 ULONG ProtectionMode
= 0;
35 PINIFILE_MAPPING BaseSrvIniFileMapping
;
37 // Windows Server 2003 table from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3
38 PCSR_API_ROUTINE BaseServerApiDispatchTable
[BasepMaxApiNumber
- BASESRV_FIRST_API_NUMBER
] =
46 BaseSrvUpdateVDMEntry
,
47 BaseSrvGetNextVDMCommand
,
50 BaseSrvGetVDMExitCode
,
51 BaseSrvSetReenterCount
,
52 BaseSrvSetProcessShutdownParam
,
53 BaseSrvGetProcessShutdownParam
,
54 BaseSrvNlsSetUserInfo
,
55 BaseSrvNlsSetMultipleUserInfo
,
56 BaseSrvNlsCreateSection
,
59 BaseSrvBatNotification
,
60 BaseSrvRegisterWowExec
,
61 BaseSrvSoundSentryNotification
,
62 BaseSrvRefreshIniFileMapping
,
63 BaseSrvDefineDosDevice
,
64 BaseSrvSetTermsrvAppInstallMode
,
65 BaseSrvNlsUpdateCacheCount
,
66 BaseSrvSetTermsrvClientTimeZone
,
67 BaseSrvSxsCreateActivationContext
,
69 BaseSrvRegisterThread
,
70 BaseSrvNlsGetUserInfo
,
73 BOOLEAN BaseServerApiServerValidTable
[BasepMaxApiNumber
- BASESRV_FIRST_API_NUMBER
] =
75 TRUE
, // BaseSrvCreateProcess
76 TRUE
, // BaseSrvCreateThread
77 TRUE
, // BaseSrvGetTempFile
78 FALSE
, // BaseSrvExitProcess
79 FALSE
, // BaseSrvDebugProcess
80 TRUE
, // BaseSrvCheckVDM
81 TRUE
, // BaseSrvUpdateVDMEntry
82 TRUE
, // BaseSrvGetNextVDMCommand
83 TRUE
, // BaseSrvExitVDM
84 TRUE
, // BaseSrvIsFirstVDM
85 TRUE
, // BaseSrvGetVDMExitCode
86 TRUE
, // BaseSrvSetReenterCount
87 TRUE
, // BaseSrvSetProcessShutdownParam
88 TRUE
, // BaseSrvGetProcessShutdownParam
89 TRUE
, // BaseSrvNlsSetUserInfo
90 TRUE
, // BaseSrvNlsSetMultipleUserInfo
91 TRUE
, // BaseSrvNlsCreateSection
92 TRUE
, // BaseSrvSetVDMCurDirs
93 TRUE
, // BaseSrvGetVDMCurDirs
94 TRUE
, // BaseSrvBatNotification
95 TRUE
, // BaseSrvRegisterWowExec
96 TRUE
, // BaseSrvSoundSentryNotification
97 TRUE
, // BaseSrvRefreshIniFileMapping
98 TRUE
, // BaseSrvDefineDosDevice
99 TRUE
, // BaseSrvSetTermsrvAppInstallMode
100 TRUE
, // BaseSrvNlsUpdateCacheCount
101 TRUE
, // BaseSrvSetTermsrvClientTimeZone
102 TRUE
, // BaseSrvSxsCreateActivationContext
103 FALSE
, // BaseSrvDebugProcess
104 TRUE
, // BaseSrvRegisterThread
105 TRUE
, // BaseSrvNlsGetUserInfo
109 * On Windows Server 2003, CSR Servers contain
110 * the API Names Table only in Debug Builds.
113 PCHAR BaseServerApiNameTable
[BasepMaxApiNumber
- BASESRV_FIRST_API_NUMBER
] =
121 "BaseUpdateVDMEntry",
122 "BaseGetNextVDMCommand",
125 "BaseGetVDMExitCode",
126 "BaseSetReenterCount",
127 "BaseSetProcessShutdownParam",
128 "BaseGetProcessShutdownParam",
129 "BaseNlsSetUserInfo",
130 "BaseNlsSetMultipleUserInfo",
131 "BaseNlsCreateSection",
134 "BaseBatNotification",
135 "BaseRegisterWowExec",
136 "BaseSoundSentryNotification",
137 "BaseRefreshIniFileMapping",
138 "BaseDefineDosDevice",
139 "BaseSetTermsrvAppInstallMode",
140 "BaseNlsUpdateCacheCount",
141 "BaseSetTermsrvClientTimeZone",
142 "BaseSxsCreateActivationContext",
143 "BaseSrvDebugProcessStop",
144 "BaseRegisterThread",
145 "BaseNlsGetUserInfo",
149 /* FUNCTIONS ******************************************************************/
153 BaseSrvInitializeIniFileMappings(IN PBASE_STATIC_SERVER_DATA StaticServerData
)
155 /* Allocate the mapping blob */
156 BaseSrvIniFileMapping
= RtlAllocateHeap(BaseSrvSharedHeap
,
158 sizeof(*BaseSrvIniFileMapping
));
159 if (BaseSrvIniFileMapping
== NULL
)
161 DPRINT1("BASESRV: Unable to allocate memory in shared heap for IniFileMapping\n");
162 return STATUS_NO_MEMORY
;
166 StaticServerData
->IniFileMapping
= BaseSrvIniFileMapping
;
168 /* FIXME: Do the work to initialize the mappings */
169 return STATUS_SUCCESS
;
174 CreateBaseAcls(OUT PACL
* Dacl
,
175 OUT PACL
* RestrictedDacl
)
177 PSID SystemSid
, WorldSid
, RestrictedSid
;
178 SID_IDENTIFIER_AUTHORITY NtAuthority
= {SECURITY_NT_AUTHORITY
};
179 SID_IDENTIFIER_AUTHORITY WorldAuthority
= {SECURITY_WORLD_SID_AUTHORITY
};
181 UCHAR KeyValueBuffer
[0x40];
182 PKEY_VALUE_PARTIAL_INFORMATION KeyValuePartialInfo
;
183 UNICODE_STRING KeyName
;
187 OBJECT_ATTRIBUTES ObjectAttributes
;
189 /* Open the Session Manager Key */
190 RtlInitUnicodeString(&KeyName
, SM_REG_KEY
);
191 InitializeObjectAttributes(&ObjectAttributes
,
193 OBJ_CASE_INSENSITIVE
,
196 Status
= NtOpenKey(&hKey
, KEY_READ
, &ObjectAttributes
);
197 if (NT_SUCCESS(Status
))
199 /* Read the key value */
200 RtlInitUnicodeString(&KeyName
, L
"ProtectionMode");
201 Status
= NtQueryValueKey(hKey
,
203 KeyValuePartialInformation
,
205 sizeof(KeyValueBuffer
),
208 /* Make sure it's what we expect it to be */
209 KeyValuePartialInfo
= (PKEY_VALUE_PARTIAL_INFORMATION
)KeyValueBuffer
;
210 if ((NT_SUCCESS(Status
)) && (KeyValuePartialInfo
->Type
== REG_DWORD
) &&
211 (*(PULONG
)KeyValuePartialInfo
->Data
))
213 /* Save the Protection Mode */
214 ProtectionMode
= *(PULONG
)KeyValuePartialInfo
->Data
;
217 /* Close the handle */
221 /* Allocate the System SID */
222 Status
= RtlAllocateAndInitializeSid(&NtAuthority
,
223 1, SECURITY_LOCAL_SYSTEM_RID
,
226 ASSERT(NT_SUCCESS(Status
));
228 /* Allocate the World SID */
229 Status
= RtlAllocateAndInitializeSid(&WorldAuthority
,
230 1, SECURITY_WORLD_RID
,
233 ASSERT(NT_SUCCESS(Status
));
235 /* Allocate the restricted SID */
236 Status
= RtlAllocateAndInitializeSid(&NtAuthority
,
237 1, SECURITY_RESTRICTED_CODE_RID
,
240 ASSERT(NT_SUCCESS(Status
));
242 /* Allocate one ACL with 3 ACEs each for one SID */
243 AclLength
= sizeof(ACL
) + 3 * sizeof(ACCESS_ALLOWED_ACE
) +
244 RtlLengthSid(SystemSid
) +
245 RtlLengthSid(WorldSid
) +
246 RtlLengthSid(RestrictedSid
);
247 *Dacl
= RtlAllocateHeap(BaseSrvHeap
, 0, AclLength
);
248 ASSERT(*Dacl
!= NULL
);
250 /* Set the correct header fields */
251 Status
= RtlCreateAcl(*Dacl
, AclLength
, ACL_REVISION2
);
252 ASSERT(NT_SUCCESS(Status
));
254 /* Give the appropriate rights to each SID */
255 /* FIXME: Should check SessionId/ProtectionMode */
256 Status
= RtlAddAccessAllowedAce(*Dacl
, ACL_REVISION2
, DIRECTORY_QUERY
| DIRECTORY_TRAVERSE
| DIRECTORY_CREATE_OBJECT
| DIRECTORY_CREATE_SUBDIRECTORY
| READ_CONTROL
, WorldSid
);
257 ASSERT(NT_SUCCESS(Status
));
258 Status
= RtlAddAccessAllowedAce(*Dacl
, ACL_REVISION2
, DIRECTORY_ALL_ACCESS
, SystemSid
);
259 ASSERT(NT_SUCCESS(Status
));
260 Status
= RtlAddAccessAllowedAce(*Dacl
, ACL_REVISION2
, DIRECTORY_TRAVERSE
, RestrictedSid
);
261 ASSERT(NT_SUCCESS(Status
));
263 /* Now allocate the restricted DACL */
264 *RestrictedDacl
= RtlAllocateHeap(BaseSrvHeap
, 0, AclLength
);
265 ASSERT(*RestrictedDacl
!= NULL
);
268 Status
= RtlCreateAcl(*RestrictedDacl
, AclLength
, ACL_REVISION2
);
269 ASSERT(NT_SUCCESS(Status
));
271 /* And add the same ACEs as before */
272 /* FIXME: Not really fully correct */
273 Status
= RtlAddAccessAllowedAce(*RestrictedDacl
, ACL_REVISION2
, DIRECTORY_QUERY
| DIRECTORY_TRAVERSE
| DIRECTORY_CREATE_OBJECT
| DIRECTORY_CREATE_SUBDIRECTORY
| READ_CONTROL
, WorldSid
);
274 ASSERT(NT_SUCCESS(Status
));
275 Status
= RtlAddAccessAllowedAce(*RestrictedDacl
, ACL_REVISION2
, DIRECTORY_ALL_ACCESS
, SystemSid
);
276 ASSERT(NT_SUCCESS(Status
));
277 Status
= RtlAddAccessAllowedAce(*RestrictedDacl
, ACL_REVISION2
, DIRECTORY_TRAVERSE
, RestrictedSid
);
278 ASSERT(NT_SUCCESS(Status
));
280 /* The SIDs are captured, can free them now */
281 RtlFreeSid(RestrictedSid
);
282 RtlFreeSid(WorldSid
);
283 RtlFreeSid(SystemSid
);
289 BaseInitializeStaticServerData(IN PCSR_SERVER_DLL LoadedServerDll
)
293 WCHAR BnoBuffer
[100];
296 UNICODE_STRING SystemRootString
;
297 UNICODE_STRING UnexpandedSystemRootString
= RTL_CONSTANT_STRING(L
"%SystemRoot%");
298 UNICODE_STRING BaseSrvCSDString
;
299 UNICODE_STRING BaseSrvWindowsDirectory
;
300 UNICODE_STRING BaseSrvWindowsSystemDirectory
;
301 UNICODE_STRING BnoString
;
302 OBJECT_ATTRIBUTES ObjectAttributes
;
303 HANDLE BaseSrvNamedObjectDirectory
;
304 HANDLE BaseSrvRestrictedObjectDirectory
;
305 PACL BnoDacl
, BnoRestrictedDacl
;
306 PSECURITY_DESCRIPTOR BnoSd
;
308 UNICODE_STRING DirectoryName
, SymlinkName
;
310 RTL_QUERY_REGISTRY_TABLE BaseServerRegistryConfigurationTable
[2] =
314 RTL_QUERY_REGISTRY_DIRECT
,
323 /* Initialize the memory */
324 BaseSrvHeap
= RtlGetProcessHeap(); // Initialize our own heap.
325 BaseSrvSharedHeap
= LoadedServerDll
->SharedSection
; // Get the CSR shared heap.
327 /* Get the session ID */
328 SessionId
= NtCurrentPeb()->SessionId
;
330 /* Get the Windows directory */
331 RtlInitEmptyUnicodeString(&SystemRootString
, Buffer
, sizeof(Buffer
));
332 Status
= RtlExpandEnvironmentStrings_U(NULL
,
333 &UnexpandedSystemRootString
,
336 ASSERT(NT_SUCCESS(Status
));
338 /* Create the base directory */
339 Buffer
[SystemRootString
.Length
/ sizeof(WCHAR
)] = UNICODE_NULL
;
340 Success
= RtlCreateUnicodeString(&BaseSrvWindowsDirectory
,
341 SystemRootString
.Buffer
);
344 /* Create the system directory */
345 wcscat(SystemRootString
.Buffer
, L
"\\System32");
346 Success
= RtlCreateUnicodeString(&BaseSrvWindowsSystemDirectory
,
347 SystemRootString
.Buffer
);
350 /* Create the kernel32 path */
351 wcscat(SystemRootString
.Buffer
, L
"\\kernel32.dll");
352 Success
= RtlCreateUnicodeString(&BaseSrvKernel32DllPath
,
353 SystemRootString
.Buffer
);
358 swprintf(BnoBuffer
, L
"\\Sessions\\%ld\\BaseNamedObjects", SessionId
);
362 wcscpy(BnoBuffer
, L
"\\BaseNamedObjects");
364 RtlInitUnicodeString(&BnoString
, BnoBuffer
);
366 /* Allocate the server data */
367 BaseStaticServerData
= RtlAllocateHeap(BaseSrvSharedHeap
,
369 sizeof(BASE_STATIC_SERVER_DATA
));
370 ASSERT(BaseStaticServerData
!= NULL
);
372 /* Process timezone information */
373 BaseStaticServerData
->TermsrvClientTimeZoneId
= TIME_ZONE_ID_INVALID
;
374 BaseStaticServerData
->TermsrvClientTimeZoneChangeNum
= 0;
375 Status
= NtQuerySystemInformation(SystemTimeOfDayInformation
,
376 &BaseStaticServerData
->TimeOfDay
,
377 sizeof(BaseStaticServerData
->TimeOfDay
),
379 ASSERT(NT_SUCCESS(Status
));
381 /* Make a shared heap copy of the Windows directory */
382 BaseStaticServerData
->WindowsDirectory
= BaseSrvWindowsDirectory
;
383 HeapBuffer
= RtlAllocateHeap(BaseSrvSharedHeap
,
385 BaseSrvWindowsDirectory
.MaximumLength
);
387 RtlCopyMemory(HeapBuffer
,
388 BaseStaticServerData
->WindowsDirectory
.Buffer
,
389 BaseSrvWindowsDirectory
.MaximumLength
);
390 BaseStaticServerData
->WindowsDirectory
.Buffer
= HeapBuffer
;
392 /* Make a shared heap copy of the System directory */
393 BaseStaticServerData
->WindowsSystemDirectory
= BaseSrvWindowsSystemDirectory
;
394 HeapBuffer
= RtlAllocateHeap(BaseSrvSharedHeap
,
396 BaseSrvWindowsSystemDirectory
.MaximumLength
);
398 RtlCopyMemory(HeapBuffer
,
399 BaseStaticServerData
->WindowsSystemDirectory
.Buffer
,
400 BaseSrvWindowsSystemDirectory
.MaximumLength
);
401 BaseStaticServerData
->WindowsSystemDirectory
.Buffer
= HeapBuffer
;
403 /* This string is not used */
404 RtlInitEmptyUnicodeString(&BaseStaticServerData
->WindowsSys32x86Directory
,
408 /* Make a shared heap copy of the BNO directory */
409 BaseStaticServerData
->NamedObjectDirectory
= BnoString
;
410 BaseStaticServerData
->NamedObjectDirectory
.MaximumLength
= BnoString
.Length
+
411 sizeof(UNICODE_NULL
);
412 HeapBuffer
= RtlAllocateHeap(BaseSrvSharedHeap
,
414 BaseStaticServerData
->NamedObjectDirectory
.MaximumLength
);
416 RtlCopyMemory(HeapBuffer
,
417 BaseStaticServerData
->NamedObjectDirectory
.Buffer
,
418 BaseStaticServerData
->NamedObjectDirectory
.MaximumLength
);
419 BaseStaticServerData
->NamedObjectDirectory
.Buffer
= HeapBuffer
;
422 * Confirmed that in Windows, CSDNumber and RCNumber are actually Length
423 * and MaximumLength of the CSD String, since the same UNICODE_STRING is
424 * being queried twice, the first time as a ULONG!
426 * Somehow, in Windows this doesn't cause a buffer overflow, but it might
427 * in ReactOS, so this code is disabled until someone figures out WTF.
429 BaseStaticServerData
->CSDNumber
= 0;
430 BaseStaticServerData
->RCNumber
= 0;
432 /* Initialize the CSD string and query its value from the registry */
433 RtlInitEmptyUnicodeString(&BaseSrvCSDString
, Buffer
, sizeof(Buffer
));
434 Status
= RtlQueryRegistryValues(RTL_REGISTRY_WINDOWS_NT
,
436 BaseServerRegistryConfigurationTable
,
439 if (NT_SUCCESS(Status
))
441 /* Copy into the shared buffer */
442 wcsncpy(BaseStaticServerData
->CSDVersion
,
443 BaseSrvCSDString
.Buffer
,
444 BaseSrvCSDString
.Length
/ sizeof(WCHAR
));
448 /* Indicate nothing is there */
449 BaseSrvCSDString
.Length
= 0;
452 BaseStaticServerData
->CSDVersion
[BaseSrvCSDString
.Length
/ sizeof(WCHAR
)] = UNICODE_NULL
;
454 /* Cache the system information */
455 Status
= NtQuerySystemInformation(SystemBasicInformation
,
456 &BaseStaticServerData
->SysInfo
,
457 sizeof(BaseStaticServerData
->SysInfo
),
459 ASSERT(NT_SUCCESS(Status
));
461 /* Setup the ini file mappings */
462 Status
= BaseSrvInitializeIniFileMappings(BaseStaticServerData
);
463 ASSERT(NT_SUCCESS(Status
));
465 /* FIXME: Should query the registry for these */
466 BaseStaticServerData
->DefaultSeparateVDM
= FALSE
;
467 BaseStaticServerData
->IsWowTaskReady
= FALSE
;
469 /* Allocate a security descriptor and create it */
470 BnoSd
= RtlAllocateHeap(BaseSrvHeap
, 0, 1024);
472 Status
= RtlCreateSecurityDescriptor(BnoSd
, SECURITY_DESCRIPTOR_REVISION
);
473 ASSERT(NT_SUCCESS(Status
));
475 /* Create the BNO and \Restricted DACLs */
476 Status
= CreateBaseAcls(&BnoDacl
, &BnoRestrictedDacl
);
477 ASSERT(NT_SUCCESS(Status
));
479 /* Set the BNO DACL as active for now */
480 Status
= RtlSetDaclSecurityDescriptor(BnoSd
, TRUE
, BnoDacl
, FALSE
);
481 ASSERT(NT_SUCCESS(Status
));
483 /* Create the BNO directory */
484 InitializeObjectAttributes(&ObjectAttributes
,
486 OBJ_OPENIF
| OBJ_PERMANENT
| OBJ_CASE_INSENSITIVE
,
489 Status
= NtCreateDirectoryObject(&BaseSrvNamedObjectDirectory
,
490 DIRECTORY_ALL_ACCESS
,
492 ASSERT(NT_SUCCESS(Status
));
494 /* Check if we are session 0 */
497 /* Mark this as a session 0 directory */
498 Status
= NtSetInformationObject(BaseSrvNamedObjectDirectory
,
499 ObjectSessionInformation
,
502 ASSERT(NT_SUCCESS(Status
));
505 /* Check if LUID device maps are enabled */
506 Status
= NtQueryInformationProcess(NtCurrentProcess(),
507 ProcessLUIDDeviceMapsEnabled
,
511 ASSERT(NT_SUCCESS(Status
));
512 BaseStaticServerData
->LUIDDeviceMapsEnabled
= (BOOLEAN
)LuidEnabled
;
513 if (!BaseStaticServerData
->LUIDDeviceMapsEnabled
)
515 /* Make Global point back to BNO */
516 RtlInitUnicodeString(&DirectoryName
, L
"Global");
517 RtlInitUnicodeString(&SymlinkName
, L
"\\BaseNamedObjects");
518 InitializeObjectAttributes(&ObjectAttributes
,
520 OBJ_OPENIF
| OBJ_PERMANENT
| OBJ_CASE_INSENSITIVE
,
521 BaseSrvNamedObjectDirectory
,
523 Status
= NtCreateSymbolicLinkObject(&SymHandle
,
524 SYMBOLIC_LINK_ALL_ACCESS
,
527 if ((NT_SUCCESS(Status
)) && SessionId
== 0) NtClose(SymHandle
);
529 /* Make local point back to \Sessions\x\BNO */
530 RtlInitUnicodeString(&DirectoryName
, L
"Local");
531 ASSERT(SessionId
== 0);
532 InitializeObjectAttributes(&ObjectAttributes
,
534 OBJ_OPENIF
| OBJ_PERMANENT
| OBJ_CASE_INSENSITIVE
,
535 BaseSrvNamedObjectDirectory
,
537 Status
= NtCreateSymbolicLinkObject(&SymHandle
,
538 SYMBOLIC_LINK_ALL_ACCESS
,
541 if ((NT_SUCCESS(Status
)) && SessionId
== 0) NtClose(SymHandle
);
543 /* Make Session point back to BNOLINKS */
544 RtlInitUnicodeString(&DirectoryName
, L
"Session");
545 RtlInitUnicodeString(&SymlinkName
, L
"\\Sessions\\BNOLINKS");
546 InitializeObjectAttributes(&ObjectAttributes
,
548 OBJ_OPENIF
| OBJ_PERMANENT
| OBJ_CASE_INSENSITIVE
,
549 BaseSrvNamedObjectDirectory
,
551 Status
= NtCreateSymbolicLinkObject(&SymHandle
,
552 SYMBOLIC_LINK_ALL_ACCESS
,
555 if ((NT_SUCCESS(Status
)) && SessionId
== 0) NtClose(SymHandle
);
557 /* Create the BNO\Restricted directory and set the restricted DACL */
558 RtlInitUnicodeString(&DirectoryName
, L
"Restricted");
559 Status
= RtlSetDaclSecurityDescriptor(BnoSd
, TRUE
, BnoRestrictedDacl
, FALSE
);
560 ASSERT(NT_SUCCESS(Status
));
561 InitializeObjectAttributes(&ObjectAttributes
,
563 OBJ_OPENIF
| OBJ_PERMANENT
| OBJ_CASE_INSENSITIVE
,
564 BaseSrvNamedObjectDirectory
,
566 Status
= NtCreateDirectoryObject(&BaseSrvRestrictedObjectDirectory
,
567 DIRECTORY_ALL_ACCESS
,
569 ASSERT(NT_SUCCESS(Status
));
573 BaseSrvNLSInit(BaseStaticServerData
);
575 /* Finally, set the pointer */
576 LoadedServerDll
->SharedSection
= BaseStaticServerData
;
581 BaseClientConnectRoutine(IN PCSR_PROCESS CsrProcess
,
582 IN OUT PVOID ConnectionInfo
,
583 IN OUT PULONG ConnectionInfoLength
)
585 PBASESRV_API_CONNECTINFO ConnectInfo
= (PBASESRV_API_CONNECTINFO
)ConnectionInfo
;
587 if ( ConnectionInfo
== NULL
||
588 ConnectionInfoLength
== NULL
||
589 *ConnectionInfoLength
!= sizeof(*ConnectInfo
) )
591 DPRINT1("BASESRV: Connection failed - ConnectionInfo = 0x%p ; ConnectionInfoLength = 0x%p (%lu), expected %lu\n",
593 ConnectionInfoLength
,
594 ConnectionInfoLength
? *ConnectionInfoLength
: (ULONG
)-1,
595 sizeof(*ConnectInfo
));
597 return STATUS_INVALID_PARAMETER
;
600 /* Do the NLS connection */
601 return BaseSrvNlsConnect(CsrProcess
, ConnectionInfo
, ConnectionInfoLength
);
606 BaseClientDisconnectRoutine(IN PCSR_PROCESS CsrProcess
)
608 /* Cleanup VDM resources */
609 BaseSrvCleanupVDMResources(CsrProcess
);
612 CSR_SERVER_DLL_INIT(ServerDllInitialization
)
614 /* Setup the DLL Object */
615 LoadedServerDll
->ApiBase
= BASESRV_FIRST_API_NUMBER
;
616 LoadedServerDll
->HighestApiSupported
= BasepMaxApiNumber
;
617 LoadedServerDll
->DispatchTable
= BaseServerApiDispatchTable
;
618 LoadedServerDll
->ValidTable
= BaseServerApiServerValidTable
;
620 LoadedServerDll
->NameTable
= BaseServerApiNameTable
;
622 LoadedServerDll
->SizeOfProcessData
= 0;
623 LoadedServerDll
->ConnectCallback
= BaseClientConnectRoutine
;
624 LoadedServerDll
->DisconnectCallback
= BaseClientDisconnectRoutine
;
625 LoadedServerDll
->ShutdownProcessCallback
= NULL
;
627 BaseSrvDllInstance
= LoadedServerDll
->ServerHandle
;
629 BaseInitializeStaticServerData(LoadedServerDll
);
631 /* Initialize DOS devices management */
632 BaseInitDefineDosDevice();
634 /* Initialize VDM support */
638 return STATUS_SUCCESS
;
643 DllMain(IN HINSTANCE hInstanceDll
,
645 IN LPVOID lpReserved
)
647 UNREFERENCED_PARAMETER(hInstanceDll
);
648 UNREFERENCED_PARAMETER(dwReason
);
649 UNREFERENCED_PARAMETER(lpReserved
);
651 if (DLL_PROCESS_DETACH
== dwReason
)
653 BaseCleanupDefineDosDevice();