00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
#include "precomp.h"
00014
#pragma hdrstop
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 BOOL zzzSetSystemCursor(
00029
PCURSOR pcur,
00030 DWORD
id)
00031 {
00032
int i;
00033
00034
if (!
CheckWinstaWriteAttributesAccess()) {
00035
return FALSE;
00036 }
00037
00038 UserAssert(pcur);
00039
00040
00041
00042
00043
for (i = 0; i < COCR_CONFIGURABLE; i++)
00044
if (
gasyscur[i].
Id == (WORD)
id)
00045
break;
00046
00047
00048
00049
00050
if (i == COCR_CONFIGURABLE) {
00051 RIPMSG1(RIP_WARNING,
"_SetSystemCursor: called with bad id %x.\n",
id);
00052
return FALSE;
00053 }
00054
00055
return zzzSetSystemImage(pcur,
gasyscur[i].spcur);
00056 }
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 BOOL zzzSetSystemImage(
00070
PCURSOR pcur,
00071
PCURSOR pcurSys)
00072 {
00073
#define CBCOPY (max(sizeof(CURSOR), sizeof(ACON)) - FIELD_OFFSET(CURSOR, CI_COPYSTART))
00074
#define pacon ((PACON)pcur)
00075
00076
char cbT[
CBCOPY];
00077
UINT CURSORF_flags;
00078
00079 UserAssert(pcurSys);
00080
00081
if (pcurSys == pcur)
00082
return(
TRUE);
00083
00084
00085
00086
00087
00088 UserAssert(!
IS_PTR(pcurSys->strName.Buffer));
00089 UserAssert(pcurSys->atomModName ==
atomUSER32);
00090
00091
00092
00093
00094 UserAssert(pcurSys->head.ppi ==
NULL);
00095
if (pcur->CURSORF_flags &
CURSORF_ACON &&
00096 pcur->head.ppi !=
NULL) {
00097
00098
int i;
00099
PHE phe =
HMPheFromObject(pcurSys);
00100
PTHREADINFO ptiOwner = ((
PPROCESSINFO)phe->
pOwner)->ptiList;
00101
00102
for (i = 0; i <
pacon->cpcur; i++) {
00103
HMChangeOwnerProcess(
pacon->aspcur[i], ptiOwner);
00104
pacon->aspcur[i]->head.ppi =
NULL;
00105 }
00106 }
00107
00108
00109
00110
00111
00112
00113 UserAssert(FIELD_OFFSET(
CURSOR, CI_FIRST) == FIELD_OFFSET(
ACON, CI_FIRST));
00114
00115
00116
00117
00118 RtlCopyMemory(&cbT, &pcur->CI_COPYSTART,
CBCOPY);
00119 RtlCopyMemory(&pcur->CI_COPYSTART, &pcurSys->CI_COPYSTART,
CBCOPY);
00120 RtlCopyMemory(&pcurSys->CI_COPYSTART, &cbT,
CBCOPY);
00121
00122
00123
00124 CURSORF_flags = pcur->CURSORF_flags &
CURSORF_ACON;
00125 pcur->CURSORF_flags =
00126 (pcur->CURSORF_flags & ~
CURSORF_ACON) |
00127 (pcurSys->CURSORF_flags &
CURSORF_ACON);
00128 pcurSys->CURSORF_flags =
00129 (pcurSys->CURSORF_flags & ~
CURSORF_ACON) | CURSORF_flags;
00130
00131
00132
00133
00134
00135
if (pcur->CURSORF_flags &
CURSORF_ACON) {
00136
int i;
00137
PTHREADINFO ptiCurrent =
PtiCurrent();
00138
for (i = 0; i <
pacon->cpcur; i++) {
00139
HMChangeOwnerProcess(
pacon->aspcur[i], ptiCurrent);
00140 }
00141 }
00142
00143
00144
00145
00146
_DestroyCursor(pcur,
CURSOR_THREADCLEANUP);
00147
00148
00149
00150
00151
00152
00153
if (
gpcurLogCurrent == pcurSys) {
00154
gpcurLogCurrent =
NULL;
00155
gpcurPhysCurrent =
NULL;
00156
zzzUpdateCursorImage();
00157 }
00158
00159
00160
00161
00162 pcurSys->CURSORF_flags |= CURSORF_SYSTEM;
00163
00164
return TRUE;
00165
#undef pacon
00166
#undef CBCOPY
00167
}
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 PCURSOR _GetCursorFrameInfo(
00184
PCURSOR pcur,
00185
int iFrame,
00186 PJIF pjifRate,
00187 LPINT pccur)
00188 {
00189
00190
00191
00192
00193
if (!(pcur->CURSORF_flags &
CURSORF_ACON)) {
00194 *pccur = 1;
00195 *pjifRate = 0;
00196
return pcur;
00197 }
00198
00199
00200
00201
00202
00203
#define pacon ((PACON)pcur)
00204
if (iFrame < 0 || iFrame >=
pacon->cicur)
00205
return NULL;
00206
00207 *pccur =
pacon->cicur;
00208 *pjifRate =
pacon->ajifRate[iFrame];
00209
00210
return pacon->aspcur[
pacon->aicur[iFrame]];
00211
#undef pacon
00212
}
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229 BOOL DestroyAniIcon(
00230
PACON pacon)
00231 {
00232
int i;
00233
PCURSOR pcur;
00234
00235
for (i = 0; i <
pacon->cpcur; i++) {
00236 UserAssert(
pacon->aspcur[i]->CURSORF_flags &
CURSORF_ACONFRAME);
00237
00238
00239
00240
00241
00242 UserAssert(
GETPPI(
pacon->aspcur[i]) !=
NULL);
00243 pcur =
Unlock(&
pacon->aspcur[i]);
00244
if (pcur !=
NULL) {
00245
_DestroyCursor(pcur,
CURSOR_ALWAYSDESTROY);
00246 }
00247 }
00248
00249 UserFreePool(
pacon->aspcur);
00250
00251
return TRUE;
00252 }
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 VOID LinkCursor(
00270
PCURSOR pcur)
00271 {
00272
00273
00274
00275 UserAssert(!(pcur->CURSORF_flags &
CURSORF_LINKED));
00276
00277
00278
00279
00280
00281
00282
00283
if (!(pcur->CURSORF_flags &
CURSORF_ACONFRAME)) {
00284
PPROCESSINFO ppi = pcur->head.ppi;
00285
if (ppi ==
NULL) {
00286
00287
00288
00289 pcur->pcurNext =
gpcurFirst;
00290
gpcurFirst = pcur;
00291 pcur->CURSORF_flags |=
CURSORF_LINKED;
00292 }
else if (pcur->CURSORF_flags &
CURSORF_LRSHARED) {
00293
00294
00295
00296 pcur->pcurNext = ppi->
pCursorCache;
00297 ppi->
pCursorCache = pcur;
00298 pcur->CURSORF_flags |=
CURSORF_LINKED;
00299 }
00300 }
00301 }
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319 BOOL _SetCursorIconData(
00320
PCURSOR pcur,
00321 PUNICODE_STRING cczpstrModName,
00322 PUNICODE_STRING cczpstrName,
00323
PCURSORDATA pcurData,
00324 DWORD cbData)
00325 {
00326
#define pacon ((PACON)pcur)
00327
int i;
00328
#if DBG
00329
BOOL fSuccess;
00330
#endif
00331
00332 pcur->CURSORF_flags |= pcurData->
CURSORF_flags;
00333 pcur->rt = pcurData->
rt;
00334
00335
if (pcurData->
CURSORF_flags &
CURSORF_ACON) {
00336 UserAssert(
pacon->aspcur ==
NULL);
00337 RtlCopyMemory(&
pacon->cpcur,
00338 &pcurData->
cpcur,
00339
sizeof(
ACON) - FIELD_OFFSET(
ACON, cpcur));
00340 }
else {
00341 RtlCopyMemory(&pcur->CI_COPYSTART,
00342 &pcurData->CI_COPYSTART,
00343
sizeof(
CURSOR) - FIELD_OFFSET(
CURSOR, CI_COPYSTART));
00344 }
00345
00346
00347
00348
00349
if (cczpstrName->Length != 0){
00350
00351
00352
00353
00354
00355
if (!
AllocateUnicodeString(&pcur->strName, cczpstrName))
00356
return FALSE;
00357 }
else {
00358 pcur->strName = *cczpstrName;
00359 }
00360
00361
00362
00363
00364
if (cczpstrModName->Buffer) {
00365
00366
00367
00368 pcur->atomModName =
UserAddAtom(cczpstrModName->Buffer,
FALSE);
00369
if (pcur->atomModName == 0) {
00370
return FALSE;
00371 }
00372 }
00373
00374
if (pcur->CURSORF_flags &
CURSORF_ACON) {
00375
00376
00377
00378
00379
pacon = (
PACON)pcur;
00380
pacon->aspcur = UserAllocPool(cbData, TAG_CURSOR);
00381
if (
pacon->aspcur ==
NULL)
00382
return FALSE;
00383
00384
00385
00386
00387
00388
00389
00390
00391
try {
00392 RtlCopyMemory(
pacon->aspcur, pcurData->
aspcur, cbData);
00393
pacon->aicur = (
DWORD *)((
PBYTE)
pacon->aspcur + (ULONG_PTR)pcurData->
aicur);
00394
pacon->ajifRate = (PJIF)((
PBYTE)
pacon->aspcur + (ULONG_PTR)pcurData->
ajifRate);
00395 } except (W32ExceptionHandler(
FALSE, RIP_WARNING)) {
00396 UserFreePool(
pacon->aspcur);
00397
pacon->aspcur =
NULL;
00398
return FALSE;
00399 }
00400
00401
00402
00403
00404
for (i = 0; i <
pacon->cpcur; i++) {
00405
PCURSOR pcurT;
00406
00407 pcurT = (
PCURSOR)
HMValidateHandle(
pacon->aspcur[i],
TYPE_CURSOR);
00408
if (pcurT) {
00409
pacon->aspcur[i] =
NULL;
00410
Lock(&
pacon->aspcur[i], pcurT);
00411 }
else {
00412
while (--i >= 0) {
00413
Unlock(&
pacon->aspcur[i]);
00414 }
00415
00416 UserFreePool(
pacon->aspcur);
00417
pacon->aspcur =
NULL;
00418 RIPMSG0(RIP_WARNING,
"SetCursorIconData: invalid cursor handle for animated cursor");
00419
return FALSE;
00420 }
00421 }
00422 }
else {
00423
00424 PW32PROCESS W32Process = W32GetCurrentProcess();
00425
00426
00427
00428
00429 UserAssert(pcur->hbmMask);
00430 UserAssert(pcur->cx);
00431 UserAssert(pcur->cy);
00432
00433
00434
00435
00436
00437
#if DBG
00438
fSuccess =
00439
#endif
00440
GreSetBitmapOwner(pcur->hbmMask, OBJECT_OWNER_PUBLIC);
00441 UserAssert(fSuccess);
00442 GreIncQuotaCount(W32Process);
00443
if (pcur->hbmColor) {
00444
#if DBG
00445
fSuccess =
00446
#endif
00447
GreSetBitmapOwner(pcur->hbmColor, OBJECT_OWNER_PUBLIC);
00448 UserAssert(fSuccess);
00449 GreIncQuotaCount(W32Process);
00450 }
00451 }
00452
00453
LinkCursor(pcur);
00454
00455
return TRUE;
00456
#undef pacon
00457
}