Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

icamsg.c File Reference

#include "precomp.h"
#include "dbt.h"
#include "ntdddisk.h"
#include "ntuser.h"
#include <winsta.h>
#include <wstmsg.h>

Go to the source code of this file.

Functions

VOID HardErrorRemove (PCTXHARDERRORINFO)
VOID RemoteMessageThread (PVOID)
VOID HardErrorInsert (PCSR_THREAD, PHARDERROR_MSG, PCTXHARDERRORINFO)
NTSTATUS ReplyMessageToTerminalServer (PCTXHARDERRORINFO)
NTSTATUS RemoteDoMessage (PWINSTATION_APIMSG pMsg)

Variables

BOOLEAN gbExitInProgress
CONST int aidReturn [] = { 0, 0, IDABORT, IDCANCEL, IDIGNORE, IDNO, IDOK, IDRETRY, IDYES }
PCTXHARDERRORINFO gpchiList = NULL
HANDLE ghMessageThread = NULL
DWORD gidMessageThread
OBJECT_ATTRIBUTES g_ObjA
HANDLE g_hDoMessageEvent = NULL


Function Documentation

VOID HardErrorInsert PCSR_THREAD  ,
PHARDERROR_MSG  ,
PCTXHARDERRORINFO 
 

Referenced by RemoteMessageThread().

VOID HardErrorRemove PCTXHARDERRORINFO   ) 
 

Referenced by HardErrorHandler().

NTSTATUS RemoteDoMessage PWINSTATION_APIMSG  pMsg  ) 
 

Definition at line 68 of file icamsg.c.

References tagCTXHARDERRORINFO::ClientId, CTXHARDERRORINFO, DBGHYD, tagCTXHARDERRORINFO::DoNotWait, EnterCrit, g_hDoMessageEvent, ghMessageThread, gidMessageThread, gpchiList, tagCTXHARDERRORINFO::hEvent, L, LeaveCrit, LPVOID, tagCTXHARDERRORINFO::MessageId, NT_SUCCESS, NtSetEvent(), NTSTATUS(), NULL, tagCTXHARDERRORINFO::pchiNext, tagCTXHARDERRORINFO::pMessage, tagCTXHARDERRORINFO::pResponse, tagCTXHARDERRORINFO::pTitle, RemoteMessageThread(), Status, tagCTXHARDERRORINFO::Style, and tagCTXHARDERRORINFO::Timeout.

Referenced by W32WinStationDoMessage().

00070 { 00071 WINSTATIONSENDMESSAGEMSG * pSMsg = &pMsg->u.SendMessage; 00072 PCTXHARDERRORINFO pchi; 00073 NTSTATUS Status; 00074 00075 EnterCrit(); // to synchronize heap calls 00076 00077 /* 00078 * Create list entry 00079 */ 00080 if ((pchi = (PCTXHARDERRORINFO)LocalAlloc(LPTR, sizeof(CTXHARDERRORINFO))) == NULL) { 00081 LeaveCrit(); 00082 return (STATUS_NO_MEMORY); 00083 } 00084 else if ((pchi->pTitle = LocalAlloc(LPTR, pSMsg->TitleLength + sizeof(TCHAR))) == NULL) { 00085 LocalFree(pchi); 00086 LeaveCrit(); 00087 return (STATUS_NO_MEMORY); 00088 } 00089 else if ((pchi->pMessage = LocalAlloc(LPTR, pSMsg->MessageLength + sizeof(TCHAR))) == NULL) { 00090 LocalFree(pchi->pTitle); 00091 LocalFree(pchi); 00092 LeaveCrit(); 00093 return (STATUS_NO_MEMORY); 00094 } 00095 00096 /* 00097 * Initialize 00098 */ 00099 pchi->ClientId = pMsg->h.ClientId; 00100 pchi->MessageId = pMsg->MessageId; 00101 pchi->Timeout = pSMsg->Timeout; 00102 pchi->pResponse = pSMsg->pResponse; 00103 pchi->hEvent = pSMsg->hEvent; 00104 pchi->DoNotWait = pSMsg->DoNotWait; 00105 pchi->Style = pSMsg->Style; 00106 00107 pchi->pTitle[pSMsg->TitleLength/sizeof(TCHAR)] = L'\0'; 00108 RtlMoveMemory(pchi->pTitle, pSMsg->pTitle, pSMsg->TitleLength); 00109 00110 pchi->pMessage[pSMsg->MessageLength/sizeof(TCHAR)] = L'\0'; 00111 RtlMoveMemory(pchi->pMessage, pSMsg->pMessage, pSMsg->MessageLength); 00112 00113 DBGHYD(("RemoteDoMessage: pchi->pTitle - %S\n", pchi->pTitle)); 00114 DBGHYD(("RemoteDoMessage: pchi->pMessage - %S\n", pchi->pMessage)); 00115 00116 /* 00117 * Link in at head 00118 */ 00119 pchi->pchiNext = gpchiList; 00120 gpchiList = pchi; 00121 00122 LeaveCrit(); 00123 00124 /* 00125 * Start message thread if not running, otherwise signal thread 00126 */ 00127 if (ghMessageThread == NULL) { 00128 DBGHYD(("RemoteDoMessage: starting RemoteMessageThread ...\n")); 00129 00130 if ((ghMessageThread = CreateThread(NULL, 4096, 00131 (LPTHREAD_START_ROUTINE)RemoteMessageThread, 00132 (LPVOID) NULL, 00133 0, &gidMessageThread)) == NULL) { 00134 00135 DBGHYD(("RemoteDoMessage: cannot start RemoteMessageThread, error %u\n", 00136 GetLastError())); 00137 } 00138 } else { 00139 if (g_hDoMessageEvent == NULL) { 00140 return STATUS_UNSUCCESSFUL; 00141 } 00142 Status = NtSetEvent(g_hDoMessageEvent, NULL); 00143 00144 if (!NT_SUCCESS(Status)) { 00145 DBGHYD(("RemoteDoMessage: Error NtSetEvent failed, Status=%x, rc=%u\n", 00146 Status, GetLastError())); 00147 return Status; 00148 } 00149 } 00150 00151 return STATUS_SUCCESS; 00152 }

VOID RemoteMessageThread PVOID   ) 
 

