00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
#ifdef UNICODE
00016
#define IS_ANSI FALSE
00017
#else
00018 #define IS_ANSI TRUE
00019
#if IS_ANSI != CW_FLAGS_ANSI
00020
# error("IS_ANSI != CW_FLAGS_ANSI)
00021
#endif
00022
#endif
00023
#include "ntsend.h"
00024
#include "powrprof.h"
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 HWND WINAPI
CreateWindowEx(
00039 DWORD dwExStyle,
00040 LPCTSTR lpClassName,
00041 LPCTSTR lpWindowName,
00042 DWORD dwStyle,
00043
int X,
00044
int Y,
00045
int nWidth,
00046
int nHeight,
00047 HWND hWndParent,
00048 HMENU hMenu,
00049 HINSTANCE hModule,
00050 LPVOID lpParam)
00051 {
00052
00053
#if 0
00054
00055
00056
00057
00058
00059 dwExStyle &= ~(
WS_EX_MDICHILD |
WS_EX_ANSICREATOR);
00060
#endif
00061
00062
return _CreateWindowEx(dwExStyle, lpClassName, lpWindowName,
00063 dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu,
00064 hModule, lpParam,
IS_ANSI);
00065 }
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 LRESULT
TEXT_FN(fnHkINLPCWPSTRUCT)(
00078
PWND pwnd,
00079
UINT message,
00080 WPARAM wParam,
00081 LPARAM lParam,
00082 ULONG_PTR xParam)
00083 {
00084 CWPSTRUCT cwp;
00085
00086 cwp.hwnd =
HW(pwnd);
00087 cwp.message = message;
00088 cwp.wParam = wParam;
00089 cwp.lParam = lParam;
00090
00091
return TEXT_FN(
DispatchHook)(MAKELONG(HC_ACTION, WH_CALLWNDPROC),
00092 (
GetClientInfo()->CI_flags &
CI_INTERTHREAD_HOOK) != 0,
00093 (LPARAM)&cwp, (HOOKPROC)xParam);
00094 }
00095
00096 LRESULT
TEXT_FN(fnHkINLPCWPRETSTRUCT)(
00097
PWND pwnd,
00098
UINT message,
00099 WPARAM wParam,
00100 LPARAM lParam,
00101 ULONG_PTR xParam)
00102 {
00103 CWPRETSTRUCT cwp;
00104
PCLIENTINFO pci =
GetClientInfo();
00105
00106 cwp.hwnd =
HW(pwnd);
00107 cwp.message = message;
00108 cwp.wParam = wParam;
00109 cwp.lParam = lParam;
00110 cwp.lResult = KERNEL_LRESULT_TO_LRESULT(pci->
dwHookData);
00111
00112
return TEXT_FN(
DispatchHook)(MAKELONG(HC_ACTION, WH_CALLWNDPROCRET),
00113 (
GetClientInfo()->CI_flags &
CI_INTERTHREAD_HOOK) != 0,
00114 (LPARAM)&cwp, (HOOKPROC)xParam);
00115 }
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 LRESULT
TEXT_FN(DispatchHook)(
00129
int dw,
00130 WPARAM wParam,
00131 LPARAM lParam,
00132 HOOKPROC pfn)
00133 {
00134
int dwHookSave;
00135 LRESULT nRet;
00136
PCLIENTINFO pci;
00137
#ifdef WX86
00138
HOOKPROC pfnHook;
00139
#endif
00140
#if IS_ANSI
00141
WPARAM wParamSave;
00142
#endif
00143
00144
00145
00146
static EVENTMSG CachedEvent = {0,0,0,(
DWORD)0,(HWND)0};
00147
00148
00149
00150
00151
00152 pci =
GetClientInfo();
00153 dwHookSave = pci->
dwHookCurrent;
00154 pci->
dwHookCurrent = (dw & 0xFFFF0000) |
IS_ANSI;
00155
00156
#ifdef WX86
00157
00158
00159
00160
00161
00162 pfnHook = (PVOID)((ULONG_PTR)pfn & ~0x80000000);
00163
if (pfn != pfnHook) {
00164
if (pfnWx86HookCallBack) {
00165 pfn = pfnWx86HookCallBack(HIWORD(dw),
00166 pfnHook
00167 );
00168 }
00169 }
00170
00171
#endif
00172
00173
#if IS_ANSI // TEXT_FN(DispatchHook)()
00174
if (
IS_DBCS_ENABLED()) {
00175 PMSG pMsg;
00176 PEVENTMSG pEMsg;
00177
switch (HIWORD(dw)) {
00178
case WH_JOURNALPLAYBACK:
00179
switch (LOWORD(dw)) {
00180
case HC_SKIP:
00181 CachedEvent.message = 0;
00182
break;
00183
case HC_GETNEXT:
00184
case HC_NOREMOVE:
00185 pEMsg = (PEVENTMSG)lParam;
00186
if (CachedEvent.message != 0 && pEMsg !=
NULL) {
00187 RtlCopyMemory((PEVENTMSG)lParam,&CachedEvent,
sizeof(EVENTMSG));
00188
return 0;
00189 }
00190
break;
00191 }
00192
break;
00193
case WH_MSGFILTER:
00194
case WH_SYSMSGFILTER:
00195
case WH_GETMESSAGE:
00196 pMsg = (PMSG)lParam;
00197
if (pMsg) {
00198
00199
00200
00201 wParamSave = pMsg->wParam;
00202
switch (pMsg->message) {
00203
case WM_CHAR:
00204
case EM_SETPASSWORDCHAR:
00205
00206
00207
00208
00209
00210
00211
00212
00213
if (pMsg->wParam &
WMCR_IR_DBCSCHAR) {
00214
00215
00216
00217
00218 pMsg->wParam &= 0x0000FFFF;
00219 }
else {
00220
if (
IS_DBCS_MESSAGE(LOWORD(pMsg->wParam))) {
00221 PKERNEL_MSG pDbcsMsg =
GetCallBackDbcsInfo();
00222
00223
00224
00225
00226 COPY_MSG_TO_KERNELMSG(pDbcsMsg,pMsg);
00227
00228
00229
00230
00231 pDbcsMsg->wParam = (WPARAM)((pMsg->wParam & 0x0000FF00) >> 8);
00232
00233
00234
00235 pMsg->wParam = (WPARAM)(pMsg->wParam & 0x000000FF);
00236 }
else {
00237
00238
00239
00240 pMsg->wParam &= 0x000000FF;
00241 }
00242 }
00243 }
00244 }
00245 }
00246 GetNextHookData:
00247 ;
00248 }
00249
#endif // IS_ANSI
00250
00251
00252
00253
00254 nRet = pfn(LOWORD(dw), wParam, lParam);
00255
00256
#if IS_ANSI // TEXT_FN(DispatchHook)()
00257
if (
IS_DBCS_ENABLED()) {
00258 PMSG pMsg;
00259 PEVENTMSG pEMsg;
00260
switch (HIWORD(dw)) {
00261
case WH_JOURNALPLAYBACK:
00262
switch (LOWORD(dw)) {
00263
case HC_GETNEXT:
00264
case HC_NOREMOVE:
00265 pEMsg = (PEVENTMSG)lParam;
00266
if ((nRet == 0) && pEMsg) {
00267 WPARAM dwAnsi = LOWORD(pEMsg->paramL);
00268
switch(pEMsg->message) {
00269
case WM_CHAR:
00270
case EM_SETPASSWORDCHAR:
00271
00272
00273
00274
if (
IS_DBCS_MESSAGE((dwAnsi))) {
00275
00276
00277
00278 }
else {
00279
PBYTE pchDbcsCF =
GetDispatchDbcsInfo();
00280
00281
00282
00283
00284
if (*pchDbcsCF) {
00285 WORD DbcsLeadChar = (WORD)(*pchDbcsCF);
00286
00287
00288
00289
00290 dwAnsi |= (DbcsLeadChar << 8);
00291
00292
00293
00294 *pchDbcsCF = 0;
00295 }
else if (IsDBCSLeadByteEx(
THREAD_CODEPAGE(),
LOBYTE(dwAnsi))) {
00296
00297
00298
00299
00300 *pchDbcsCF =
LOBYTE(dwAnsi);
00301
00302
00303
00304 pfn(HC_SKIP,0,0);
00305
goto GetNextHookData;
00306 }
00307 }
00308
00309
00310
00311
RtlMBMessageWParamCharToWCS(pEMsg->message, &dwAnsi);
00312
00313
00314
00315 pEMsg->paramL = (
UINT)dwAnsi;
00316
00317
00318
00319 RtlCopyMemory(&CachedEvent,pEMsg,
sizeof(EVENTMSG));
00320 }
00321 }
00322 }
00323
break;
00324
case WH_MSGFILTER:
00325
case WH_SYSMSGFILTER:
00326
case WH_GETMESSAGE:
00327 pMsg = (PMSG)lParam;
00328
if (pMsg) {
00329
switch (pMsg->message) {
00330
case WM_CHAR:
00331
case EM_SETPASSWORDCHAR:
00332
if (
GetCallBackDbcsInfo()->wParam) {
00333 PKERNEL_MSG pmsgDbcs =
GetCallBackDbcsInfo();
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348 COPY_KERNELMSG_TO_MSG(pMsg,pmsgDbcs);
00349
00350
00351
00352 pmsgDbcs->wParam = 0;
00353
00354
00355
00356 nRet = pfn(LOWORD(dw), wParam, lParam);
00357 }
00358
00359
00360
00361
00362
00363
00364
00365
00366 pMsg->wParam = wParamSave;
00367 }
00368 }
00369 }
00370 }
00371
#endif // IS_ANSI
00372
00373
00374
00375
00376 pci->
dwHookCurrent = dwHookSave;
00377
return nRet;
00378 }
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388 LONG_PTR
APIENTRY GetWindowLongPtr(HWND hwnd,
int nIndex)
00389 {
00390
PWND pwnd;
00391
00392 pwnd =
ValidateHwnd(hwnd);
00393
00394
if (pwnd ==
NULL)
00395
return 0;
00396
00397
try {
00398
return _GetWindowLongPtr(pwnd, nIndex,
IS_ANSI);
00399 } except (W32ExceptionHandler(
FALSE, RIP_WARNING)) {
00400 RIPERR1(ERROR_INVALID_WINDOW_HANDLE,
00401 RIP_WARNING,
00402
"Window %x no longer valid",
00403 hwnd);
00404
return 0;
00405 }
00406 }
00407
00408 LONG_PTR
APIENTRY SetWindowLongPtr(HWND hWnd,
int nIndex, LONG_PTR dwNewLong)
00409 {
00410
return _SetWindowLongPtr(
hWnd, nIndex, dwNewLong,
IS_ANSI);
00411 }
00412
00413
#ifdef _WIN64
00414
LONG
APIENTRY GetWindowLong(HWND hwnd,
int nIndex)
00415 {
00416
PWND pwnd;
00417
00418 pwnd =
ValidateHwnd(hwnd);
00419
00420
if (pwnd ==
NULL)
00421
return 0;
00422
00423
try {
00424
return _GetWindowLong(pwnd, nIndex, IS_ANSI);
00425 } except (W32ExceptionHandler(FALSE, RIP_WARNING)) {
00426 RIPERR1(ERROR_INVALID_WINDOW_HANDLE,
00427 RIP_WARNING,
00428
"Window %x no longer valid",
00429 hwnd);
00430
return 0;
00431 }
00432 }
00433
00434 LONG
APIENTRY SetWindowLong(HWND hWnd,
int nIndex, LONG dwNewLong)
00435 {
00436
return _SetWindowLong(hWnd, nIndex, dwNewLong, IS_ANSI);
00437 }
00438
#endif
00439
00440 ULONG_PTR
APIENTRY GetClassLongPtr(HWND hWnd,
int nIndex)
00441 {
00442
PWND pwnd;
00443
00444 pwnd =
ValidateHwnd(
hWnd);
00445
00446
if (pwnd ==
NULL)
00447
return 0;
00448
00449
try {
00450
return _GetClassLongPtr(pwnd, nIndex,
IS_ANSI);
00451 } except (W32ExceptionHandler(
FALSE, RIP_WARNING)) {
00452 RIPERR1(ERROR_INVALID_WINDOW_HANDLE,
00453 RIP_WARNING,
00454
"Window %x no longer valid",
00455
hWnd);
00456
return 0;
00457 }
00458 }
00459
00460
#ifdef _WIN64
00461
DWORD APIENTRY GetClassLong(HWND hWnd,
int nIndex)
00462 {
00463
PWND pwnd;
00464
00465 pwnd =
ValidateHwnd(hWnd);
00466
00467
if (pwnd ==
NULL)
00468
return 0;
00469
00470
try {
00471
return _GetClassLong(pwnd, nIndex, IS_ANSI);
00472 } except (W32ExceptionHandler(FALSE, RIP_WARNING)) {
00473 RIPERR1(ERROR_INVALID_WINDOW_HANDLE,
00474 RIP_WARNING,
00475
"Window %x no longer valid",
00476 hWnd);
00477
return 0;
00478 }
00479 }
00480
#endif
00481
00482
00483 BOOL APIENTRY PeekMessage(
00484 LPMSG lpMsg,
00485 HWND hWnd,
00486 UINT wMsgFilterMin,
00487 UINT wMsgFilterMax,
00488 UINT wRemoveMsg)
00489 {
00490
PCLIENTTHREADINFO pcti;
00491
PCLIENTINFO pci;
00492
UINT fsWakeMaskFilter;
00493
UINT fsWakeMask;
00494
UINT cSpinLimit;
00495
00496 pci =
GetClientInfo();
00497
00498
if (
hWnd !=
NULL) {
00499
goto lbCallServer;
00500 }
00501
00502
#if IS_ANSI
00503
00504
00505
00506
00507 UserAssert(
IS_DBCS_ENABLED() ||
GetCallBackDbcsInfo()->wParam == 0);
00508
if (
GetCallBackDbcsInfo()->wParam) {
00509
00510
00511
00512
if ((!wMsgFilterMin && !wMsgFilterMax) ||
00513 (wMsgFilterMin <= WM_CHAR && wMsgFilterMax >=WM_CHAR))
00514 {
00515
goto lbCallServer;
00516 }
00517 }
00518
#endif
00519
00520
if ( (pci->
dwTIFlags &
TIF_16BIT)
00521 && !(wRemoveMsg & PM_NOYIELD)
00522 && ((
gpsi->nEvents != 0) || (pci->
dwTIFlags & (
TIF_FIRSTIDLE |
TIF_DELAYEDEVENT)))) {
00523
00524
goto lbCallServer;
00525 }
00526
00527
00528
00529
00530
if ((pcti = pci->
pClientThreadInfo) ==
NULL) {
00531
goto lbCallServer;
00532 }
00533
00534 fsWakeMaskFilter = HIWORD(wRemoveMsg);
00535
#if DBG
00536
00537
00538
00539
00540
if (fsWakeMaskFilter & ~QS_VALID) {
00541 RIPMSG1(RIP_WARNING,
"PeekMessage: Invalid QS_ bits:%#lx", fsWakeMaskFilter);
00542 }
00543
#endif
00544
00545
00546
00547
if (wMsgFilterMax == 0 && fsWakeMaskFilter == 0) {
00548 fsWakeMask = (QS_ALLINPUT | QS_EVENT | QS_ALLPOSTMESSAGE);
00549 }
else {
00550 fsWakeMask =
CalcWakeMask(wMsgFilterMin, wMsgFilterMax, fsWakeMaskFilter);
00551 }
00552
if ((pcti->
fsChangeBits | pcti->
fsWakeBits) & fsWakeMask) {
00553
goto lbCallServer;
00554 }
00555
00556
00557
00558
00559
00560
00561
if (pcti->
CTIF_flags &
CTIF_SYSQUEUELOCKED) {
00562
goto lbCallServer;
00563 }
00564
00565
00566
00567
00568
00569
00570
00571
00572 pci->
cSpins++;
00573
00574
if ((pci->
cSpins >=
CSPINBACKGROUND) && !(pci->
dwTIFlags &
TIF_SPINNING)) {
00575
goto lbCallServer;
00576 }
00577
00578
00579
00580
00581
00582
00583
00584
if (pci->
dwTIFlags &
TIF_WAITFORINPUTIDLE){
00585
goto lbCallServer;
00586 }
00587
00588
00589
00590
00591
00592
if ((
NtGetTickCount() - pcti->
timeLastRead) > 1000) {
00593
NtUserGetThreadState(UserThreadStatePeekMessage);
00594 }
00595
00596
00597
00598
00599
00600
if ((pci->
dwTIFlags &
TIF_16BIT) && !(wRemoveMsg & PM_NOYIELD)) {
00601 cSpinLimit =
CSPINBACKGROUND / 10;
00602 }
else {
00603 cSpinLimit =
CSPINBACKGROUND;
00604 }
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
if ((pci->
dwTIFlags &
TIF_SPINNING) && (pci->
cSpins >= cSpinLimit)) {
00617 pci->
cSpins = 0;
00618
NtYieldExecution();
00619 }
00620
00621
return FALSE;
00622
00623 lbCallServer:
00624
00625
return _PeekMessage(lpMsg,
hWnd, wMsgFilterMin, wMsgFilterMax,
00626 wRemoveMsg,
IS_ANSI);
00627 }
00628
00629 LRESULT
APIENTRY DefWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
00630 {
00631
PWND pwnd;
00632
00633
if ((pwnd =
ValidateHwnd(hwnd)) ==
NULL) {
00634
switch (message) {
00635
case WM_CTLCOLORBTN:
00636
case WM_CTLCOLORSTATIC:
00637
case WM_CTLCOLORDLG:
00638
case WM_CTLCOLORMSGBOX:
00639
00640
00641
00642
00643
break;
00644
default:
00645
return 0;
00646 }
00647 }
00648
00649
return DefWindowProcWorker(pwnd, message, wParam, lParam,
IS_ANSI);
00650 }
00651
00652 LRESULT
APIENTRY SendMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
00653 {
00654
PWND pwnd;
00655
00656
00657
00658
00659
if (message &
RESERVED_MSG_BITS) {
00660 RIPERR1(ERROR_INVALID_PARAMETER,
00661 RIP_WARNING,
00662
"Invalid parameter \"message\" (%ld) to SendMessage",
00663 message);
00664
00665
return 0;
00666 }
00667
00668
00669
00670
00671
00672
if (hwnd == (HWND)-1 || hwnd == (HWND)0x0000FFFF) {
00673
00674
00675
00676
00677
00678 hwnd =
GetDesktopWindow();
00679
00680
00681
00682
00683
00684
00685
00686
return CsSendMessage(hwnd, message, wParam, lParam, 0
L,
00687
FNID_SENDMESSAGEFF,
IS_ANSI);
00688 }
00689
00690
if ((pwnd =
ValidateHwnd(hwnd)) ==
NULL)
00691
return 0;
00692
00693
return SendMessageWorker(pwnd, message, wParam, lParam,
IS_ANSI);
00694 }
00695
00696
00697 LRESULT
APIENTRY SendMessageTimeout(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam,
00698 UINT fuFlags, UINT uTimeout, PULONG_PTR lpdwResult)
00699
00700 {
00701
return SendMessageTimeoutWorker(hwnd, message, wParam, lParam,
00702 fuFlags, uTimeout, lpdwResult,
IS_ANSI);
00703 }
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717 LRESULT WINAPI
SendDlgItemMessage(
00718 HWND hwnd,
00719
int id,
00720 UINT message,
00721 WPARAM wParam,
00722 LPARAM lParam)
00723 {
00724
if (hwnd == (HWND)-1 || hwnd == (HWND)0x0000FFFF)
00725
return 0;
00726
00727
if (hwnd =
GetDlgItem(hwnd,
id))
00728
return SendMessage(hwnd, message, wParam, lParam);
00729
00730
return 0
L;
00731 }
00732
00733
00734
00735
00736
00737
00738
00739
00740 UINT GetDlgItemText(
00741 HWND hwnd,
00742
int id,
00743 LPTSTR lpch,
00744
int cchMax)
00745 {
00746
if ((hwnd =
GetDlgItem(hwnd,
id)) !=
NULL) {
00747
return GetWindowText(hwnd, lpch, cchMax);
00748 }
00749
00750
00751
00752
00753
00754
if (cchMax)
00755 *lpch = (TCHAR)0;
00756
00757
return 0;
00758 }
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768 BOOL SetDlgItemText(
00769 HWND hwnd,
00770
int id,
00771 LPCTSTR lpch)
00772 {
00773
if ((hwnd =
GetDlgItem(hwnd,
id)) !=
NULL) {
00774
return SetWindowText(hwnd, lpch);
00775 }
00776
00777
return FALSE;
00778 }
00779
00780
00781 int WINAPI
GetWindowText(
00782 HWND hwnd,
00783 LPTSTR lpName,
00784
int nMaxCount)
00785 {
00786
PWND pwnd;
00787
00788
00789
00790
00791
if (lpName ==
NULL || nMaxCount == 0) {
00792
return 0;
00793 }
00794
00795
try {
00796
00797
00798
00799 *lpName = TEXT(
'\0');
00800
00801
00802
00803
00804
if ((pwnd =
ValidateHwnd(hwnd)) ==
NULL) {
00805
return 0;
00806 }
00807
00808
00809
00810
00811
if (
TestWindowProcess(pwnd)) {
00812
return (
int)
SendMessageWorker(pwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpName,
IS_ANSI);
00813 }
else {
00814
return (
int)
DefWindowProcWorker(pwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpName,
IS_ANSI);
00815 }
00816 } except (W32ExceptionHandler(
FALSE, RIP_WARNING)) {
00817 RIPERR1(ERROR_INVALID_WINDOW_HANDLE,
00818 RIP_WARNING,
00819
"Window %x no longer valid",
00820 hwnd);
00821
return 0;
00822 }
00823 }
00824
00825 int WINAPI
GetWindowTextLength(
00826 HWND hwnd)
00827 {
00828
PWND pwnd;
00829
00830
00831
00832
00833
if ((pwnd =
ValidateHwnd(hwnd)) ==
NULL) {
00834
return 0;
00835 }
00836
00837
00838
00839
00840
if (
TestWindowProcess(pwnd)) {
00841
return (
int)
SendMessageWorker(pwnd, WM_GETTEXTLENGTH, 0, 0,
IS_ANSI);
00842 }
else {
00843
return (
int)
DefWindowProcWorker(pwnd, WM_GETTEXTLENGTH, 0, 0,
IS_ANSI);
00844 }
00845 }
00846
00847
00848 BOOL WINAPI
SetWindowText(
00849 HWND hwnd,
00850 LPCTSTR pString)
00851 {
00852 LRESULT lReturn;
00853
PWND pwnd;
00854
00855
00856
00857
00858
if ((pwnd =
ValidateHwnd(hwnd)) ==
NULL) {
00859
return FALSE;
00860 }
00861
00862
00863
00864
00865
if (
TestWindowProcess(pwnd)) {
00866 lReturn =
SendMessageWorker(pwnd, WM_SETTEXT, 0, (LPARAM)pString,
IS_ANSI);
00867 }
else {
00868 lReturn =
DefWindowProcWorker(pwnd, WM_SETTEXT, 0, (LPARAM)pString,
IS_ANSI);
00869 }
00870
return (lReturn >= 0);
00871 }
00872
00873
00874 LRESULT
APIENTRY DispatchMessage(CONST MSG *lpMsg)
00875 {
00876
extern LRESULT
DispatchMessageWorker(CONST MSG *lpMsg,
BOOL fAnsi);
00877
00878
return DispatchMessageWorker(lpMsg,
IS_ANSI);
00879 }
00880
00881
#if IS_ANSI
00882
void CopyLogFontAtoW(
00883 PLOGFONTW pdest,
00884 PLOGFONTA psrc)
00885 {
00886 LPSTR lpstrFont = (LPSTR)(&psrc->lfFaceName);
00887 LPWSTR lpstrFontW = (LPWSTR)(&pdest->lfFaceName);
00888
00889 memcpy((LPBYTE)pdest, psrc,
sizeof(LOGFONTA) - LF_FACESIZE);
00890 memset(pdest->lfFaceName, 0, LF_FACESIZE *
sizeof(WCHAR));
00891 MBToWCS(lpstrFont, -1, &lpstrFontW, LF_FACESIZE, FALSE);
00892 }
00893
00894
void CopyLogFontWtoA(
00895 PLOGFONTA pdest,
00896 PLOGFONTW psrc)
00897 {
00898 LPSTR lpstrFont = (LPSTR)(&pdest->lfFaceName);
00899
00900 memcpy((LPBYTE)pdest, (LPBYTE)psrc,
sizeof(LOGFONTA) - LF_FACESIZE);
00901 memset(pdest->lfFaceName, 0, LF_FACESIZE);
00902 WCSToMB(psrc->lfFaceName, -1, &lpstrFont, LF_FACESIZE, FALSE);
00903 }
00904
#else
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914 typedef BOOLEAN (*
PFNGETACTIVEPWRSCHEME)(
PUINT);
00915 typedef BOOLEAN (*
PFNSETACTIVEPWRSCHEME)(
UINT, PGLOBAL_POWER_POLICY, PPOWER_POLICY);
00916 typedef BOOLEAN (*
PFNREADPWRSCHEME)(
UINT, PPOWER_POLICY);
00917
00918 BOOL SetVideoTimeout(
00919 DWORD dwVideoTimeout)
00920 {
00921 POWER_POLICY pp;
00922
UINT uiID;
00923 HINSTANCE hInstDLL;
00924
PFNGETACTIVEPWRSCHEME pfnGetActivePwrScheme;
00925
PFNSETACTIVEPWRSCHEME pfnSetActivePwrScheme;
00926
PFNREADPWRSCHEME pfnReadPwrScheme;
00927
BOOL fRet =
FALSE;
00928
00929
if ((hInstDLL = LoadLibrary(TEXT(
"powrprof.dll"))) ==
NULL) {
00930
return FALSE;
00931 }
00932
00933 pfnGetActivePwrScheme = (
PFNGETACTIVEPWRSCHEME)GetProcAddress(hInstDLL,
"GetActivePwrScheme");
00934 pfnSetActivePwrScheme = (
PFNSETACTIVEPWRSCHEME)GetProcAddress(hInstDLL,
"SetActivePwrScheme");
00935 pfnReadPwrScheme = (
PFNREADPWRSCHEME)GetProcAddress(hInstDLL,
"ReadPwrScheme");
00936
00937
if (pfnGetActivePwrScheme(&uiID)) {
00938
00939
if (pfnReadPwrScheme(uiID, &pp)) {
00940
00941 pp.user.VideoTimeoutDc = dwVideoTimeout;
00942 pp.user.VideoTimeoutAc = dwVideoTimeout;
00943
00944 fRet = pfnSetActivePwrScheme(uiID,
NULL, &pp);
00945 }
00946 }
00947 FreeLibrary (hInstDLL);
00948
00949
return fRet;
00950 }
00951
#endif // IS_ANSI
00952
00953
00954
00955
00956
00957
00958
00959 BOOL APIENTRY SystemParametersInfo(
00960 UINT wFlag,
00961 UINT wParam,
00962 PVOID lParam,
00963 UINT flags)
00964 {
00965
#if IS_ANSI
00966
NONCLIENTMETRICSW ClientMetricsW;
00967 ICONMETRICSW IconMetricsW;
00968 LOGFONTW LogFontW;
00969
00970
00971
00972
00973 WCHAR szTemp[
MAX_PATH];
00974
UINT oldwParam = wParam;
00975
#endif
00976
INTERNALSETHIGHCONTRAST ihc;
00977
IN_STRING strlParam;
00978 PVOID oldlParam = lParam;
00979
00980
00981
00982
00983 strlParam.
fAllocated =
FALSE;
00984
00985
BEGINCALL();
00986
00987
switch (wFlag) {
00988
case SPI_SETSCREENSAVERRUNNING:
00989
MSGERROR();
00990
00991
case SPI_SETDESKPATTERN:
00992
00993
if (wParam == 0x0000FFFF)
00994 wParam = (
UINT)-1;
00995
00996
00997
00998
00999
if (wParam == (
UINT)-1)
01000
break;
01001
01002
01003
01004
01005
if ((lParam != (PVOID)0) && (lParam != (PVOID)-1)) {
01006
COPYLPTSTR(&strlParam, (LPTSTR)lParam);
01007 lParam = strlParam.
pstr;
01008 }
01009
break;
01010
01011
case SPI_SETDESKWALLPAPER: {
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
if ((lParam != (PVOID) 0) &&
01023 (lParam != (PVOID)-1) &&
01024 (lParam != (PVOID)-2)) {
01025
01026
COPYLPTSTR(&strlParam, (LPTSTR)lParam);
01027 lParam = strlParam.
pstr;
01028 wParam = 0;
01029
01030 }
else {
01031 wParam = (
UINT)-1;
01032 }
01033 }
01034
break;
01035
01036
01037
01038
01039
01040
case SPI_GETDESKWALLPAPER:
01041
if ((lParam ==
NULL) || (wParam == 0))
01042
MSGERROR();
01043
#if IS_ANSI
01044
lParam = szTemp;
01045 wParam =
ARRAY_SIZE(szTemp);
01046
#else
01047
01048
01049
01050
01051 wParam--;
01052
#endif
01053
01054
break;
01055
01056
01057
case SPI_GETANIMATION:
01058
if ((lParam ==
NULL) || (*((
DWORD *)(lParam)) !=
sizeof(ANIMATIONINFO)))
01059
MSGERROR();
01060
break;
01061
01062
case SPI_GETNONCLIENTMETRICS:
01063
#if IS_ANSI
01064
if ((lParam ==
NULL) || (*((
DWORD *)(lParam)) !=
sizeof(NONCLIENTMETRICSA)))
01065
MSGERROR();
01066 lParam = &ClientMetricsW;
01067
#else
01068
if ((lParam ==
NULL) || (*((
DWORD *)(lParam)) !=
sizeof(NONCLIENTMETRICSW)))
01069
MSGERROR();
01070
#endif
01071
break;
01072
01073
case SPI_GETMINIMIZEDMETRICS:
01074
if ((lParam ==
NULL) || (*((
DWORD *)(lParam)) !=
sizeof(MINIMIZEDMETRICS)))
01075
MSGERROR();
01076
break;
01077
01078
case SPI_GETICONMETRICS:
01079
#if IS_ANSI
01080
if ((lParam ==
NULL) || (*((
DWORD *)(lParam)) !=
sizeof(ICONMETRICSA)))
01081
MSGERROR();
01082 lParam = &IconMetricsW;
01083
#else
01084
if ((lParam ==
NULL) || (*((
DWORD *)(lParam)) !=
sizeof(ICONMETRICSW)))
01085
MSGERROR();
01086
#endif
01087
break;
01088
01089
case SPI_GETHIGHCONTRAST:
01090
#if IS_ANSI
01091
{
01092 LPHIGHCONTRASTA pHC = (HIGHCONTRASTA *)lParam;
01093
if (!pHC || (pHC->cbSize !=
sizeof(HIGHCONTRASTA))) {
01094
MSGERROR();
01095 }
01096
if (!
pcHighContrastScheme) {
01097
pcHighContrastScheme = LocalAlloc(LPTR, MAX_SCHEME_NAME_SIZE *
sizeof(WCHAR));
01098
if (!
pcHighContrastScheme)
01099
MSGERROR();
01100 }
01101
if (!
pwcHighContrastScheme) {
01102
pwcHighContrastScheme = LocalAlloc(LPTR, MAX_SCHEME_NAME_SIZE *
sizeof(WCHAR));
01103
if (!
pwcHighContrastScheme)
01104
MSGERROR();
01105 }
01106 ((LPHIGHCONTRASTW)(lParam))->lpszDefaultScheme =
pwcHighContrastScheme;
01107 }
01108
#else
01109
{
01110 LPHIGHCONTRASTW pHC = (HIGHCONTRASTW *)lParam;
01111
if (!pHC || (pHC->cbSize !=
sizeof(HIGHCONTRASTW)))
01112
MSGERROR();
01113
if (!
pwcHighContrastScheme) {
01114
pwcHighContrastScheme = LocalAlloc(LPTR, MAX_SCHEME_NAME_SIZE *
sizeof(WCHAR));
01115
if (!
pwcHighContrastScheme)
01116
MSGERROR();
01117 }
01118 pHC->lpszDefaultScheme =
pwcHighContrastScheme;
01119 }
01120
#endif
01121
01122
break;
01123
01124
#if IS_ANSI
01125
case SPI_GETICONTITLELOGFONT:
01126 lParam = &LogFontW;
01127
break;
01128
#endif
01129
01130
case SPI_SETANIMATION:
01131 {
01132
if ((lParam ==
NULL) || (*((
DWORD *)(lParam)) !=
sizeof(ANIMATIONINFO)))
01133
MSGERROR();
01134 }
01135
break;
01136
01137
case SPI_SETHIGHCONTRAST:
01138 ihc.
cbSize =
sizeof (HIGHCONTRASTW);
01139 {
01140 LPHIGHCONTRAST pHC = (HIGHCONTRAST *)lParam;
01141
if ((lParam ==
NULL) || (pHC->cbSize !=
sizeof(HIGHCONTRAST)))
01142
MSGERROR();
01143
01144 lParam = &ihc;
01145 ihc.
dwFlags = pHC->dwFlags;
01146
COPYLPTSTR(&strlParam, pHC->lpszDefaultScheme);
01147 ihc.usDefaultScheme = *strlParam.
pstr;
01148 }
01149
break;
01150
01151
case SPI_SETNONCLIENTMETRICS:
01152
#if IS_ANSI
01153
{
01154 PNONCLIENTMETRICSA psrc = (PNONCLIENTMETRICSA)lParam;
01155
01156
if ((lParam ==
NULL) || (*((
DWORD *)(lParam)) !=
sizeof(NONCLIENTMETRICSA)))
01157
MSGERROR();
01158
01159
if( psrc->iCaptionWidth > 256 )
01160 psrc->iCaptionWidth = 256;
01161
01162
if( psrc->iCaptionHeight > 256 )
01163 psrc->iCaptionHeight = 256;
01164
01165 ClientMetricsW.cbSize = psrc->cbSize;
01166 ClientMetricsW.iBorderWidth = psrc->iBorderWidth;
01167 ClientMetricsW.iScrollWidth = psrc->iScrollWidth;
01168 ClientMetricsW.iScrollHeight = psrc->iScrollHeight;
01169 ClientMetricsW.iCaptionWidth = psrc->iCaptionWidth;
01170 ClientMetricsW.iCaptionHeight = psrc->iCaptionHeight;
01171 ClientMetricsW.iSmCaptionWidth = psrc->iSmCaptionWidth;
01172 ClientMetricsW.iSmCaptionHeight = psrc->iSmCaptionHeight;
01173 ClientMetricsW.iMenuWidth = psrc->iMenuWidth;
01174 ClientMetricsW.iMenuHeight = psrc->iMenuHeight;
01175
01176
CopyLogFontAtoW(&(ClientMetricsW.lfCaptionFont), &(psrc->lfCaptionFont));
01177
CopyLogFontAtoW(&(ClientMetricsW.lfSmCaptionFont), &(psrc->lfSmCaptionFont));
01178
CopyLogFontAtoW(&(ClientMetricsW.lfMenuFont), &(psrc->lfMenuFont));
01179
CopyLogFontAtoW(&(ClientMetricsW.lfStatusFont), &(psrc->lfStatusFont));
01180
CopyLogFontAtoW(&(ClientMetricsW.lfMessageFont), &(psrc->lfMessageFont));
01181
01182 lParam = &ClientMetricsW;
01183 }
01184
#else
01185
{
01186 PNONCLIENTMETRICSA psrc;
01187
01188
if ((lParam ==
NULL) || (*((
DWORD *)(lParam)) !=
sizeof(NONCLIENTMETRICSW)))
01189
MSGERROR();
01190
01191 psrc = (PNONCLIENTMETRICSA)lParam;
01192
01193
if( psrc->iCaptionWidth > 256 )
01194 psrc->iCaptionWidth = 256;
01195
01196
if( psrc->iCaptionHeight > 256 )
01197 psrc->iCaptionHeight = 256;
01198 }
01199
#endif
01200
wParam =
sizeof(NONCLIENTMETRICSW);
01201
break;
01202
01203
case SPI_SETMINIMIZEDMETRICS:
01204
if ((lParam ==
NULL) || (*((
DWORD *)(lParam)) !=
sizeof(MINIMIZEDMETRICS)))
01205
MSGERROR();
01206 wParam =
sizeof(MINIMIZEDMETRICS);
01207
break;
01208
01209
case SPI_SETICONMETRICS:
01210
#if IS_ANSI
01211
{
01212 PICONMETRICSA psrc = (PICONMETRICSA)lParam;
01213
01214
if ((lParam ==
NULL) || (*((
DWORD *)(lParam)) !=
sizeof(ICONMETRICSA)))
01215
MSGERROR();
01216
01217 memcpy(&IconMetricsW, psrc,
sizeof(ICONMETRICSA) -
sizeof(LOGFONTA));
01218
01219
CopyLogFontAtoW(&(IconMetricsW.lfFont), &(psrc->lfFont));
01220 lParam = &IconMetricsW;
01221 }
01222
#else
01223
if ((lParam ==
NULL) || (*((
DWORD *)(lParam)) !=
sizeof(ICONMETRICSW)))
01224
MSGERROR();
01225
#endif
01226
wParam =
sizeof(ICONMETRICSW);
01227
break;
01228
01229
case SPI_SETICONTITLELOGFONT:
01230
#if IS_ANSI
01231
CopyLogFontAtoW(&LogFontW, lParam);
01232 lParam = &LogFontW;
01233
#endif
01234
wParam =
sizeof(LOGFONTW);
01235
break;
01236
01237
case SPI_GETFILTERKEYS:
01238 {
01239
if ((((LPFILTERKEYS)lParam)->cbSize == 0) ||
01240 (((LPFILTERKEYS)lParam)->cbSize) >
sizeof(FILTERKEYS)) {
01241
MSGERROR();
01242 }
01243 }
01244
break;
01245
01246
case SPI_GETSTICKYKEYS:
01247 {
01248
if ((((LPSTICKYKEYS)lParam)->cbSize == 0) ||
01249 (((LPSTICKYKEYS)lParam)->cbSize) >
sizeof(STICKYKEYS)) {
01250
MSGERROR();
01251 }
01252 }
01253
break;
01254
01255
case SPI_GETTOGGLEKEYS:
01256 {
01257
if ((((LPTOGGLEKEYS)lParam)->cbSize == 0) ||
01258 (((LPTOGGLEKEYS)lParam)->cbSize) >
sizeof(TOGGLEKEYS)) {
01259
MSGERROR();
01260 }
01261 }
01262
break;
01263
01264
case SPI_GETMOUSEKEYS:
01265 {
01266
if ((((LPMOUSEKEYS)lParam)->cbSize == 0) ||
01267 (((LPMOUSEKEYS)lParam)->cbSize) >
sizeof(MOUSEKEYS)) {
01268
MSGERROR();
01269 }
01270 }
01271
break;
01272
01273
case SPI_GETACCESSTIMEOUT:
01274 {
01275
if ((((LPACCESSTIMEOUT)lParam)->cbSize == 0) ||
01276 (((LPACCESSTIMEOUT)lParam)->cbSize) >
sizeof(ACCESSTIMEOUT)) {
01277
MSGERROR();
01278 }
01279 }
01280
break;
01281
01282
case SPI_GETSOUNDSENTRY:
01283
01284
01285
01286
01287
01288
01289 {
01290
if ((((LPSOUNDSENTRY)lParam)->cbSize == 0) ||
01291 (((LPSOUNDSENTRY)lParam)->cbSize) >
sizeof(SOUNDSENTRY)) {
01292
MSGERROR();
01293 }
01294 }
01295
break;
01296 }
01297
01298 retval =
NtUserSystemParametersInfo(wFlag, wParam, lParam, flags);
01299
01300
switch (wFlag) {
01301
#if IS_ANSI
01302
case SPI_GETNONCLIENTMETRICS:
01303 {
01304 PNONCLIENTMETRICSA pdst = (PNONCLIENTMETRICSA)oldlParam;
01305
01306 pdst->cbSize =
sizeof(NONCLIENTMETRICSA);
01307 pdst->iBorderWidth = ClientMetricsW.iBorderWidth;
01308 pdst->iScrollWidth = ClientMetricsW.iScrollWidth;
01309 pdst->iScrollHeight = ClientMetricsW.iScrollHeight;
01310 pdst->iCaptionWidth = ClientMetricsW.iCaptionWidth;
01311 pdst->iCaptionHeight = ClientMetricsW.iCaptionHeight;
01312 pdst->iSmCaptionWidth = ClientMetricsW.iSmCaptionWidth;
01313 pdst->iSmCaptionHeight = ClientMetricsW.iSmCaptionHeight;
01314 pdst->iMenuWidth = ClientMetricsW.iMenuWidth;
01315 pdst->iMenuHeight = ClientMetricsW.iMenuHeight;
01316
01317
CopyLogFontWtoA(&(pdst->lfCaptionFont), &(ClientMetricsW.lfCaptionFont));
01318
CopyLogFontWtoA(&(pdst->lfSmCaptionFont), &(ClientMetricsW.lfSmCaptionFont));
01319
CopyLogFontWtoA(&(pdst->lfMenuFont), &(ClientMetricsW.lfMenuFont));
01320
CopyLogFontWtoA(&(pdst->lfStatusFont), &(ClientMetricsW.lfStatusFont));
01321
CopyLogFontWtoA(&(pdst->lfMessageFont), &(ClientMetricsW.lfMessageFont));
01322 }
01323
break;
01324
01325
case SPI_GETICONMETRICS:
01326 {
01327 PICONMETRICSA pdst = (PICONMETRICSA)oldlParam;
01328
01329 memcpy(pdst, &IconMetricsW,
sizeof(ICONMETRICSA) -
sizeof(LOGFONTA));
01330 pdst->cbSize =
sizeof(ICONMETRICSA);
01331
01332
CopyLogFontWtoA(&(pdst->lfFont), &(IconMetricsW.lfFont));
01333 }
01334
break;
01335
01336
case SPI_GETICONTITLELOGFONT:
01337 {
01338
CopyLogFontWtoA((PLOGFONTA)oldlParam, &LogFontW);
01339 }
01340
break;
01341
01342
case SPI_GETHIGHCONTRAST:
01343 WCSToMB(
pwcHighContrastScheme, -1, &
pcHighContrastScheme, MAX_SCHEME_NAME_SIZE,
FALSE);
01344 ((LPHIGHCONTRASTA)(lParam))->lpszDefaultScheme =
pcHighContrastScheme;
01345
break;
01346
01347
#endif // IS_ANSI
01348
01349
01350
01351
01352
01353
case SPI_GETDESKWALLPAPER:
01354 {
01355
01356
01357
01358
01359
#if IS_ANSI
01360
INT cchAnsiCopy = WCSToMB(lParam,
01361 -1,
01362 (LPSTR*)&oldlParam,
01363 oldwParam - 1,
01364
FALSE);
01365
01366 cchAnsiCopy =
min(cchAnsiCopy, (
INT)(oldwParam - 1));
01367 ((LPSTR)oldlParam)[cchAnsiCopy] = 0;
01368
#else //UNICODE
01369
((LPWSTR)oldlParam)[wParam] = (WCHAR)0;
01370
#endif //IS_ANSI
01371
break;
01372 }
01373
case SPI_SETLOWPOWERTIMEOUT:
01374
case SPI_SETPOWEROFFTIMEOUT:
01375
if (retval && (flags & SPIF_UPDATEINIFILE)) {
01376 retval =
SetVideoTimeout(wParam);
01377 }
01378
break;
01379 }
01380
01381
ERRORTRAP(
FALSE);
01382
CLEANUPLPTSTR(strlParam);
01383
ENDCALL(
BOOL);
01384 }
01385
01386
01387 HANDLE
APIENTRY GetProp(HWND hwnd, LPCTSTR pString) {
01388
PWND pwnd;
01389
int iString;
01390
01391
if (
IS_PTR(pString)) {
01392 iString = (
int)GlobalFindAtom(pString);
01393
if (iString == 0)
01394
return NULL;
01395 }
else
01396 iString =
PTR_TO_ID(pString);
01397
01398 pwnd =
ValidateHwnd(hwnd);
01399
01400
if (pwnd ==
NULL)
01401
return NULL;
01402
01403
return _GetProp(pwnd, (LPWSTR)UIntToPtr( iString ),
FALSE);
01404 }
01405
01406
01407
01408
01409
01410
01411
01412
01413 ATOM
01414 WINAPI
01415 TEXT_FN(RegisterClass)(
01416 CONST WNDCLASS *lpWndClass )
01417 {
01418 WNDCLASSEX wc;
01419
01420
01421
01422
01423
01424
01425 RtlCopyMemory(&(wc.lpfnWndProc), &(lpWndClass->lpfnWndProc),
sizeof(WNDCLASS) - FIELD_OFFSET(WNDCLASS, lpfnWndProc));
01426 wc.style = lpWndClass->style;
01427 wc.hIconSm =
NULL;
01428 wc.cbSize =
sizeof(WNDCLASSEX);
01429
01430
return TEXT_FN(
RegisterClassExWOW)(&wc,
NULL, 0);
01431 }
01432
01433
01434
01435
01436
01437
01438
01439 ATOM
01440 WINAPI
01441 TEXT_FN(RegisterClassEx)(
01442 CONST WNDCLASSEX *lpWndClass)
01443 {
01444
if (lpWndClass->cbSize !=
sizeof(WNDCLASSEX)) {
01445 RIPERR1(ERROR_INVALID_PARAMETER,
01446 RIP_WARNING,
01447
"RegisterClassEx: cbsize is wrong %lX",
01448 lpWndClass->cbSize);
01449
01450
return 0;
01451 }
else {
01452
return TEXT_FN(
RegisterClassExWOW)((LPWNDCLASSEX)lpWndClass,
01453
NULL, 0);
01454 }
01455 }
01456
01457
01458
01459
01460
01461
01462
01463 BOOL TEXT_FN(GetMenuItemInfoInternal) (HMENU hMenu,
UINT uID,
BOOL fByPosition,
01464 LPMENUITEMINFOW lpInfo)
01465 {
01466 VALIDATIONFNNAME(
GetMenuItemInfoInternal)
01467
01468
PITEM pItem;
01469
PMENU pMenu;
01470
PMENU pMenuT;
01471
01472 pMenu =
VALIDATEHMENU(hMenu);
01473
if (pMenu ==
NULL) {
01474 VALIDATIONFAIL(hMenu);
01475 }
01476
01477 pMenuT = pMenu;
01478
01479 pItem =
MNLookUpItem(pMenu, uID, fByPosition, &pMenu);
01480
if (pItem ==
NULL) {
01481
01482
01483
01484
01485
01486 SetLastError(ERROR_MENU_ITEM_NOT_FOUND);
01487
return FALSE;
01488
01489 }
01490
01491
if (lpInfo->fMask & MIIM_STATE) {
01492 lpInfo->fState = pItem->
fState & MFS_MASK;
01493 }
01494
01495
if (lpInfo->fMask & MIIM_ID) {
01496 lpInfo->wID = pItem->
wID;
01497 }
01498
01499
if ((lpInfo->fMask & MIIM_SUBMENU) && (pItem->
spSubMenu !=
NULL)) {
01500 lpInfo->hSubMenu =
PtoH(
REBASEPTR(pMenu, pItem->
spSubMenu));
01501 }
else {
01502 lpInfo->hSubMenu =
NULL;
01503 }
01504
01505
if (lpInfo->fMask & MIIM_CHECKMARKS) {
01506 lpInfo->hbmpChecked = pItem->
hbmpChecked;
01507 lpInfo->hbmpUnchecked= pItem->
hbmpUnchecked;
01508 }
01509
01510
if (lpInfo->fMask & MIIM_DATA) {
01511 lpInfo->dwItemData = KERNEL_ULONG_PTR_TO_ULONG_PTR(pItem->
dwItemData);
01512 }
01513
01514
if (lpInfo->fMask & MIIM_FTYPE) {
01515 lpInfo->fType = pItem->
fType & MFT_MASK;
01516
if (
TestMF(pMenuT,
MFRTL))
01517 lpInfo->fType |= MFT_RIGHTORDER;
01518 }
01519
01520
if ( lpInfo->fMask & MIIM_BITMAP) {
01521 lpInfo->hbmpItem = pItem->
hbmp;
01522 }
01523
01524
if (lpInfo->fMask & MIIM_STRING) {
01525
if ((lpInfo->cch == 0)
01526 || (lpInfo->dwTypeData ==
NULL)
01527
01528
01529
01530
01531
01532
01533
01534 || ((lpInfo->fMask & MIIM_TYPE)
01535 && ((lpInfo->fType & MFT_OWNERDRAW)
01536
01537
01538
01539
01540
01541
01542 || (lpInfo->fType & MFT_SEPARATOR)
01543 || ((pItem->
hbmp !=
NULL) && ((pItem->
hbmp < HBMMENU_POPUPFIRST) || (pItem->
hbmp > HBMMENU_POPUPLAST)))))) {
01544
01545
01546
01547
01548
01549
01550
01551
01552
if (
IS_ANSI &&
IS_DBCS_ENABLED() && pItem->
lpstr !=
NULL) {
01553
NTSTATUS Status;
01554 ULONG cch;
01555
01556
Status =
RtlUnicodeToMultiByteSize(&cch,
REBASEPTR(pMenu, pItem->
lpstr), pItem->
cch *
sizeof(WCHAR));
01557 UserAssert(
NT_SUCCESS(
Status));
01558 lpInfo->cch = cch;
01559 }
else {
01560 lpInfo->cch = pItem->
cch;
01561 }
01562 lpInfo->dwTypeData =
NULL;
01563
01564
01565 }
else {
01566
int cch = 0;
01567
01568
if (pItem->
lpstr !=
NULL) {
01569
01570
01571
01572 cch = pItem->
cch;
01573 UserAssert(cch >= 0);
01574
if (
IS_DBCS_ENABLED()) {
01575
01576
01577
01578 cch *=
DBCS_CHARSIZE;
01579 }
01580 cch =
min(lpInfo->cch - 1, (
DWORD)cch);
01581
01582
#if IS_ANSI
01583
cch = WCSToMB(
REBASEPTR(pMenu, pItem->
lpstr), pItem->
cch,
01584 (LPSTR *)&(lpInfo->dwTypeData), cch,
FALSE);
01585
#else
01586
wcsncpy(lpInfo->dwTypeData, (LPWSTR)
REBASEPTR(pMenu, pItem->
lpstr),
01587 cch);
01588
#endif
01589
}
01590
01591
#if IS_ANSI
01592
*((LPSTR)lpInfo->dwTypeData + cch) = (
CHAR)0;
01593
#else
01594
*(lpInfo->dwTypeData + cch) = (WCHAR)0;
01595
#endif
01596
lpInfo->cch = cch;
01597 }
01598 }
01599
01600
return TRUE;
01601
01602 VALIDATIONERROR(
FALSE);
01603
01604 }
01605
01606
01607
01608
01609
01610
01611 int GetMenuString(HMENU hMenu, UINT wID, LPTSTR lpsz,
int cchMax, UINT flags)
01612 {
01613 MENUITEMINFOW miiLocal;
01614
01615 miiLocal.fMask = MIIM_STRING;
01616 miiLocal.dwTypeData = (LPWSTR)lpsz;
01617 miiLocal.cch = cchMax;
01618
01619
if (cchMax != 0) {
01620 *lpsz = (TCHAR)0;
01621 }
01622
01623
if (
TEXT_FN(
GetMenuItemInfoInternal)(hMenu, wID, (
BOOL)(flags & MF_BYPOSITION), &miiLocal)) {
01624
return miiLocal.cch;
01625 }
else {
01626
return 0;
01627 }
01628 }
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643 BOOL GetMenuItemInfo(HMENU hMenu, UINT wID, BOOL fByPos, LPMENUITEMINFO lpmii)
01644 {
01645
UINT cbCallercbSize = lpmii->cbSize;
01646 MENUITEMINFOW miiLocal;
01647
01648
01649
if (!
ValidateMENUITEMINFO((LPMENUITEMINFOW)lpmii, &miiLocal,
MENUAPI_GET)) {
01650
return FALSE;
01651 }
01652
01653
if (!
TEXT_FN(
GetMenuItemInfoInternal)(hMenu, wID, fByPos, &miiLocal)) {
01654
return FALSE;
01655 }
01656
01657
01658
01659
01660
01661 RtlCopyMemory(lpmii, &miiLocal, SIZEOFMENUITEMINFO95);
01662 lpmii->cbSize = cbCallercbSize;
01663
if (cbCallercbSize > SIZEOFMENUITEMINFO95) {
01664 lpmii->hbmpItem = miiLocal.hbmpItem;
01665 }
01666
01667
if (lpmii->fMask & MIIM_TYPE) {
01668
if ((miiLocal.hbmpItem !=
NULL) && (miiLocal.dwTypeData ==
NULL)) {
01669 lpmii->fType |= MFT_BITMAP;
01670 lpmii->dwTypeData = (LPTSTR)miiLocal.hbmpItem;
01671 }
else if (miiLocal.cch == 0) {
01672 lpmii->dwTypeData =
NULL;
01673 }
01674 lpmii->fMask &= ~(MIIM_FTYPE | MIIM_BITMAP | MIIM_STRING);
01675 }
01676
01677
return TRUE;
01678 }
01679
01680
01681
01682
01683
01684
01685 BOOL SetMenuItemInfo(HMENU hMenu, UINT uID, BOOL fByPosition, LPCMENUITEMINFO lpmii)
01686 {
01687
01688 MENUITEMINFOW miiLocal;
01689
01690
if (!
ValidateMENUITEMINFO((LPMENUITEMINFOW)lpmii, &miiLocal,
MENUAPI_SET)) {
01691
return FALSE;
01692 }
01693
01694
return (
ThunkedMenuItemInfo(hMenu, uID, fByPosition,
FALSE, &miiLocal,
IS_ANSI));
01695 }
01696
01697
01698
01699
01700
01701
01702 BOOL InsertMenuItem (HMENU hMenu, UINT uID, BOOL fByPosition, LPCMENUITEMINFO lpmii)
01703 {
01704
01705 MENUITEMINFOW miiLocal;
01706
01707
if (!
ValidateMENUITEMINFO((LPMENUITEMINFOW)lpmii, &miiLocal,
MENUAPI_SET)) {
01708
return FALSE;
01709 }
01710
01711
return (
ThunkedMenuItemInfo(hMenu, uID, fByPosition,
TRUE, &miiLocal,
IS_ANSI));
01712 }
01713
01714
01715
01716
01717
01718
01719
01720 BOOL InsertMenu(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCTSTR lpNewItem)
01721 {
01722 MENUITEMINFOW miiLocal;
01723
01724
SetMenuItemInfoStruct(hMenu, uFlags, uIDNewItem, (LPWSTR)lpNewItem, &miiLocal);
01725
return ThunkedMenuItemInfo(hMenu, uPosition, (
BOOL) (uFlags & MF_BYPOSITION),
TRUE, (LPMENUITEMINFOW)&miiLocal,
IS_ANSI);
01726 }
01727
01728
01729
01730
01731
01732
01733
01734 BOOL AppendMenu(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCTSTR lpNewItem)
01735 {
01736 MENUITEMINFOW miiLocal;
01737
01738
SetMenuItemInfoStruct(hMenu, uFlags, uIDNewItem, (LPWSTR)lpNewItem, &miiLocal);
01739
return ThunkedMenuItemInfo(hMenu,
MFMWFP_NOITEM, MF_BYPOSITION,
TRUE, (LPMENUITEMINFOW)&miiLocal,
IS_ANSI);
01740 }
01741
01742
01743
01744
01745
01746
01747 BOOL ModifyMenu(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCTSTR lpNewItem) {
01748 MENUITEMINFOW miiLocal;
01749
01750
SetMenuItemInfoStruct(hMenu, uFlags, uIDNewItem, (LPWSTR)lpNewItem, &miiLocal);
01751
return ThunkedMenuItemInfo(hMenu, uPosition, (
BOOL) (uFlags & MF_BYPOSITION),
FALSE, (LPMENUITEMINFOW)&miiLocal,
IS_ANSI);
01752 }
01753
01754
01755
01756
01757
01758
01759
01760 WINUSERAPI LONG
BroadcastSystemMessage(DWORD dwFlags, LPDWORD lpdwRecipients,
01761 UINT uiMessage, WPARAM wParam, LPARAM lParam)
01762 {
01763
extern LONG
BroadcastSystemMessageWorker(
DWORD dwFlags, LPDWORD lpdwRecipients,
01764
UINT uiMessage, WPARAM wParam, LPARAM lParam,
BOOL fAnsi);
01765
01766
return BroadcastSystemMessageWorker(
dwFlags, lpdwRecipients,
01767 uiMessage, wParam, lParam,
IS_ANSI);
01768 }
01769
01770 WINUSERAPI
UINT WINAPI
01771 GetWindowModuleFileName(HWND hwnd, LPTSTR pszFileName, UINT cchFileNameMax)
01772 {
01773
PWND pwnd;
01774
01775 pwnd =
ValidateHwnd(hwnd);
01776
01777
if (pwnd ==
NULL) {
01778
return 0;
01779 }
01780
01781
return GetModuleFileName(pwnd->hModule, pszFileName, cchFileNameMax);
01782 }
01783
01784
01785
01786
01787
01788
01789
01790
01791 WINUSERAPI HDEVNOTIFY WINAPI
01792 RegisterDeviceNotification(
01793 IN HANDLE hRecipient,
01794 IN LPVOID NotificationFilter,
01795 IN DWORD Flags
01796 )
01797 {
01798
extern HDEVNOTIFY
RegisterDeviceNotificationWorker(IN HANDLE hRecipient,
01799 IN
LPVOID NotificationFilter,
01800 IN
DWORD Flags,
01801 IN
BOOL IsAnsi
01802 );
01803
01804
01805
01806
return RegisterDeviceNotificationWorker(hRecipient,
01807 NotificationFilter,
01808 Flags,
01809
IS_ANSI
01810 );
01811 }
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
BOOL WINUSERAPI
01824 GetMonitorInfo(HMONITOR hMonitor, LPMONITORINFO lpmi)
01825 {
01826
PMONITOR pMonitor;
01827
BOOL bRetVal;
01828
int cbSize;
01829
01830 pMonitor =
VALIDATEHMONITOR(hMonitor);
01831
if (!pMonitor) {
01832
return FALSE;
01833 }
01834
01835 cbSize = lpmi->cbSize;
01836
if (cbSize ==
sizeof(MONITORINFO)) {
01837
01838
01839
01840
01841
01842
01843
01844 }
else if (cbSize ==
sizeof(MONITORINFOEX)) {
01845
01846
01847
01848 ULONG_PTR pName;
01849
#if IS_ANSI
01850
WCHAR szDevice[CCHDEVICENAME];
01851 pName = (ULONG_PTR)szDevice;
01852
#else
01853
pName = (ULONG_PTR)(((LPMONITORINFOEX)lpmi)->szDevice);
01854
#endif
01855
bRetVal = (
BOOL)
NtUserCallTwoParam((ULONG_PTR)(hMonitor),
01856 pName,
01857 SFI_GETHDEVNAME);
01858
if (!bRetVal) {
01859
return FALSE;
01860 }
01861
#if IS_ANSI
01862
WideCharToMultiByte(
01863 CP_ACP, 0,
01864 (LPWSTR)pName, -1,
01865 (LPSTR)((LPMONITORINFOEX)lpmi)->szDevice,
01866
sizeof(WCHAR)*CCHDEVICENAME,
01867
NULL,
NULL);
01868
01869
#endif
01870
}
else {
01871 RIPERR1(ERROR_INVALID_PARAMETER,
01872 RIP_WARNING,
01873
"Invalid lpmi->cbSize, %d", lpmi->cbSize);
01874
01875
return FALSE;
01876 }
01877
01878 lpmi->dwFlags = (pMonitor ==
GetPrimaryMonitor()) ? MONITORINFOF_PRIMARY : 0;
01879 lpmi->rcMonitor = pMonitor->
rcMonitor;
01880 lpmi->rcWork = pMonitor->
rcWork;
01881
01882
return TRUE;
01883 }