Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

424 lines
8.5 KiB

  1. /*++
  2. Copyright 1996 - 1997 Microsoft Corporation
  3. Module Name:
  4. ginastub.c
  5. Abstract:
  6. --*/
  7. #include <windows.h>
  8. #include <stdio.h>
  9. #include <winwlx.h>
  10. #include "testshim.h"
  11. //
  12. // Location of the real msgina.
  13. //
  14. #define REALGINA_PATH TEXT("MSGINA.DLL")
  15. //
  16. // winlogon function dispatch table
  17. //
  18. WLX_DISPATCH_VERSION_1_3 WinlogonTable;
  19. PWLX_DISPATCH_VERSION_1_3 pTable ;
  20. //
  21. // Functions pointers to the real msgina which we will call.
  22. //
  23. PGWLXNEGOTIATE GWlxNegotiate;
  24. PGWLXINITIALIZE GWlxInitialize;
  25. PGWLXDISPLAYSASNOTICE GWlxDisplaySASNotice;
  26. PGWLXLOGGEDOUTSAS GWlxLoggedOutSAS;
  27. PGWLXACTIVATEUSERSHELL GWlxActivateUserShell;
  28. PGWLXLOGGEDONSAS GWlxLoggedOnSAS;
  29. PGWLXDISPLAYLOCKEDNOTICE GWlxDisplayLockedNotice;
  30. PGWLXWKSTALOCKEDSAS GWlxWkstaLockedSAS;
  31. PGWLXISLOCKOK GWlxIsLockOk;
  32. PGWLXISLOGOFFOK GWlxIsLogoffOk;
  33. PGWLXLOGOFF GWlxLogoff;
  34. PGWLXSHUTDOWN GWlxShutdown;
  35. //
  36. // NEW for version 1.1
  37. //
  38. PGWLXSTARTAPPLICATION GWlxStartApplication;
  39. PGWLXSCREENSAVERNOTIFY GWlxScreenSaverNotify;
  40. //
  41. // Scum Level
  42. //
  43. ULONG ScumLevel = 0 ;
  44. #define SCUM_CLEAN 2
  45. #define SCUM_DIRTY 1
  46. #define SCUM_RANCID 0
  47. //
  48. // hook into the real GINA.
  49. //
  50. BOOL
  51. MyInitialize( void )
  52. {
  53. HINSTANCE hDll;
  54. //
  55. // Load MSGINA.DLL.
  56. //
  57. if( !(hDll = LoadLibrary( REALGINA_PATH )) ) {
  58. return FALSE;
  59. }
  60. ScumLevel = GetProfileInt( TEXT("Winlogon"),
  61. TEXT("ShimScum"),
  62. 0 );
  63. //
  64. // Get pointers to all of the WLX functions in the real MSGINA.
  65. //
  66. GWlxNegotiate = (PGWLXNEGOTIATE)GetProcAddress( hDll, "WlxNegotiate" );
  67. if( !GWlxNegotiate ) {
  68. return FALSE;
  69. }
  70. GWlxInitialize = (PGWLXINITIALIZE)GetProcAddress( hDll, "WlxInitialize" );
  71. if( !GWlxInitialize ) {
  72. return FALSE;
  73. }
  74. GWlxDisplaySASNotice =
  75. (PGWLXDISPLAYSASNOTICE)GetProcAddress( hDll, "WlxDisplaySASNotice" );
  76. if( !GWlxDisplaySASNotice ) {
  77. return FALSE;
  78. }
  79. GWlxLoggedOutSAS =
  80. (PGWLXLOGGEDOUTSAS)GetProcAddress( hDll, "WlxLoggedOutSAS" );
  81. if( !GWlxLoggedOutSAS ) {
  82. return FALSE;
  83. }
  84. GWlxActivateUserShell =
  85. (PGWLXACTIVATEUSERSHELL)GetProcAddress( hDll, "WlxActivateUserShell" );
  86. if( !GWlxActivateUserShell ) {
  87. return FALSE;
  88. }
  89. GWlxLoggedOnSAS =
  90. (PGWLXLOGGEDONSAS)GetProcAddress( hDll, "WlxLoggedOnSAS" );
  91. if( !GWlxLoggedOnSAS ) {
  92. return FALSE;
  93. }
  94. GWlxDisplayLockedNotice =
  95. (PGWLXDISPLAYLOCKEDNOTICE)GetProcAddress(
  96. hDll,
  97. "WlxDisplayLockedNotice" );
  98. if( !GWlxDisplayLockedNotice ) {
  99. return FALSE;
  100. }
  101. GWlxIsLockOk = (PGWLXISLOCKOK)GetProcAddress( hDll, "WlxIsLockOk" );
  102. if( !GWlxIsLockOk ) {
  103. return FALSE;
  104. }
  105. GWlxWkstaLockedSAS =
  106. (PGWLXWKSTALOCKEDSAS)GetProcAddress( hDll, "WlxWkstaLockedSAS" );
  107. if( !GWlxWkstaLockedSAS ) {
  108. return FALSE;
  109. }
  110. GWlxIsLogoffOk = (PGWLXISLOGOFFOK)GetProcAddress( hDll, "WlxIsLogoffOk" );
  111. if( !GWlxIsLogoffOk ) {
  112. return FALSE;
  113. }
  114. GWlxLogoff = (PGWLXLOGOFF)GetProcAddress( hDll, "WlxLogoff" );
  115. if( !GWlxLogoff ) {
  116. return FALSE;
  117. }
  118. GWlxShutdown = (PGWLXSHUTDOWN)GetProcAddress( hDll, "WlxShutdown" );
  119. if( !GWlxShutdown ) {
  120. return FALSE;
  121. }
  122. //
  123. // we don't check for failure here because these don't exist for
  124. // gina's implemented prior to Windows NT 4.0
  125. //
  126. GWlxStartApplication = (PGWLXSTARTAPPLICATION) GetProcAddress( hDll, "WlxStartApplication" );
  127. GWlxScreenSaverNotify = (PGWLXSCREENSAVERNOTIFY) GetProcAddress( hDll, "WlxScreenSaverNotify" );
  128. //
  129. // Everything loaded ok. Return success.
  130. //
  131. return TRUE;
  132. }
  133. BOOL
  134. WINAPI
  135. WlxNegotiate(
  136. DWORD dwWinlogonVersion,
  137. DWORD *pdwDllVersion)
  138. {
  139. BOOL NegRet ;
  140. if( !MyInitialize() )
  141. return FALSE;
  142. NegRet = GWlxNegotiate(
  143. ( (ScumLevel == SCUM_RANCID) ? dwWinlogonVersion :
  144. (ScumLevel == SCUM_DIRTY) ? WLX_VERSION_1_2 :
  145. dwWinlogonVersion ),
  146. pdwDllVersion );
  147. return NegRet ;
  148. }
  149. BOOL
  150. WINAPI
  151. WlxInitialize(
  152. LPWSTR lpWinsta,
  153. HANDLE hWlx,
  154. PVOID pvReserved,
  155. PVOID pWinlogonFunctions,
  156. PVOID *pWlxContext)
  157. {
  158. switch ( ScumLevel )
  159. {
  160. case SCUM_RANCID:
  161. case SCUM_DIRTY:
  162. CopyMemory( &WinlogonTable,
  163. pWinlogonFunctions,
  164. sizeof( WLX_DISPATCH_VERSION_1_2 ) );
  165. pTable = &WinlogonTable ;
  166. break;
  167. case SCUM_CLEAN:
  168. pTable = pWinlogonFunctions ;
  169. break;
  170. }
  171. return GWlxInitialize(
  172. lpWinsta,
  173. hWlx,
  174. pvReserved,
  175. pTable,
  176. pWlxContext
  177. );
  178. }
  179. VOID
  180. WINAPI
  181. WlxDisplaySASNotice(
  182. PVOID pWlxContext)
  183. {
  184. GWlxDisplaySASNotice( pWlxContext );
  185. }
  186. int
  187. WINAPI
  188. WlxLoggedOutSAS(
  189. PVOID pWlxContext,
  190. DWORD dwSasType,
  191. PLUID pAuthenticationId,
  192. PSID pLogonSid,
  193. PDWORD pdwOptions,
  194. PHANDLE phToken,
  195. PWLX_MPR_NOTIFY_INFO pMprNotifyInfo,
  196. PVOID *pProfile)
  197. {
  198. int iRet;
  199. iRet = GWlxLoggedOutSAS(
  200. pWlxContext,
  201. dwSasType,
  202. pAuthenticationId,
  203. pLogonSid,
  204. pdwOptions,
  205. phToken,
  206. pMprNotifyInfo,
  207. pProfile
  208. );
  209. if(iRet == WLX_SAS_ACTION_LOGON) {
  210. //
  211. // copy pMprNotifyInfo and pLogonSid for later use
  212. //
  213. // pMprNotifyInfo->pszUserName
  214. // pMprNotifyInfo->pszDomain
  215. // pMprNotifyInfo->pszPassword
  216. // pMprNotifyInfo->pszOldPassword
  217. }
  218. return iRet;
  219. }
  220. BOOL
  221. WINAPI
  222. WlxActivateUserShell(
  223. PVOID pWlxContext,
  224. PWSTR pszDesktopName,
  225. PWSTR pszMprLogonScript,
  226. PVOID pEnvironment)
  227. {
  228. return GWlxActivateUserShell(
  229. pWlxContext,
  230. pszDesktopName,
  231. pszMprLogonScript,
  232. pEnvironment
  233. );
  234. }
  235. int
  236. WINAPI
  237. WlxLoggedOnSAS(
  238. PVOID pWlxContext,
  239. DWORD dwSasType,
  240. PVOID pReserved)
  241. {
  242. return GWlxLoggedOnSAS( pWlxContext, dwSasType, pReserved );
  243. }
  244. VOID
  245. WINAPI
  246. WlxDisplayLockedNotice(
  247. PVOID pWlxContext )
  248. {
  249. GWlxDisplayLockedNotice( pWlxContext );
  250. }
  251. BOOL
  252. WINAPI
  253. WlxIsLockOk(
  254. PVOID pWlxContext)
  255. {
  256. return GWlxIsLockOk( pWlxContext );
  257. }
  258. int
  259. WINAPI
  260. WlxWkstaLockedSAS(
  261. PVOID pWlxContext,
  262. DWORD dwSasType )
  263. {
  264. return GWlxWkstaLockedSAS( pWlxContext, dwSasType );
  265. }
  266. BOOL
  267. WINAPI
  268. WlxIsLogoffOk(
  269. PVOID pWlxContext
  270. )
  271. {
  272. BOOL bSuccess;
  273. bSuccess = GWlxIsLogoffOk( pWlxContext );
  274. if(bSuccess) {
  275. //
  276. // if it's ok to logoff, finish with the stored credentials
  277. // and scrub the buffers
  278. //
  279. }
  280. return bSuccess;
  281. }
  282. VOID
  283. WINAPI
  284. WlxLogoff(
  285. PVOID pWlxContext
  286. )
  287. {
  288. GWlxLogoff( pWlxContext );
  289. }
  290. VOID
  291. WINAPI
  292. WlxShutdown(
  293. PVOID pWlxContext,
  294. DWORD ShutdownType
  295. )
  296. {
  297. GWlxShutdown( pWlxContext, ShutdownType );
  298. }
  299. //
  300. // NEW for version 1.1
  301. //
  302. BOOL
  303. WINAPI
  304. WlxScreenSaverNotify(
  305. PVOID pWlxContext,
  306. BOOL * pSecure
  307. )
  308. {
  309. if(GWlxScreenSaverNotify != NULL)
  310. return GWlxScreenSaverNotify( pWlxContext, pSecure );
  311. //
  312. // if not exported, return something intelligent
  313. //
  314. *pSecure = TRUE;
  315. return TRUE;
  316. }
  317. BOOL
  318. WINAPI
  319. WlxStartApplication(
  320. PVOID pWlxContext,
  321. PWSTR pszDesktopName,
  322. PVOID pEnvironment,
  323. PWSTR pszCmdLine
  324. )
  325. {
  326. if(GWlxStartApplication != NULL)
  327. return GWlxStartApplication(
  328. pWlxContext,
  329. pszDesktopName,
  330. pEnvironment,
  331. pszCmdLine
  332. );
  333. //
  334. // if not exported, return something intelligent
  335. //
  336. }