Definition at line 167 of file icamsg.c.

References tagCTXHARDERRORINFO::ClientId, DBGHYD, EnterCrit, FALSE, g_hDoMessageEvent, g_ObjA, gbExitInProgress, gpchiList, HardErrorInsert(), LeaveCrit, NT_SUCCESS, NtClose(), NtCreateEvent(), NtResetEvent(), NTSTATUS(), NtWaitForSingleObject(), NULL, tagCTXHARDERRORINFO::pchiNext, tagCTXHARDERRORINFO::pMessage, tagCTXHARDERRORINFO::pTitle, RtlInitUnicodeString(), Status, and tagCTXHARDERRORINFO::Style.

Referenced by RemoteDoMessage().

00169 { 00170 HARDERROR_MSG hemsg; 00171 PCTXHARDERRORINFO pchi, *ppchi; 00172 UNICODE_STRING Message, Title; 00173 NTSTATUS Status; 00174 00175 /* 00176 * Create sync event 00177 */ 00178 InitializeObjectAttributes(&g_ObjA, NULL, 0, NULL, NULL); 00179 Status = NtCreateEvent(&g_hDoMessageEvent, EVENT_ALL_ACCESS, &g_ObjA, 00180 NotificationEvent, FALSE); 00181 00182 if (!NT_SUCCESS(Status)) { 00183 DBGHYD(("RemoteMessageThread: Error NtCreateEvent failed, rc=%u\n", 00184 GetLastError())); 00185 return; 00186 } 00187 00188 while (!gbExitInProgress) { 00189 00190 EnterCrit(); // to synchronize heap calls 00191 00192 /* 00193 * Valid list 00194 */ 00195 if (gpchiList != NULL) { 00196 00197 /* 00198 * Find last entry 00199 */ 00200 for (ppchi = &gpchiList; 00201 (*ppchi != NULL) && ((*ppchi)->pchiNext != NULL); 00202 ppchi = &(*ppchi)->pchiNext) ; 00203 00204 /* 00205 * Found it 00206 */ 00207 if ((pchi = *ppchi) != NULL) { 00208 00209 /* 00210 * Unlink from the list. 00211 */ 00212 for (ppchi = &gpchiList; *ppchi != NULL && *ppchi != pchi; 00213 ppchi = &(*ppchi)->pchiNext) 00214 ; 00215 00216 if (*ppchi != NULL) { 00217 *ppchi = pchi->pchiNext; 00218 } 00219 00220 LeaveCrit(); 00221 00222 /* 00223 * Make strings unicode 00224 */ 00225 RtlInitUnicodeString(&Title, pchi->pTitle); 00226 RtlInitUnicodeString(&Message, pchi->pMessage); 00227 00228 /* 00229 * Initialize harderror message struct 00230 */ 00231 hemsg.h.ClientId = pchi->ClientId; 00232 hemsg.Status = STATUS_SERVICE_NOTIFICATION; 00233 hemsg.NumberOfParameters = 3; 00234 hemsg.UnicodeStringParameterMask = 3; 00235 hemsg.ValidResponseOptions = OptionOk; 00236 hemsg.Parameters[0] = (ULONG_PTR)&Message; 00237 hemsg.Parameters[1] = (ULONG_PTR)&Title; 00238 hemsg.Parameters[2] = (ULONG_PTR)pchi->Style; 00239 00240 /* 00241 * Place message in harderror queue 00242 */ 00243 HardErrorInsert(NULL, &hemsg, pchi); 00244 } else { 00245 LeaveCrit(); 00246 } 00247 } else { 00248 LeaveCrit(); 00249 } 00250 00251 if (gpchiList == NULL) { 00252 00253 UserAssert(g_hDoMessageEvent != NULL); 00254 00255 Status = NtWaitForSingleObject(g_hDoMessageEvent, FALSE, NULL); 00256 00257 UserAssert(NT_SUCCESS(Status)); 00258 00259 NtResetEvent(g_hDoMessageEvent, NULL); 00260 } 00261 } 00262 00263 NtClose(g_hDoMessageEvent); 00264 g_hDoMessageEvent = NULL; 00265 00266 return; 00267 00268 UNREFERENCED_PARAMETER(pVoid); 00269 }

NTSTATUS ReplyMessageToTerminalServer PCTXHARDERRORINFO   ) 
 

Definition at line 168 of file icadis.c.

References ConnectToTerminalServer(), DbgPrint, tagCTXHARDERRORINFO::hEvent, NT_SUCCESS, NtClose(), NtRequestWaitReplyPort(), NTSTATUS(), PortHandle, tagCTXHARDERRORINFO::pResponse, tagCTXHARDERRORINFO::Response, Status, and TRUE.

Referenced by HardErrorRemove().

00170 { 00171 WINSTATION_APIMSG Msg; 00172 NTSTATUS Status; 00173 HANDLE PortHandle; 00174 00175 /* 00176 * Connect to Session Mgr 00177 */ 00178 Status = ConnectToTerminalServer(0, &PortHandle); //BUGBUG -- add access 00179 if (!NT_SUCCESS(Status)) { 00180 return (Status); 00181 } 00182 00183 00184 00185 00186 00187 Msg.h.u1.s1.DataLength = sizeof(Msg) - sizeof(PORT_MESSAGE); 00188 Msg.h.u1.s1.TotalLength = sizeof(Msg); 00189 Msg.h.u2.s2.Type = 0; // Kernel will fill in message type 00190 Msg.h.u2.s2.DataInfoOffset = 0; 00191 Msg.WaitForReply = TRUE; 00192 Msg.ApiNumber = SMWinStationIcaReplyMessage; 00193 Msg.ReturnedStatus = 0; 00194 00195 Msg.u.ReplyMessage.Response = pchi->Response; 00196 Msg.u.ReplyMessage.pResponse = pchi->pResponse; 00197 Msg.u.ReplyMessage.hEvent = pchi->hEvent; 00198 00199 Status = NtRequestWaitReplyPort(PortHandle, (PPORT_MESSAGE)&Msg, (PPORT_MESSAGE)&Msg); 00200 00201 00202 00203 00204 00205 #if DBG 00206 if (!NT_SUCCESS(Status)) { 00207 DbgPrint("ReplyMessageToTerminalServer: rc=0x%x\n", Status); 00208 } 00209 #endif 00210 NtClose(PortHandle); 00211 00212 return (Status); 00213 }


Variable Documentation

CONST int aidReturn[] = { 0, 0, IDABORT, IDCANCEL, IDIGNORE, IDNO, IDOK, IDRETRY, IDYES }
 

Definition at line 48 of file icamsg.c.

HANDLE g_hDoMessageEvent = NULL
 

Definition at line 53 of file icamsg.c.

Referenced by RemoteDoMessage(), RemoteMessageThread(), and W32WinStationTerminate().

OBJECT_ATTRIBUTES g_ObjA
 

Definition at line 52 of file icamsg.c.

Referenced by RemoteMessageThread().

BOOLEAN gbExitInProgress
 

Definition at line 42 of file icamsg.c.

HANDLE ghMessageThread = NULL
 

Definition at line 50 of file icamsg.c.

Referenced by RemoteDoMessage().

DWORD gidMessageThread
 

Definition at line 51 of file icamsg.c.

Referenced by RemoteDoMessage().

PCTXHARDERRORINFO gpchiList = NULL
 

Definition at line 49 of file icamsg.c.

Referenced by RemoteDoMessage(), and RemoteMessageThread().


Generated on Sat May 15 19:44:07 2004 for test by doxygen 1.3.7