Module: D:\SOURCE\WIN\WCOPY\waitcurs.cpp Group: 'DGROUP' CONST,CONST2,_DATA,_BSS Segment: waitcurs_TEXT PARA 00000315 bytes #include "waitcurs.h" #include #define ANIMATIONSPEED 512 #define CURSORS 18 static HINSTANCE __far hinstDLL; static HHOOK __far hook=NULL; static HCURSOR __far hWaitCursor[CURSORS]; static DWORD __far beginWaitTime; static HTASK __far htaskWait=NULL; static HWND __far hwndDesktop=NULL; static UINT __far timerId=0; #pragma pack(1); struct hookMSG { LPARAM lParam; WPARAM wParam; UINT uMsg; HWND hWnd; }; #pragma pack(); LRESULT CALLBACK MyCallWndProc(int code, WPARAM wParam, LPARAM lParam) { 0000 long far MyCallWndProc( int, int unsigned, long ): 0000 1e push ds 0001 58 pop ax 0002 90 nop 0003 45 inc bp 0004 55 push bp 0005 89 e5 mov bp,sp 0007 1e push ds 0008 8e d8 mov ds,ax 000a 56 push si 000b 57 push di 000c 83 ec 02 sub sp,0002H 000f 8b 7e 06 mov di,+6H[bp] if(code>=0) { hookMSG __far *msgp = (hookMSG __far *)lParam; if(msgp->uMsg==WM_SETCURSOR && (LOWORD(msgp->lParam)==HTCLIENT || LOWORD(msgp->lParam)==HTCAPTION) && GetCapture()==NULL && 0012 83 7e 0c 00 cmp word ptr +0cH[bp],0000H 0016 0f 8c a2 00 jl L2 001a 8b 46 08 mov ax,+8H[bp] GetWindowTask(msgp->hWnd)==htaskWait && msgp->hWnd!=hwndDesktop) { 001d 8e c0 mov es,ax 001f 89 fe mov si,di 0021 26 8b 5d 06 mov bx,es:+6H[di] 0025 89 46 f8 mov -8H[bp],ax 0028 83 fb 20 cmp bx,0020H 002b 0f 85 8d 00 jne L2 002f 26 8b 0d mov cx,es:[di] 0032 83 f9 01 cmp cx,0001H 0035 74 07 je L1 0037 83 f9 02 cmp cx,0002H 003a 0f 85 7e 00 jne L2 003e 9a 00 00 00 00 L1 call far GETCAPTURE 0043 85 c0 test ax,ax 0045 75 75 jne L2 0047 8e 46 f8 mov es,-8H[bp] 004a 26 8b 54 08 mov dx,es:+8H[si] 004e 52 push dx 004f 9a 00 00 00 00 call far GETWINDOWTASK 0054 ba 00 00 mov dx,seg int unsigned far htaskWait 0057 8e c2 mov es,dx 0059 26 3b 06 00 00 cmp ax,es:int unsigned far htaskWait 005e 75 5c jne L2 0060 8e 46 f8 mov es,-8H[bp] 0063 26 8b 44 08 mov ax,es:+8H[si] 0067 8e c2 mov es,dx 0069 26 3b 06 00 00 cmp ax,es:int unsigned far hwndDesktop 006e 74 4c je L2 0070 bf 00 00 mov di,seg long unsigned far beginWaitTime int ci=((int)((GetTickCount()-beginWaitTime)/ANIMATIONSPEED))%CURSORS; 0073 9a 00 00 00 00 call far GETTICKCOUNT 0078 8e c7 mov es,di 007a 26 8b 3e 00 00 mov di,es:long unsigned far beginWaitTime 007f 26 8b 1e 02 00 mov bx,es:long unsigned far beginWaitTime+2H 0084 26 29 f8 sub ax,di 0087 26 19 da sbb dx,bx 008a b1 09 mov cl,09H 008c d3 e8 shr ax,cl 008e d3 ca ror dx,cl 0090 31 d0 xor ax,dx 0092 81 e2 7f 00 and dx,007fH 0096 31 d0 xor ax,dx 0098 bf 12 00 mov di,0012H 009b 99 cwd 009c f7 ff idiv di SetCursor(hWaitCursor[ci]); 009e 89 d7 mov di,dx 00a0 01 d7 add di,dx 00a2 26 8b 8d 00 00 mov cx,es:int unsigned far hWaitCursor[][di] 00a7 51 push cx 00a8 9a 00 00 00 00 call far SETCURSOR msgp->uMsg = WM_NULL; 00ad 8e 46 f8 mov es,-8H[bp] return 0; } } 00b0 31 c0 xor ax,ax 00b2 31 d2 xor dx,dx 00b4 26 c7 44 06 00 00 mov word ptr es:+6H[si],0000H 00ba eb 24 jmp L3 return CallNextHookEx(hook,code,wParam,lParam); 00bc b8 00 00 L2 mov ax,seg long unsigned far hook 00bf 8e c0 mov es,ax 00c1 26 8b 36 02 00 mov si,es:long unsigned far hook+2H 00c6 26 56 push si 00c8 26 a1 00 00 mov ax,es:long unsigned far hook 00cc 26 50 push ax 00ce 8b 56 0c mov dx,+0cH[bp] 00d1 52 push dx 00d2 8b 5e 0a mov bx,+0aH[bp] 00d5 53 push bx 00d6 8b 4e 08 mov cx,+8H[bp] 00d9 51 push cx 00da 57 push di 00db 9a 00 00 00 00 call far CALLNEXTHOOKEX } 00e0 8d 66 fa L3 lea sp,-6H[bp] 00e3 5f pop di 00e4 5e pop si 00e5 1f pop ds 00e6 5d pop bp 00e7 4d dec bp 00e8 ca 08 00 retf 0008H 00eb fc cld void CALLBACK MyTimerProc(HWND, UINT, int, DWORD dwTime) { POINT p; 00ec void far MyTimerProc( int unsigned, int unsigned, int, long unsigned ): 00ec 1e push ds 00ed 58 pop ax 00ee 90 nop 00ef 45 inc bp 00f0 55 push bp 00f1 89 e5 mov bp,sp 00f3 1e push ds 00f4 8e d8 mov ds,ax 00f6 56 push si 00f7 83 ec 04 sub sp,0004H 00fa 16 push ss GetCursorPos(&p); 00fb 8d 56 f8 lea dx,-8H[bp] 00fe 52 push dx 00ff 9a 00 00 00 00 call far GETCURSORPOS HWND hwnd=WindowFromPoint(p); if(GetCapture()==NULL && 0104 8b 56 fa mov dx,-6H[bp] 0107 52 push dx 0108 8b 5e f8 mov bx,-8H[bp] 010b 53 push bx 010c 9a 00 00 00 00 call far WINDOWFROMPOINT 0111 89 c6 mov si,ax GetWindowTask(hwnd)==htaskWait && hwnd!=hwndDesktop) { 0113 9a 00 00 00 00 call far GETCAPTURE 0118 85 c0 test ax,ax 011a 75 52 jne L4 011c 56 push si 011d 9a 00 00 00 00 call far GETWINDOWTASK 0122 ba 00 00 mov dx,seg int unsigned far htaskWait 0125 8e c2 mov es,dx 0127 26 3b 06 00 00 cmp ax,es:int unsigned far htaskWait 012c 75 40 jne L4 012e 26 3b 36 00 00 cmp si,es:int unsigned far hwndDesktop 0133 74 39 je L4 int ci=((int)((dwTime-beginWaitTime)/ANIMATIONSPEED))%CURSORS; 0135 8b 46 06 mov ax,+6H[bp] 0138 26 8b 16 00 00 mov dx,es:long unsigned far beginWaitTime 013d 26 8b 1e 02 00 mov bx,es:long unsigned far beginWaitTime+2H 0142 26 29 d0 sub ax,dx 0145 8b 56 08 mov dx,+8H[bp] 0148 26 19 da sbb dx,bx 014b b1 09 mov cl,09H 014d d3 e8 shr ax,cl 014f d3 ca ror dx,cl 0151 31 d0 xor ax,dx 0153 81 e2 7f 00 and dx,007fH 0157 31 d0 xor ax,dx 0159 be 12 00 mov si,0012H 015c 99 cwd 015d f7 fe idiv si SetCursor(hWaitCursor[ci]); } 015f 89 d6 mov si,dx 0161 01 d6 add si,dx 0163 26 8b 8c 00 00 mov cx,es:int unsigned far hWaitCursor[][si] 0168 51 push cx 0169 9a 00 00 00 00 call far SETCURSOR } 016e 8d 66 fc L4 lea sp,-4H[bp] 0171 5e pop si 0172 1f pop ds 0173 5d pop bp 0174 4d dec bp 0175 ca 0a 00 retf 000aH BOOL CALLBACK __export BeginWaitCursor(void) { 0178 1e BEGINWAITCURSOR push ds 0179 58 pop ax 017a 90 nop 017b 45 inc bp 017c 55 push bp 017d 89 e5 mov bp,sp 017f 1e push ds 0180 8e d8 mov ds,ax if(hook!=NULL) return FALSE; 0182 b8 00 00 mov ax,seg long unsigned far hook 0185 8e c0 mov es,ax 0187 26 a1 02 00 mov ax,es:long unsigned far hook+2H 018b 26 0b 06 00 00 or ax,es:long unsigned far hook 0190 74 04 je L5 0192 31 c0 xor ax,ax 0194 eb 67 jmp L6 htaskWait = GetCurrentTask(); 0196 9a 00 00 00 00 L5 call far GETCURRENTTASK 019b ba 00 00 mov dx,seg int unsigned far htaskWait 019e 8e c2 mov es,dx 01a0 26 a3 00 00 mov es:int unsigned far htaskWait,ax beginWaitTime = GetTickCount(); 01a4 9a 00 00 00 00 call far GETTICKCOUNT hook = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)MyCallWndProc, hinstDLL, NULL ); 01a9 6a 04 push 0004H 01ab bb 00 00 mov bx,seg long unsigned far beginWaitTime 01ae 68 00 00 push seg long far MyCallWndProc( int, int unsigned, long ) 01b1 8e c3 mov es,bx 01b3 68 00 00 push offset long far MyCallWndProc( int, int unsigned, long ) 01b6 26 8b 1e 00 00 mov bx,es:int unsigned far hinstDLL 01bb 26 53 push bx 01bd 26 a3 00 00 mov es:long unsigned far beginWaitTime,ax 01c1 6a 00 push 0000H 01c3 26 89 16 02 00 mov es:long unsigned far beginWaitTime+2H,dx 01c8 9a 00 00 00 00 call far SETWINDOWSHOOKEX 01cd bb 00 00 mov bx,seg long unsigned far hook 01d0 8e c3 mov es,bx 01d2 26 a3 00 00 mov es:long unsigned far hook,ax 01d6 26 89 16 02 00 mov es:long unsigned far hook+2H,dx if(hook==NULL) return FALSE; else { 01db 09 d0 or ax,dx 01dd 74 1e je L6 timerId = SetTimer(NULL,0,ANIMATIONSPEED,(TIMERPROC)MyTimerProc); 01df 6a 00 push 0000H 01e1 6a 00 push 0000H 01e3 68 00 02 push 0200H 01e6 68 00 00 push seg void far MyTimerProc( int unsigned, int unsigned, int, long unsigned ) 01e9 68 00 00 push offset void far MyTimerProc( int unsigned, int unsigned, int, long unsigned ) 01ec 9a 00 00 00 00 call far SETTIMER 01f1 ba 00 00 mov dx,seg int unsigned far timerId 01f4 8e c2 mov es,dx 01f6 26 a3 00 00 mov es:int unsigned far timerId,ax return TRUE; } 01fa b8 01 00 mov ax,0001H } 01fd 1f L6 pop ds 01fe 5d pop bp 01ff 4d dec bp 0200 cb retf 0201 89 c0 mov ax,ax 0203 fc cld BOOL CALLBACK __export EndWaitCursor(void) { 0204 1e ENDWAITCURSOR push ds 0205 58 pop ax 0206 90 nop 0207 45 inc bp 0208 55 push bp 0209 89 e5 mov bp,sp 020b 1e push ds 020c 8e d8 mov ds,ax 020e 56 push si if(timerId) KillTimer(NULL,timerId); 020f b8 00 00 mov ax,seg int unsigned far timerId 0212 8e c0 mov es,ax 0214 26 8b 16 00 00 mov dx,es:int unsigned far timerId 0219 26 85 d2 test dx,dx 021c 74 09 je L7 021e 6a 00 push 0000H 0220 26 52 push dx 0222 9a 00 00 00 00 call far KILLTIMER if(hook==NULL) return FALSE; 0227 b8 00 00 L7 mov ax,seg long unsigned far hook 022a 8e c0 mov es,ax 022c 26 a1 02 00 mov ax,es:long unsigned far hook+2H 0230 26 8b 0e 00 00 mov cx,es:long unsigned far hook 0235 26 09 c8 or ax,cx 0238 74 1f je L8 BOOL rc=UnhookWindowsHookEx(hook); 023a 26 8b 36 02 00 mov si,es:long unsigned far hook+2H 023f 26 56 push si 0241 26 51 push cx 0243 9a 00 00 00 00 call far UNHOOKWINDOWSHOOKEX hook=NULL; return rc; 0248 ba 00 00 mov dx,seg long unsigned far hook 024b 8e c2 mov es,dx 024d 31 d2 xor dx,dx 024f 26 89 16 00 00 mov es:long unsigned far hook,dx 0254 26 89 16 02 00 mov es:long unsigned far hook+2H,dx } 0259 5e L8 pop si 025a 1f pop ds 025b 5d pop bp 025c 4d dec bp 025d cb retf 025e 89 c0 mov ax,ax int CALLBACK LibMain(HINSTANCE hinst, WORD, WORD, LPSTR) { 0260 1e LIBMAIN push ds 0261 58 pop ax 0262 90 nop 0263 45 inc bp 0264 55 push bp 0265 89 e5 mov bp,sp 0267 1e push ds 0268 8e d8 mov ds,ax 026a 56 push si 026b 57 push di hinstDLL=hinst; 026c b8 00 00 mov ax,seg int unsigned far hinstDLL 026f 8e c0 mov es,ax 0271 8b 46 0e mov ax,+0eH[bp] 0274 be 00 00 mov si,seg int unsigned far hwndDesktop 0277 26 a3 00 00 mov es:int unsigned far hinstDLL,ax hwndDesktop=GetDesktopWindow(); 027b 9a 00 00 00 00 call far GETDESKTOPWINDOW 0280 8e c6 mov es,si 0282 31 ff xor di,di 0284 26 a3 00 00 mov es:int unsigned far hwndDesktop,ax for(int i=0; i