4 static char Copyright
[] = "Copyright Martin Ayotte, 1994";
17 static LPWINETASKENTRY lpTaskList
= NULL
;
18 static int nTaskCount
= 0;
21 /**********************************************************************
22 * GetCurrentTask [KERNEL.36]
24 HTASK
GetCurrentTask()
26 LPWINETASKENTRY lpTask
= lpTaskList
;
29 printf("GetCurrentTask() // unix_pid=%08X !\n", pid
);
31 if (lpTask
== NULL
) return 0;
33 if (lpTask
->unix_pid
== pid
) break;
34 if (lpTask
->lpNextTask
== NULL
) return 0;
35 lpTask
= lpTask
->lpNextTask
;
38 printf("GetCurrentTask() returned hTask=%04X !\n", lpTask
->te
.hTask
);
40 return lpTask
->te
.hTask
;
44 /**********************************************************************
45 * GetNumTasks [KERNEL.152]
49 printf("GetNumTasks() returned %d !\n", nTaskCount
);
54 /**********************************************************************
55 * GetWindowTask [USER.224]
57 HTASK
GetWindowTask(HWND hWnd
)
61 LPWINETASKENTRY lpTask
= lpTaskList
;
62 printf("GetWindowTask(%04X) !\n", hWnd
);
63 while (lpTask
!= NULL
) {
64 wptr
= lpTask
->lpWndList
;
67 while (++count
< MAXWIN_PER_TASK
) {
68 printf("GetWindowTask // searching %04X %04X !\n",
69 lpTask
->te
.hTask
, *(wptr
));
70 if (*(wptr
) == hWnd
) {
71 printf("GetWindowTask(%04X) found hTask=%04X !\n",
72 hWnd
, lpTask
->te
.hTask
);
73 return lpTask
->te
.hTask
;
78 lpTask
= lpTask
->lpNextTask
;
84 /**********************************************************************
85 * EnumTaskWindows [USER.225]
87 BOOL
EnumTaskWindows(HANDLE hTask
, FARPROC lpEnumFunc
, LONG lParam
)
92 LPWINETASKENTRY lpTask
= lpTaskList
;
93 printf("EnumTaskWindows(%04X, %08X, %08X) !\n", hTask
, lpEnumFunc
, lParam
);
95 if (lpTask
->te
.hTask
== hTask
) break;
97 printf("EnumTaskWindows // hTask=%04X not found !\n", hTask
);
100 lpTask
= lpTask
->lpNextTask
;
102 printf("EnumTaskWindows // found hTask=%04X !\n", hTask
);
103 wptr
= lpTask
->lpWndList
;
104 if (wptr
== NULL
) return FALSE
;
105 if (lpEnumFunc
== NULL
) return FALSE
;
106 while ((hWnd
= *(wptr
++)) != 0) {
107 if (++count
>= MAXWIN_PER_TASK
) return FALSE
;
108 printf("EnumTaskWindows // hWnd=%04X count=%d !\n", hWnd
, count
);
110 bRet
= (*lpEnumFunc
)(hWnd
, lParam
);
112 bRet
= CallBack16(lpEnumFunc
, 2, 0, (int)hWnd
, 2, (int)lParam
);
114 if (bRet
== 0) break;
120 /**********************************************************************
121 * CreateNewTask [internal]
123 HANDLE
CreateNewTask(HINSTANCE hInst
, HTASK hTaskParent
)
126 LPWINETASKENTRY lpTask
= lpTaskList
;
127 LPWINETASKENTRY lpNewTask
;
128 if (lpTask
!= NULL
) {
130 if (lpTask
->lpNextTask
== NULL
) break;
131 lpTask
= lpTask
->lpNextTask
;
134 hTask
= GlobalAlloc(GMEM_MOVEABLE
, sizeof(WINETASKENTRY
));
135 lpNewTask
= (LPWINETASKENTRY
) GlobalLock(hTask
);
137 printf("CreateNewTask entry allocated %08X\n", lpNewTask
);
139 if (lpNewTask
== NULL
) return 0;
140 if (lpTaskList
== NULL
) {
141 lpTaskList
= lpNewTask
;
142 lpNewTask
->lpPrevTask
= NULL
;
145 lpTask
->lpNextTask
= lpNewTask
;
146 lpTask
->te
.hNext
= lpNewTask
->te
.hTask
;
147 lpNewTask
->lpPrevTask
= lpTask
;
149 lpNewTask
->lpNextTask
= NULL
;
150 lpNewTask
->hIcon
= 0;
151 lpNewTask
->te
.dwSize
= sizeof(TASKENTRY
);
152 lpNewTask
->te
.hModule
= 0;
153 lpNewTask
->te
.hInst
= hInst
;
154 lpNewTask
->te
.hTask
= hTask
;
155 lpNewTask
->te
.hTaskParent
= hTaskParent
;
156 lpNewTask
->te
.wSS
= 0;
157 lpNewTask
->te
.wSP
= 0;
158 lpNewTask
->te
.wStackTop
= 0;
159 lpNewTask
->te
.wStackMinimum
= 0;
160 lpNewTask
->te
.wStackBottom
= 0;
161 lpNewTask
->te
.wcEvents
= 0;
162 lpNewTask
->te
.hQueue
= 0;
163 sprintf(lpNewTask
->te
.szModule
, "TASK%04X", hInst
);
164 lpNewTask
->te
.wPSPOffset
= 0;
165 lpNewTask
->unix_pid
= getpid();
166 lpNewTask
->lpWndList
= (HWND
*) malloc(MAXWIN_PER_TASK
* sizeof(HWND
));
167 if (lpNewTask
->lpWndList
!= NULL
)
168 memset((LPSTR
)lpNewTask
->lpWndList
, 0, MAXWIN_PER_TASK
* sizeof(HWND
));
170 printf("CreateNewTask // unix_pid=%08X return hTask=%04X\n",
171 lpNewTask
->unix_pid
, hTask
);
179 /**********************************************************************
180 * AddWindowToTask [internal]
182 BOOL
AddWindowToTask(HTASK hTask
, HWND hWnd
)
186 LPWINETASKENTRY lpTask
= lpTaskList
;
188 printf("AddWindowToTask(%04X, %04X); !\n", hTask
, hWnd
);
191 if (lpTask
->te
.hTask
== hTask
) break;
192 if (lpTask
== NULL
) {
193 printf("AddWindowToTask // hTask=%04X not found !\n", hTask
);
196 lpTask
= lpTask
->lpNextTask
;
198 wptr
= lpTask
->lpWndList
;
199 if (wptr
== NULL
) return FALSE
;
200 while (*(wptr
) != 0) {
201 if (++count
>= MAXWIN_PER_TASK
) return FALSE
;
206 printf("AddWindowToTask // window added, count=%d !\n", count
);
212 /**********************************************************************
213 * RemoveWindowFromTask [internal]
215 BOOL
RemoveWindowFromTask(HTASK hTask
, HWND hWnd
)
219 LPWINETASKENTRY lpTask
= lpTaskList
;
221 printf("RemoveWindowToTask(%04X, %04X); !\n", hTask
, hWnd
);
224 if (lpTask
->te
.hTask
== hTask
) break;
225 if (lpTask
== NULL
) {
226 printf("RemoveWindowFromTask // hTask=%04X not found !\n", hTask
);
229 lpTask
= lpTask
->lpNextTask
;
231 wptr
= lpTask
->lpWndList
;
232 if (wptr
== NULL
) return FALSE
;
233 while (*(wptr
) != hWnd
) {
234 if (++count
>= MAXWIN_PER_TASK
) return FALSE
;
237 while (*(wptr
) != 0) {
238 *(wptr
) = *(wptr
+ 1);
239 if (++count
>= MAXWIN_PER_TASK
) return FALSE
;
243 printf("RemoveWindowFromTask // window removed, count=%d !\n", --count
);