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

ntsend.h

Go to the documentation of this file.
00001 /**************************************************************************\ 00002 * Module Name: ntsend.h 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * client-side macros for kernel-mode 00007 * 00008 * 03-21-95 JimA Created. 00009 \**************************************************************************/ 00010 00011 /* 00012 * The BEGINCALLCONNECT macro ensures that the thread is set up correctly. 00013 */ 00014 #define BEGINCALLCONNECT() \ 00015 { \ 00016 ULONG_PTR retval; \ 00017 { \ 00018 if (NtCurrentTeb()->Win32ThreadInfo == NULL) { \ 00019 if (!NtUserGetThreadState(UserThreadConnect)) { \ 00020 MSGERROR(); \ 00021 } \ 00022 } 00023 00024 /* 00025 * Use this macro if you don't need to access shared memory. 00026 */ 00027 #define BEGINCALL() \ 00028 { \ 00029 ULONG_PTR retval; \ 00030 { 00031 00032 #define BEGINCALLVOID() \ 00033 { 00034 00035 #define ERRORTRAP(error) \ 00036 goto cleanup; \ 00037 } \ 00038 goto errorexit; \ 00039 errorexit: \ 00040 retval = (ULONG_PTR)error; \ 00041 cleanup: 00042 00043 #define ERRORTRAPVOID() \ 00044 goto errorexit; \ 00045 errorexit: 00046 00047 #define ENDCALL(type) \ 00048 return (type)retval; \ 00049 } 00050 00051 #define ENDCALLVOID() \ 00052 return; \ 00053 } 00054 00055 #define MSGERROR() goto errorexit 00056 #define MSGERRORCODE(code) { \ 00057 RIPERR0(code, RIP_WARNING, "Unspecified error"); \ 00058 goto errorexit; } 00059 00060 #define MSGNTERRORCODE(code) { \ 00061 RIPNTERR0(code, RIP_WARNING, "Unspecified error"); \ 00062 goto errorexit; } 00063 00064 #define MESSAGECALL(api) \ 00065 LRESULT api( \ 00066 HWND hwnd, \ 00067 UINT msg, \ 00068 WPARAM wParam, \ 00069 LPARAM lParam, \ 00070 ULONG_PTR xParam, \ 00071 DWORD xpfnProc, \ 00072 BOOL bAnsi) 00073 00074 /* 00075 * Copy optional string/Ordinal where if hiword is FF/FFFF then new WORD is a 00076 * resource oridinal ID 00077 * Sources is Unicode 00078 */ 00079 #define OrdinalLPSTR(src) (MAKELONG(0xFFFF,((*(DWORD UNALIGNED *)src) >> 8))) 00080 #define OrdinalLPSTRW(src) (MAKELONG(0xFFFF,((*(DWORD UNALIGNED *)src) >> 8))) 00081 #define OrdinalLPWSTR(src) (*(DWORD UNALIGNED *)src) 00082 #define OrdinalLPWSTRA(src) (*(DWORD UNALIGNED *)((PBYTE)src + 1)) 00083 00084 /* 00085 * Ansi->Unicode macros 00086 */ 00087 #define COPYLPSTRW(pinstr, psz) \ 00088 if (!RtlCaptureAnsiString((pinstr), (LPCSTR)(psz), TRUE)) \ 00089 MSGERROR(); 00090 00091 #define COPYLPSTRIDW(pinstr, psz) \ 00092 if (IS_PTR(psz)) { \ 00093 if (!RtlCaptureAnsiString((pinstr), (LPCSTR)(psz), TRUE)) \ 00094 MSGERROR(); \ 00095 } \ 00096 else { \ 00097 (pinstr)->fAllocated = FALSE; \ 00098 (pinstr)->pstr = &(pinstr)->strCapture; \ 00099 (pinstr)->strCapture.Length = \ 00100 (pinstr)->strCapture.MaximumLength = 0; \ 00101 (pinstr)->strCapture.Buffer = (LPWSTR)(psz); \ 00102 } 00103 00104 #define COPYLPSTRIDOPTW COPYLPSTRIDW 00105 #define COPYLPSTROPTW COPYLPSTRW 00106 00107 #define LARGECOPYLPSTRW(pinstr, psz) \ 00108 if(!RtlCaptureLargeAnsiString((pinstr), (LPCSTR)(psz), TRUE)) \ 00109 MSGERROR(); 00110 00111 #define LARGECOPYLPSTROPTW LARGECOPYLPSTRW 00112 00113 #define LARGECOPYLPSTRORDINALOPTW(pinstr, psz) \ 00114 (pinstr)->pstr = &(pinstr)->strCapture; \ 00115 (pinstr)->fAllocated = FALSE; \ 00116 if (psz) { \ 00117 if (*(LPBYTE)(psz) != 0xff) { \ 00118 if (!RtlCaptureLargeAnsiString((pinstr), (LPCSTR)(psz), TRUE)) \ 00119 MSGERROR(); \ 00120 } else { \ 00121 (pinstr)->strCapture.Length = \ 00122 (pinstr)->strCapture.MaximumLength = sizeof(DWORD); \ 00123 dwOrdinal = OrdinalLPSTRW(psz); \ 00124 (pinstr)->strCapture.Buffer = (LPWSTR)&dwOrdinal; \ 00125 } \ 00126 } else { \ 00127 (pinstr)->strCapture.Length = \ 00128 (pinstr)->strCapture.MaximumLength = 0; \ 00129 (pinstr)->strCapture.Buffer = NULL; \ 00130 } 00131 00132 #define FIRSTCOPYLPSTRW(pinstr, psz) \ 00133 if (!RtlCaptureAnsiString((pinstr), (LPCSTR)(psz), FALSE)) \ 00134 MSGERROR(); 00135 00136 #define FIRSTCOPYLPSTRIDW(pinstr, psz) \ 00137 if (IS_PTR(psz)) { \ 00138 if (!RtlCaptureAnsiString((pinstr), (LPCSTR)(psz), FALSE)) \ 00139 MSGERROR(); \ 00140 } else { \ 00141 (pinstr)->fAllocated = FALSE; \ 00142 (pinstr)->pstr = &(pinstr)->strCapture; \ 00143 (pinstr)->strCapture.Length = \ 00144 (pinstr)->strCapture.MaximumLength = 0; \ 00145 (pinstr)->strCapture.Buffer = (LPWSTR)(psz); \ 00146 } 00147 00148 #define FIRSTCOPYLPSTRIDOPTW FIRSTCOPYLPSTRIDW 00149 #define FIRSTCOPYLPSTROPTW FIRSTCOPYLPSTRW 00150 00151 #define FIRSTLARGECOPYLPSTRW(pinstr, psz) \ 00152 if (!RtlCaptureLargeAnsiString((pinstr), (LPCSTR)(psz), FALSE)) \ 00153 MSGERROR(); 00154 00155 #define FIRSTLARGECOPYLPSTROPTW FIRSTLARGECOPYLPSTRW 00156 00157 #define FIRSTLARGECOPYLPSTRORDINALOPTW(pinstr, psz) \ 00158 (pinstr)->pstr = &(pinstr)->strCapture; \ 00159 (pinstr)->fAllocated = FALSE; \ 00160 if (psz) { \ 00161 if (*(LPBYTE)(psz) != 0xff) { \ 00162 if (!RtlCaptureLargeAnsiString((pinstr), (LPCSTR)(psz), FALSE)) \ 00163 MSGERROR(); \ 00164 } else { \ 00165 (pinstr)->strCapture.Length = \ 00166 (pinstr)->strCapture.MaximumLength = sizeof(DWORD); \ 00167 dwOrdinal = OrdinalLPSTRW(psz); \ 00168 (pinstr)->strCapture.Buffer = (LPWSTR)&dwOrdinal; \ 00169 } \ 00170 } else { \ 00171 (pinstr)->strCapture.Length = \ 00172 (pinstr)->strCapture.MaximumLength = 0; \ 00173 (pinstr)->strCapture.Buffer = NULL; \ 00174 } 00175 00176 #define CLEANUPLPSTRW(instr) \ 00177 if (instr.fAllocated) \ 00178 RtlFreeHeap(pUserHeap, 0, instr.strCapture.Buffer); 00179 00180 /* 00181 * Unicode->Unicode macros 00182 */ 00183 #define COPYLPWSTR(pinstr, psz) \ 00184 (pinstr)->fAllocated = FALSE; \ 00185 (pinstr)->pstr = &(pinstr)->strCapture; \ 00186 RtlInitUnicodeString(&(pinstr)->strCapture, (psz)); 00187 00188 #define COPYLPWSTRID(pinstr, psz) \ 00189 (pinstr)->fAllocated = FALSE; \ 00190 (pinstr)->pstr = &(pinstr)->strCapture; \ 00191 if (IS_PTR(psz)) \ 00192 RtlInitUnicodeString(&(pinstr)->strCapture, (psz)); \ 00193 else { \ 00194 (pinstr)->strCapture.Length = \ 00195 (pinstr)->strCapture.MaximumLength = 0; \ 00196 (pinstr)->strCapture.Buffer = (LPWSTR)(psz); \ 00197 } 00198 00199 #define COPYLPWSTRIDOPT COPYLPWSTRID 00200 #define COPYLPWSTROPT COPYLPWSTR 00201 00202 #define LARGECOPYLPWSTR(pinstr, psz) \ 00203 (pinstr)->fAllocated = FALSE; \ 00204 (pinstr)->pstr = &(pinstr)->strCapture; \ 00205 RtlInitLargeUnicodeString(&(pinstr)->strCapture, (psz), (UINT)-1); 00206 00207 #define LARGECOPYLPWSTROPT LARGECOPYLPWSTR 00208 00209 #define LARGECOPYLPWSTRORDINALOPT(pinstr, psz) \ 00210 (pinstr)->fAllocated = FALSE; \ 00211 (pinstr)->pstr = &(pinstr)->strCapture; \ 00212 if (psz) { \ 00213 if (*(LPWORD)(psz) != 0xffff) \ 00214 RtlInitLargeUnicodeString(&(pinstr)->strCapture, (psz), (UINT)-1); \ 00215 else { \ 00216 (pinstr)->strCapture.Length = \ 00217 (pinstr)->strCapture.MaximumLength = sizeof(DWORD); \ 00218 dwOrdinal = OrdinalLPWSTR(psz); \ 00219 (pinstr)->strCapture.Buffer = (LPWSTR)&dwOrdinal; \ 00220 } \ 00221 } else { \ 00222 (pinstr)->strCapture.Length = \ 00223 (pinstr)->strCapture.MaximumLength = 0; \ 00224 (pinstr)->strCapture.Buffer = NULL; \ 00225 } 00226 00227 #define FIRSTCOPYLPWSTR COPYLPWSTR 00228 #define FIRSTCOPYLPWSTRID COPYLPWSTRID 00229 #define FIRSTCOPYLPWSTRIDOPT COPYLPWSTRIDOPT 00230 #define FIRSTCOPYLPWSTROPT COPYLPWSTROPT 00231 #define FIRSTLARGECOPYLPWSTR LARGECOPYLPWSTR 00232 #define FIRSTLARGECOPYLPWSTROPT LARGECOPYLPWSTROPT 00233 #define FIRSTLARGECOPYLPWSTRORDINALOPT LARGECOPYLPWSTRORDINALOPT 00234 00235 #define CLEANUPLPWSTR(instr) 00236 00237 /* 00238 * Type-neutral macros 00239 */ 00240 #ifdef UNICODE 00241 00242 #define COPYLPTSTR COPYLPWSTR 00243 #define COPYLPTSTRID COPYLPWSTRID 00244 #define COPYLPTSTRIDOPT COPYLPWSTRIDOPT 00245 #define COPYLPTSTROPT COPYLPWSTROPT 00246 #define FIRSTCOPYLPTSTR COPYLPWSTR 00247 #define FIRSTCOPYLPTSTRID COPYLPWSTRID 00248 #define FIRSTCOPYLPTSTRIDOPT COPYLPWSTRIDOPT 00249 #define LARGECOPYLPTSTR LARGECOPYLPWSTR 00250 #define LARGECOPYLPTSTROPT LARGECOPYLPWSTROPT 00251 #define FIRSTLARGECOPYLPTSTROPT LARGECOPYLPWSTROPT 00252 #define CLEANUPLPTSTR CLEANUPLPWSTR 00253 00254 #else 00255 00256 #define COPYLPTSTR COPYLPSTRW 00257 #define COPYLPTSTRID COPYLPSTRIDW 00258 #define COPYLPTSTRIDOPT COPYLPSTRIDOPTW 00259 #define COPYLPTSTROPT COPYLPSTROPTW 00260 #define FIRSTCOPYLPTSTR COPYLPSTRW 00261 #define FIRSTCOPYLPTSTRID COPYLPSTRIDW 00262 #define FIRSTCOPYLPTSTRIDOPT COPYLPSTRIDOPTW 00263 #define LARGECOPYLPTSTR LARGECOPYLPSTRW 00264 #define LARGECOPYLPTSTROPT LARGECOPYLPSTROPTW 00265 #define FIRSTLARGECOPYLPTSTROPT LARGECOPYLPSTROPTW 00266 #define CLEANUPLPTSTR CLEANUPLPSTRW 00267 00268 #endif

Generated on Sat May 15 19:41:01 2004 for test by doxygen 1.3.7