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