Release 980329
[wine] / win32 / process.c
1 /*
2  * Win32 kernel functions
3  *
4  * Copyright 1995 Martin von Loewis
5  */
6
7 #include <stdio.h>
8 #include <string.h>
9 #include <unistd.h>
10 #include <sys/times.h>
11 #include "windows.h"
12 #include "winerror.h"
13 #include "heap.h"
14 #include "thread.h"
15 #include "process.h"
16 #include "pe_image.h"
17 #include "file.h"
18 #include "debug.h"
19
20
21 /***********************************************************************
22  *           MsgWaitForMultipleObjects    (USER32.399)
23  */
24 DWORD WINAPI MsgWaitForMultipleObjects(
25         DWORD nCount,HANDLE32 *pHandles,BOOL32 fWaitAll,DWORD dwMilliseconds,
26         DWORD dwWakeMask
27 ) {
28         int     i;
29         fprintf(stderr,"MsgWaitForMultipleObjects(%ld,[",nCount);
30         for (i=0;i<nCount;i++)
31                 fprintf(stderr,"%ld,",(DWORD)pHandles[i]);
32         fprintf(stderr,"],%d,%ld,0x%08lx)\n",fWaitAll,dwMilliseconds,dwWakeMask);
33         return 0;
34 }
35
36 /***********************************************************************
37  *           DuplicateHandle    (KERNEL32.78)
38  */
39 BOOL32 WINAPI DuplicateHandle(HANDLE32 a, HANDLE32 b, HANDLE32 c, HANDLE32 * d, DWORD e, BOOL32 f, DWORD g)
40 {
41         fprintf(stderr,"DuplicateHandle(%d,%d,%d,%p,%ld,%d,%ld) stub\n",a,b,c,d,e,f,g);
42         *d = b;
43         return TRUE;
44 }
45
46 /**********************************************************************
47  *          GetProcessAffinityMask
48  */
49 BOOL32 WINAPI GetProcessAffinityMask(HANDLE32 hProcess,
50                                      LPDWORD lpProcessAffinityMask,
51                                      LPDWORD lpSystemAffinityMask)
52 {
53         TRACE(task,"(%x,%lx,%lx)\n",
54                 hProcess,(lpProcessAffinityMask?*lpProcessAffinityMask:0),
55                 (lpSystemAffinityMask?*lpSystemAffinityMask:0));
56         /* It is definitely important for a process to know on what processor
57            it is running :-) */
58         if(lpProcessAffinityMask)
59                 *lpProcessAffinityMask=1;
60         if(lpSystemAffinityMask)
61                 *lpSystemAffinityMask=1;
62         return TRUE;
63 }
64
65 /**********************************************************************
66  *           SetThreadAffinityMask
67  * Works now like the Windows95 (no MP support) version
68  */
69 BOOL32 WINAPI SetThreadAffinityMask(HANDLE32 hThread, DWORD dwThreadAffinityMask)
70 {
71         THDB    *thdb = THREAD_GetPtr( hThread, THREAD_SET_INFORMATION );
72
73         if (!thdb) 
74                 return FALSE;
75         if (dwThreadAffinityMask!=1) {
76                 fprintf(stderr,"SetThreadAffinityMask(%d,%ld), only 1 processor supported.\n",(int)hThread,dwThreadAffinityMask);
77                 K32OBJ_DecCount((K32OBJ*)thdb);
78                 return FALSE;
79         }
80         K32OBJ_DecCount((K32OBJ*)thdb);
81         return TRUE;
82 }
83
84 BOOL32 WINAPI CreateProcess32A(
85         LPCSTR appname,LPSTR cmdline,LPSECURITY_ATTRIBUTES processattributes,
86         LPSECURITY_ATTRIBUTES threadattributes,BOOL32 inherithandles,
87         DWORD creationflags,LPVOID env,LPCSTR curdir,
88         LPSTARTUPINFO32A startupinfo,LPPROCESS_INFORMATION processinfo
89 ) {
90         fprintf(stderr,"CreateProcessA(%s,%s,%p,%p,%d,%08lx,%p,%s,%p,%p), stub\n",
91                 appname,cmdline,processattributes,threadattributes,
92                 inherithandles,creationflags,env,curdir,startupinfo,processinfo
93         );
94         /* make from lcc uses system as fallback if CreateProcess returns
95            FALSE, so return false */
96         return FALSE;
97 }
98
99 BOOL32 WINAPI CreateProcess32W(
100         LPCWSTR appname,LPWSTR cmdline,LPSECURITY_ATTRIBUTES processattributes,
101         LPSECURITY_ATTRIBUTES threadattributes,BOOL32 inherithandles,
102         DWORD creationflags,LPVOID env,LPCWSTR curdir,
103         LPSTARTUPINFO32W startupinfo,LPPROCESS_INFORMATION processinfo)
104 {
105     fprintf(stderr,"CreateProcessW(%p,%p,%p,%p,%d,%08lx,%p,%p,%p,%p) stub\n",
106             appname,cmdline,processattributes,threadattributes,
107             inherithandles,creationflags,env,curdir,startupinfo,processinfo );
108     /* make from lcc uses system as fallback if CreateProcess returns
109        FALSE, so return false */
110     return FALSE;
111 }
112
113 BOOL32 WINAPI ContinueDebugEvent(DWORD pid,DWORD tid,DWORD contstatus) {
114         fprintf(stderr,"ContinueDebugEvent(%ld,%ld,%ld) stub\n",pid,tid,contstatus);
115         return TRUE;
116 }
117
118 /*********************************************************************
119  *      GetProcessTimes                         [KERNEL32.262]
120  *
121  * FIXME: implement this better ...
122  */
123 BOOL32 WINAPI GetProcessTimes(
124         HANDLE32 hprocess,LPFILETIME lpCreationTime,LPFILETIME lpExitTime,
125         LPFILETIME lpKernelTime, LPFILETIME lpUserTime
126 ) {
127         struct tms tms;
128
129         times(&tms);
130         DOSFS_UnixTimeToFileTime(tms.tms_utime,lpUserTime,0);
131         DOSFS_UnixTimeToFileTime(tms.tms_stime,lpKernelTime,0);
132         return TRUE;
133 }
134