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

base.c File Reference

#include "precomp.h"
#include <ntddbeep.h>

Go to the source code of this file.

Functions

int RtlLoadStringOrError (UINT wID, LPWSTR lpBuffer, int cchBufferMax, WORD wLangId)
VOID UserSleep (DWORD dwMilliseconds)
BOOL UserBeep (DWORD dwFreq, DWORD dwDuration)
void RtlInitUnicodeStringOrId (PUNICODE_STRING pstrName, LPWSTR lpstrName)


Function Documentation

void RtlInitUnicodeStringOrId PUNICODE_STRING  pstrName,
LPWSTR  lpstrName
 

Definition at line 204 of file base.c.

References IS_PTR, and RtlInitUnicodeString().

Referenced by xxxCreateWindowEx(), xxxGetScrollMenu(), xxxLoadSysMenu(), xxxUpdateSystemCursorsFromRegistry(), and xxxUpdateSystemIconsFromRegistry().

00207 { 00208 if (IS_PTR(lpstrName)) { 00209 RtlInitUnicodeString(pstrName, lpstrName); 00210 } else { 00211 pstrName->Length = pstrName->MaximumLength = 0; 00212 pstrName->Buffer = lpstrName; 00213 } 00214 }

int RtlLoadStringOrError UINT  wID,
LPWSTR  lpBuffer,
int  cchBufferMax,
WORD  wLangId
 

Definition at line 30 of file base.c.

References hModuleWin, NT_SUCCESS, NTSTATUS(), RtlFindMessage(), and Status.

00035 { 00036 PMESSAGE_RESOURCE_ENTRY MessageEntry; 00037 int cch; 00038 NTSTATUS Status; 00039 00040 /* 00041 * Make sure the parms are valid. 00042 */ 00043 if (!lpBuffer || (cchBufferMax-- == 0)) 00044 return 0; 00045 00046 cch = 0; 00047 00048 Status = RtlFindMessage((PVOID)hModuleWin, (ULONG_PTR)RT_MESSAGETABLE, 00049 wLangId, wID, &MessageEntry); 00050 if (NT_SUCCESS(Status)) { 00051 00052 /* 00053 * Copy out the message. If the whole thing can be copied, 00054 * copy two fewer chars so the crlf in the message will be 00055 * stripped out. 00056 */ 00057 cch = wcslen((PWCHAR)MessageEntry->Text) - 2; 00058 if (cch > cchBufferMax) 00059 cch = cchBufferMax; 00060 00061 RtlCopyMemory(lpBuffer, (PWCHAR)MessageEntry->Text, cch * sizeof(WCHAR)); 00062 } 00063 00064 /* 00065 * Append a NULL. 00066 */ 00067 lpBuffer[cch] = 0; 00068 00069 return cch; 00070 }

BOOL UserBeep DWORD  dwFreq,
DWORD  dwDuration
 

Definition at line 102 of file base.c.

References _UserSoundSentryWorker(), BOOL, CheckCritOut, DWORD, EnterCrit, FALSE, gbRemoteSession, gpRemoteBeepDevice, KeDelayExecutionThread(), KernelMode, L, LeaveCrit, NT_SUCCESS, NTSTATUS(), NULL, ObjectAttributes, ObOpenObjectByPointer(), RtlInitUnicodeString(), Status, TRUE, UserMode, and ZwCreateFile().

Referenced by DownSiren(), HighBeep(), KeyClick(), LowBeep(), ProcessKeyboardInput(), QueueMouseEvent(), UpSiren(), and xxxOldMessageBeep().

00105 { 00106 OBJECT_ATTRIBUTES ObjectAttributes; 00107 UNICODE_STRING NameString; 00108 NTSTATUS Status; 00109 IO_STATUS_BLOCK IoStatus; 00110 BEEP_SET_PARAMETERS BeepParameters; 00111 HANDLE hBeepDevice; 00112 LARGE_INTEGER TimeOut; 00113 00114 CheckCritOut(); 00115 00116 if (gbRemoteSession) { 00117 if (gpRemoteBeepDevice == NULL) 00118 Status = STATUS_UNSUCCESSFUL; 00119 else 00120 Status = ObOpenObjectByPointer( 00121 gpRemoteBeepDevice, 00122 0, 00123 NULL, 00124 EVENT_ALL_ACCESS, 00125 NULL, 00126 KernelMode, 00127 &hBeepDevice); 00128 } else { 00129 00130 RtlInitUnicodeString(&NameString, DD_BEEP_DEVICE_NAME_U); 00131 00132 InitializeObjectAttributes(&ObjectAttributes, 00133 &NameString, 00134 0, 00135 NULL, 00136 NULL); 00137 00138 Status = ZwCreateFile(&hBeepDevice, 00139 FILE_READ_DATA | FILE_WRITE_DATA, 00140 &ObjectAttributes, 00141 &IoStatus, 00142 NULL, 00143 0, 00144 FILE_SHARE_READ | FILE_SHARE_WRITE, 00145 FILE_OPEN_IF, 00146 0, 00147 (PVOID) NULL, 00148 0L); 00149 } 00150 00151 if (!NT_SUCCESS(Status)) { 00152 return FALSE; 00153 } 00154 00155 /* 00156 * 0,0 is a special case used to turn off a beep. Otherwise 00157 * validate the dwFreq parameter to be in range. 00158 */ 00159 if ((dwFreq != 0 || dwDuration != 0) && 00160 (dwFreq < (ULONG)0x25 || dwFreq > (ULONG)0x7FFF)) { 00161 00162 Status = STATUS_INVALID_PARAMETER; 00163 } else { 00164 BeepParameters.Frequency = dwFreq; 00165 BeepParameters.Duration = dwDuration; 00166 00167 Status = ZwDeviceIoControlFile(hBeepDevice, 00168 NULL, 00169 NULL, 00170 NULL, 00171 &IoStatus, 00172 IOCTL_BEEP_SET, 00173 &BeepParameters, 00174 sizeof(BeepParameters), 00175 NULL, 00176 0); 00177 } 00178 00179 EnterCrit(); 00180 _UserSoundSentryWorker(); 00181 LeaveCrit(); 00182 00183 if (!NT_SUCCESS(Status)) { 00184 ZwClose(hBeepDevice); 00185 return FALSE; 00186 } 00187 00188 /* 00189 * Beep device is asynchronous, so sleep for duration 00190 * to allow this beep to complete. 00191 */ 00192 if (dwDuration != (DWORD)-1 && (dwFreq != 0 || dwDuration != 0)) { 00193 TimeOut.QuadPart = Int32x32To64( dwDuration, -10000); 00194 00195 do { 00196 Status = KeDelayExecutionThread(UserMode, FALSE, &TimeOut); 00197 } 00198 while (Status == STATUS_ALERTED); 00199 } 00200 ZwClose(hBeepDevice); 00201 return TRUE; 00202 }

VOID UserSleep DWORD  dwMilliseconds  ) 
 

Definition at line 83 of file base.c.

References FALSE, KeDelayExecutionThread(), UserMode, and VOID().

Referenced by DoBeep(), RawInputThread(), xxxAnimateCaption(), and xxxCreateDesktop().

00085 { 00086 LARGE_INTEGER TimeOut; 00087 00088 TimeOut.QuadPart = Int32x32To64( dwMilliseconds, -10000 ); 00089 KeDelayExecutionThread(UserMode, FALSE, &TimeOut); 00090 }


Generated on Sat May 15 19:42:57 2004 for test by doxygen 1.3.7