4 * Copyright 1996, 1998 Alexandre Julliard
26 static void PROCESS_Destroy( K32OBJ
*obj
);
28 const K32OBJ_OPS PROCESS_Ops
=
30 PROCESS_Destroy
/* destroy */
33 static DWORD PROCESS_InitialProcessID
= 0;
34 static PDB32
*PROCESS_PDBList
= NULL
;
35 static DWORD PROCESS_PDBList_Size
= 0;
37 /***********************************************************************
40 PDB32
*PROCESS_Current(void)
42 return THREAD_Current()->process
;
45 /***********************************************************************
48 * FIXME: This works only while running all processes in the same
49 * address space (or, at least, the initial process is mapped
50 * into all address spaces as is KERNEL32 in Windows 95)
53 PDB32
*PROCESS_Initial(void)
55 return PROCESS_IdToPDB( PROCESS_InitialProcessID
);
58 /***********************************************************************
61 * Get a process from a handle, incrementing the PDB refcount.
63 PDB32
*PROCESS_GetPtr( HANDLE32 handle
, DWORD access
, int *server_handle
)
65 return (PDB32
*)HANDLE_GetObjPtr( PROCESS_Current(), handle
,
66 K32OBJ_PROCESS
, access
, server_handle
);
70 /***********************************************************************
73 * Convert a process id to a PDB, making sure it is valid.
75 PDB32
*PROCESS_IdToPDB( DWORD id
)
79 if (!id
) return PROCESS_Current();
80 pdb
= PROCESS_ID_TO_PDB( id
);
81 if (!K32OBJ_IsValid( &pdb
->header
, K32OBJ_PROCESS
))
83 SetLastError( ERROR_INVALID_PARAMETER
);
91 /***********************************************************************
94 * Build the env DB for the initial process
96 static BOOL32
PROCESS_BuildEnvDB( PDB32
*pdb
)
98 /* Allocate the env DB (FIXME: should not be on the system heap) */
100 if (!(pdb
->env_db
= HeapAlloc(SystemHeap
,HEAP_ZERO_MEMORY
,sizeof(ENVDB
))))
102 InitializeCriticalSection( &pdb
->env_db
->section
);
104 /* Allocate startup info */
105 if (!(pdb
->env_db
->startup_info
=
106 HeapAlloc( SystemHeap
, HEAP_ZERO_MEMORY
, sizeof(STARTUPINFO32A
) )))
109 /* Allocate the standard handles */
111 pdb
->env_db
->hStdin
= FILE_DupUnixHandle( 0, GENERIC_READ
);
112 pdb
->env_db
->hStdout
= FILE_DupUnixHandle( 1, GENERIC_WRITE
);
113 pdb
->env_db
->hStderr
= FILE_DupUnixHandle( 2, GENERIC_WRITE
);
115 /* Build the command-line */
117 pdb
->env_db
->cmd_line
= HEAP_strdupA( SystemHeap
, 0, "kernel32" );
119 /* Build the environment strings */
121 return ENV_BuildEnvironment( pdb
);
125 /***********************************************************************
126 * PROCESS_InheritEnvDB
128 static BOOL32
PROCESS_InheritEnvDB( PDB32
*pdb
, LPCSTR cmd_line
, LPCSTR env
,
129 BOOL32 inherit_handles
, STARTUPINFO32A
*startup
)
131 if (!(pdb
->env_db
= HeapAlloc(pdb
->heap
, HEAP_ZERO_MEMORY
, sizeof(ENVDB
))))
133 InitializeCriticalSection( &pdb
->env_db
->section
);
135 /* Copy the parent environment */
137 if (!ENV_InheritEnvironment( pdb
, env
)) return FALSE
;
139 /* Copy the command line */
141 if (!(pdb
->env_db
->cmd_line
= HEAP_strdupA( pdb
->heap
, 0, cmd_line
)))
144 /* Remember startup info */
145 if (!(pdb
->env_db
->startup_info
=
146 HeapAlloc( pdb
->heap
, HEAP_ZERO_MEMORY
, sizeof(STARTUPINFO32A
) )))
148 *pdb
->env_db
->startup_info
= *startup
;
150 /* Inherit the standard handles */
151 if (pdb
->env_db
->startup_info
->dwFlags
& STARTF_USESTDHANDLES
)
153 pdb
->env_db
->hStdin
= pdb
->env_db
->startup_info
->hStdInput
;
154 pdb
->env_db
->hStdout
= pdb
->env_db
->startup_info
->hStdOutput
;
155 pdb
->env_db
->hStderr
= pdb
->env_db
->startup_info
->hStdError
;
157 else if (inherit_handles
)
159 pdb
->env_db
->hStdin
= pdb
->parent
->env_db
->hStdin
;
160 pdb
->env_db
->hStdout
= pdb
->parent
->env_db
->hStdout
;
161 pdb
->env_db
->hStderr
= pdb
->parent
->env_db
->hStderr
;
163 /* else will be done later on in PROCESS_Create */
168 /***********************************************************************
169 * PROCESS_PDBList_Insert
170 * Insert this PDB into the global PDB list
173 static void PROCESS_PDBList_Insert (PDB32
*pdb
)
175 TRACE (process
, "Inserting PDB 0x%0lx, #%ld current\n",
176 PDB_TO_PROCESS_ID (pdb
), PROCESS_PDBList_Size
);
178 SYSTEM_LOCK (); /* FIXME: Do I need to worry about this ?
179 * I.e., could more than one process be
182 if (PROCESS_PDBList
== NULL
)
184 PROCESS_PDBList
= pdb
;
185 pdb
->list_next
= NULL
;
186 pdb
->list_prev
= NULL
;
190 PDB32
*first
= PROCESS_PDBList
, *last
= PROCESS_PDBList
;
191 if (first
->list_prev
) last
= first
->list_prev
;
193 PROCESS_PDBList
= pdb
;
194 pdb
->list_next
= first
;
195 pdb
->list_prev
= last
;
196 last
->list_next
= pdb
;
197 first
->list_prev
= pdb
;
199 PROCESS_PDBList_Size
++;
203 /***********************************************************************
204 * PROCESS_PDBList_Remove
205 * Remove this PDB from the global PDB list
208 static void PROCESS_PDBList_Remove (PDB32
*pdb
)
210 PDB32
*next
= pdb
->list_next
, *prev
= pdb
->list_prev
;
212 TRACE (process
, "Removing PDB 0x%0lx, #%ld current\n",
213 PDB_TO_PROCESS_ID (pdb
), PROCESS_PDBList_Size
);
219 next
->list_prev
= NULL
;
220 next
->list_next
= NULL
;
224 if (next
) next
->list_prev
= prev
;
225 if (prev
) prev
->list_next
= next
;
228 if (pdb
== PROCESS_PDBList
)
230 PROCESS_PDBList
= next
? next
: prev
;
232 PROCESS_PDBList_Size
--;
237 /***********************************************************************
238 * PROCESS_PDBList_Getsize
239 * Return the number of items in the global PDB list
242 int PROCESS_PDBList_Getsize ()
244 return PROCESS_PDBList_Size
;
247 /***********************************************************************
248 * PROCESS_PDBList_Getfirst
249 * Return the head of the PDB list
252 PDB32
* PROCESS_PDBList_Getfirst ()
254 return PROCESS_PDBList
;
257 /***********************************************************************
258 * PROCESS_PDBList_Getnext
259 * Return the "next" pdb as referenced from the argument.
260 * If at the end of the list, return NULL.
263 PDB32
* PROCESS_PDBList_Getnext (PDB32
*pdb
)
265 return (pdb
->list_next
!= PROCESS_PDBList
) ? pdb
->list_next
: NULL
;
268 /***********************************************************************
271 * Free a PDB and all associated storage.
273 static void PROCESS_FreePDB( PDB32
*pdb
)
277 * If this routine is called because PROCESS_CreatePDB fails, the
278 * following call to PROCESS_PDBList_Remove will probably screw
281 PROCESS_PDBList_Remove (pdb
);
282 pdb
->header
.type
= K32OBJ_UNKNOWN
;
283 if (pdb
->handle_table
) HANDLE_CloseAll( pdb
, NULL
);
284 ENV_FreeEnvironment( pdb
);
285 if (pdb
->heap
&& (pdb
->heap
!= pdb
->system_heap
)) HeapDestroy( pdb
->heap
);
286 DeleteCriticalSection( &pdb
->crit_section
);
287 HeapFree( SystemHeap
, 0, pdb
);
291 /***********************************************************************
294 * Allocate and fill a PDB structure.
295 * Runs in the context of the parent process.
297 static PDB32
*PROCESS_CreatePDB( PDB32
*parent
, BOOL32 inherit
)
299 PDB32
*pdb
= HeapAlloc( SystemHeap
, HEAP_ZERO_MEMORY
, sizeof(PDB32
) );
301 if (!pdb
) return NULL
;
302 pdb
->header
.type
= K32OBJ_PROCESS
;
303 pdb
->header
.refcount
= 1;
304 pdb
->exit_code
= 0x103; /* STILL_ACTIVE */
306 pdb
->running_threads
= 1;
307 pdb
->ring0_threads
= 1;
308 pdb
->system_heap
= SystemHeap
;
309 pdb
->parent
= parent
;
311 pdb
->priority
= 8; /* Normal */
312 pdb
->heap
= pdb
->system_heap
; /* will be changed later on */
314 /* Create the handle table */
316 if (!HANDLE_CreateTable( pdb
, inherit
)) goto error
;
318 PROCESS_PDBList_Insert (pdb
);
322 PROCESS_FreePDB( pdb
);
327 /***********************************************************************
328 * PROCESS_FinishCreatePDB
330 * Second part of CreatePDB
332 static BOOL32
PROCESS_FinishCreatePDB( PDB32
*pdb
)
334 InitializeCriticalSection( &pdb
->crit_section
);
335 /* Allocate the event */
336 if (!(pdb
->load_done_evt
= CreateEvent32A( NULL
, TRUE
, FALSE
, NULL
)))
342 /***********************************************************************
345 BOOL32
PROCESS_Init(void)
350 /* Initialize virtual memory management */
351 if (!VIRTUAL_Init()) return FALSE
;
353 /* Create the system heaps */
354 if (!(SystemHeap
= HeapCreate( HEAP_GROWABLE
, 0x10000, 0 ))) return FALSE
;
356 /* Create the initial process and thread structures */
357 if (!(pdb
= PROCESS_CreatePDB( NULL
, FALSE
))) return FALSE
;
358 if (!(thdb
= THREAD_Create( pdb
, 0, FALSE
, NULL
, NULL
, NULL
, NULL
))) return FALSE
;
359 thdb
->unix_pid
= getpid();
361 PROCESS_InitialProcessID
= PDB_TO_PROCESS_ID(pdb
);
363 /* Remember TEB selector of initial process for emergency use */
364 SYSLEVEL_EmergencyTeb
= thdb
->teb_sel
;
366 /* Create the environment DB of the first process */
367 if (!PROCESS_BuildEnvDB( pdb
)) return FALSE
;
369 /* Initialize the first thread */
370 if (CLIENT_InitThread()) return FALSE
;
371 if (!PROCESS_FinishCreatePDB( pdb
)) return FALSE
;
373 /* Create the SEGPTR heap */
374 if (!(SegptrHeap
= HeapCreate( HEAP_WINE_SEGPTR
, 0, 0 ))) return FALSE
;
380 /***********************************************************************
383 * Create a new process database and associated info.
385 PDB32
*PROCESS_Create( NE_MODULE
*pModule
, LPCSTR cmd_line
, LPCSTR env
,
386 HINSTANCE16 hInstance
, HINSTANCE16 hPrevInstance
,
387 BOOL32 inherit
, STARTUPINFO32A
*startup
,
388 PROCESS_INFORMATION
*info
)
391 int server_thandle
, server_phandle
;
394 PDB32
*parent
= PROCESS_Current();
395 PDB32
*pdb
= PROCESS_CreatePDB( parent
, inherit
);
398 if (!pdb
) return NULL
;
399 info
->hThread
= info
->hProcess
= INVALID_HANDLE_VALUE32
;
400 if (!PROCESS_FinishCreatePDB( pdb
)) goto error
;
402 /* Create the heap */
404 if (pModule
->module32
)
406 size
= PE_HEADER(pModule
->module32
)->OptionalHeader
.SizeOfHeapReserve
;
407 commit
= PE_HEADER(pModule
->module32
)->OptionalHeader
.SizeOfHeapCommit
;
413 pdb
->flags
|= PDB32_WIN16_PROC
; /* This is a Win16 process */
415 if (!(pdb
->heap
= HeapCreate( HEAP_GROWABLE
, size
, commit
))) goto error
;
416 pdb
->heap_list
= pdb
->heap
;
418 /* Inherit the env DB from the parent */
420 if (!PROCESS_InheritEnvDB( pdb
, cmd_line
, env
, inherit
, startup
)) goto error
;
422 /* Create the main thread */
424 if (pModule
->module32
)
425 size
= PE_HEADER(pModule
->module32
)->OptionalHeader
.SizeOfStackReserve
;
428 if (!(thdb
= THREAD_Create( pdb
, size
, FALSE
, &server_thandle
, &server_phandle
,
429 NULL
, NULL
))) goto error
;
430 if ((info
->hThread
= HANDLE_Alloc( parent
, &thdb
->header
, THREAD_ALL_ACCESS
,
431 FALSE
, server_thandle
)) == INVALID_HANDLE_VALUE32
)
433 if ((info
->hProcess
= HANDLE_Alloc( parent
, &pdb
->header
, PROCESS_ALL_ACCESS
,
434 FALSE
, server_phandle
)) == INVALID_HANDLE_VALUE32
)
436 info
->dwProcessId
= PDB_TO_PROCESS_ID(pdb
);
437 info
->dwThreadId
= THDB_TO_THREAD_ID(thdb
);
440 thdb
->unix_pid
= getpid(); /* FIXME: wrong here ... */
442 /* All Win16 'threads' have the same unix_pid, no matter by which thread
443 they were created ! */
444 pTask
= (TDB
*)GlobalLock16( parent
->task
);
445 thdb
->unix_pid
= pTask
? pTask
->thdb
->unix_pid
: THREAD_Current()->unix_pid
;
448 /* Duplicate the standard handles */
450 if ((!(pdb
->env_db
->startup_info
->dwFlags
& STARTF_USESTDHANDLES
)) && !inherit
)
452 DuplicateHandle( GetCurrentProcess(), pdb
->parent
->env_db
->hStdin
,
453 info
->hProcess
, &pdb
->env_db
->hStdin
, 0, TRUE
, DUPLICATE_SAME_ACCESS
);
454 DuplicateHandle( GetCurrentProcess(), pdb
->parent
->env_db
->hStdout
,
455 info
->hProcess
, &pdb
->env_db
->hStdout
, 0, TRUE
, DUPLICATE_SAME_ACCESS
);
456 DuplicateHandle( GetCurrentProcess(), pdb
->parent
->env_db
->hStderr
,
457 info
->hProcess
, &pdb
->env_db
->hStderr
, 0, TRUE
, DUPLICATE_SAME_ACCESS
);
460 /* Create a Win16 task for this process */
462 if (startup
->dwFlags
& STARTF_USESHOWWINDOW
)
463 cmdShow
= startup
->wShowWindow
;
465 pdb
->task
= TASK_Create( thdb
, pModule
, hInstance
, hPrevInstance
, cmdShow
);
466 if (!pdb
->task
) goto error
;
469 /* Map system DLLs into this process (from initial process) */
470 /* FIXME: this is a hack */
471 pdb
->modref_list
= PROCESS_Initial()->modref_list
;
477 if (info
->hThread
!= INVALID_HANDLE_VALUE32
) CloseHandle( info
->hThread
);
478 if (info
->hProcess
!= INVALID_HANDLE_VALUE32
) CloseHandle( info
->hProcess
);
479 if (thdb
) K32OBJ_DecCount( &thdb
->header
);
480 PROCESS_FreePDB( pdb
);
485 /***********************************************************************
488 static void PROCESS_Destroy( K32OBJ
*ptr
)
490 PDB32
*pdb
= (PDB32
*)ptr
;
491 assert( ptr
->type
== K32OBJ_PROCESS
);
493 /* Free everything */
495 ptr
->type
= K32OBJ_UNKNOWN
;
496 PROCESS_FreePDB( pdb
);
500 /***********************************************************************
501 * ExitProcess (KERNEL32.100)
503 void WINAPI
ExitProcess( DWORD status
)
505 PDB32
*pdb
= PROCESS_Current();
506 TDB
*pTask
= (TDB
*)GlobalLock16( pdb
->task
);
507 if ( pTask
) pTask
->nEvents
++;
509 if ( pTask
&& pTask
->thdb
!= THREAD_Current() )
510 ExitThread( status
);
513 /* FIXME: should kill all running threads of this process */
514 pdb
->exit_code
= status
;
515 if (pdb
->console
) FreeConsole();
518 __RESTORE_ES
; /* Necessary for Pietrek's showseh example program */
519 TASK_KillCurrentTask( status
);
523 /******************************************************************************
524 * TerminateProcess (KERNEL32.684)
526 BOOL32 WINAPI
TerminateProcess( HANDLE32 handle
, DWORD exit_code
)
528 struct terminate_process_request req
;
530 req
.handle
= HANDLE_GetServerHandle( PROCESS_Current(), handle
,
531 K32OBJ_PROCESS
, PROCESS_TERMINATE
);
532 req
.exit_code
= exit_code
;
533 CLIENT_SendRequest( REQ_TERMINATE_PROCESS
, -1, 1, &req
, sizeof(req
) );
534 return !CLIENT_WaitReply( NULL
, NULL
, 0 );
537 /***********************************************************************
538 * GetCurrentProcess (KERNEL32.198)
540 HANDLE32 WINAPI
GetCurrentProcess(void)
542 return CURRENT_PROCESS_PSEUDOHANDLE
;
546 /*********************************************************************
547 * OpenProcess (KERNEL32.543)
549 HANDLE32 WINAPI
OpenProcess( DWORD access
, BOOL32 inherit
, DWORD id
)
552 PDB32
*pdb
= PROCESS_ID_TO_PDB(id
);
553 if (!K32OBJ_IsValid( &pdb
->header
, K32OBJ_PROCESS
))
555 SetLastError( ERROR_INVALID_HANDLE
);
558 if ((server_handle
= CLIENT_OpenProcess( pdb
->server_pid
, access
, inherit
)) == -1)
560 SetLastError( ERROR_INVALID_HANDLE
);
563 return HANDLE_Alloc( PROCESS_Current(), &pdb
->header
, access
,
564 inherit
, server_handle
);
568 /***********************************************************************
569 * GetCurrentProcessId (KERNEL32.199)
571 DWORD WINAPI
GetCurrentProcessId(void)
573 PDB32
*pdb
= PROCESS_Current();
574 return PDB_TO_PROCESS_ID( pdb
);
578 /***********************************************************************
579 * GetProcessHeap (KERNEL32.259)
581 HANDLE32 WINAPI
GetProcessHeap(void)
583 PDB32
*pdb
= PROCESS_Current();
584 return pdb
->heap
? pdb
->heap
: SystemHeap
;
588 /***********************************************************************
589 * GetThreadLocale (KERNEL32.295)
591 LCID WINAPI
GetThreadLocale(void)
593 return PROCESS_Current()->locale
;
597 /***********************************************************************
598 * SetPriorityClass (KERNEL32.503)
600 BOOL32 WINAPI
SetPriorityClass( HANDLE32 hprocess
, DWORD priorityclass
)
602 PDB32
*pdb
= PROCESS_GetPtr( hprocess
, PROCESS_SET_INFORMATION
, NULL
);
603 if (!pdb
) return FALSE
;
604 switch (priorityclass
)
606 case NORMAL_PRIORITY_CLASS
:
607 pdb
->priority
= 0x00000008;
609 case IDLE_PRIORITY_CLASS
:
610 pdb
->priority
= 0x00000004;
612 case HIGH_PRIORITY_CLASS
:
613 pdb
->priority
= 0x0000000d;
615 case REALTIME_PRIORITY_CLASS
:
616 pdb
->priority
= 0x00000018;
619 WARN(process
,"Unknown priority class %ld\n",priorityclass
);
622 K32OBJ_DecCount( &pdb
->header
);
627 /***********************************************************************
628 * GetPriorityClass (KERNEL32.250)
630 DWORD WINAPI
GetPriorityClass(HANDLE32 hprocess
)
632 PDB32
*pdb
= PROCESS_GetPtr( hprocess
, PROCESS_QUERY_INFORMATION
, NULL
);
636 switch (pdb
->priority
)
639 ret
= NORMAL_PRIORITY_CLASS
;
642 ret
= IDLE_PRIORITY_CLASS
;
645 ret
= HIGH_PRIORITY_CLASS
;
648 ret
= REALTIME_PRIORITY_CLASS
;
651 WARN(process
,"Unknown priority %ld\n",pdb
->priority
);
653 K32OBJ_DecCount( &pdb
->header
);
659 /***********************************************************************
660 * GetStdHandle (KERNEL32.276)
662 HANDLE32 WINAPI
GetStdHandle( DWORD std_handle
)
664 PDB32
*pdb
= PROCESS_Current();
668 case STD_INPUT_HANDLE
: return pdb
->env_db
->hStdin
;
669 case STD_OUTPUT_HANDLE
: return pdb
->env_db
->hStdout
;
670 case STD_ERROR_HANDLE
: return pdb
->env_db
->hStderr
;
672 SetLastError( ERROR_INVALID_PARAMETER
);
673 return INVALID_HANDLE_VALUE32
;
677 /***********************************************************************
678 * SetStdHandle (KERNEL32.506)
680 BOOL32 WINAPI
SetStdHandle( DWORD std_handle
, HANDLE32 handle
)
682 PDB32
*pdb
= PROCESS_Current();
683 /* FIXME: should we close the previous handle? */
686 case STD_INPUT_HANDLE
:
687 pdb
->env_db
->hStdin
= handle
;
689 case STD_OUTPUT_HANDLE
:
690 pdb
->env_db
->hStdout
= handle
;
692 case STD_ERROR_HANDLE
:
693 pdb
->env_db
->hStderr
= handle
;
696 SetLastError( ERROR_INVALID_PARAMETER
);
700 /***********************************************************************
701 * GetProcessVersion (KERNEL32)
703 DWORD WINAPI
GetProcessVersion( DWORD processid
)
706 PDB32
*pdb
= PROCESS_IdToPDB( processid
);
709 if (!(pTask
= (TDB
*)GlobalLock16( pdb
->task
))) return 0;
710 return (pTask
->version
&0xff) | (((pTask
->version
>>8) & 0xff)<<16);
713 /***********************************************************************
714 * GetProcessFlags (KERNEL32)
716 DWORD WINAPI
GetProcessFlags( DWORD processid
)
718 PDB32
*pdb
= PROCESS_IdToPDB( processid
);
723 /***********************************************************************
724 * SetProcessWorkingSetSize [KERNEL32.662]
725 * Sets the min/max working set sizes for a specified process.
728 * hProcess [I] Handle to the process of interest
729 * minset [I] Specifies minimum working set size
730 * maxset [I] Specifies maximum working set size
734 BOOL32 WINAPI
SetProcessWorkingSetSize(HANDLE32 hProcess
,DWORD minset
,
737 FIXME(process
,"(0x%08x,%ld,%ld): stub - harmless\n",hProcess
,minset
,maxset
);
738 if(( minset
== -1) && (maxset
== -1)) {
739 /* Trim the working set to zero */
740 /* Swap the process out of physical RAM */
745 /***********************************************************************
746 * GetProcessWorkingSetSize (KERNEL32)
748 BOOL32 WINAPI
GetProcessWorkingSetSize(HANDLE32 hProcess
,LPDWORD minset
,
751 FIXME(process
,"(0x%08x,%p,%p): stub\n",hProcess
,minset
,maxset
);
752 /* 32 MB working set size */
753 if (minset
) *minset
= 32*1024*1024;
754 if (maxset
) *maxset
= 32*1024*1024;
758 /***********************************************************************
759 * SetProcessShutdownParameters (KERNEL32)
761 * CHANGED - James Sutherland (JamesSutherland@gmx.de)
762 * Now tracks changes made (but does not act on these changes)
763 * NOTE: the definition for SHUTDOWN_NORETRY was done on guesswork.
764 * It really shouldn't be here, but I'll move it when it's been checked!
766 #define SHUTDOWN_NORETRY 1
767 static unsigned int shutdown_noretry
= 0;
768 static unsigned int shutdown_priority
= 0x280L
;
769 BOOL32 WINAPI
SetProcessShutdownParameters(DWORD level
,DWORD flags
)
771 if (flags
& SHUTDOWN_NORETRY
)
772 shutdown_noretry
= 1;
774 shutdown_noretry
= 0;
775 if (level
> 0x100L
&& level
< 0x3FFL
)
776 shutdown_priority
= level
;
779 ERR(process
,"invalid priority level 0x%08lx\n", level
);
786 /***********************************************************************
787 * GetProcessShutdownParameters (KERNEL32)
790 BOOL32 WINAPI
GetProcessShutdownParameters( LPDWORD lpdwLevel
,
793 (*lpdwLevel
) = shutdown_priority
;
794 (*lpdwFlags
) = (shutdown_noretry
* SHUTDOWN_NORETRY
);
797 /***********************************************************************
798 * SetProcessPriorityBoost (KERNEL32)
800 BOOL32 WINAPI
SetProcessPriorityBoost(HANDLE32 hprocess
,BOOL32 disableboost
)
802 FIXME(process
,"(%d,%d): stub\n",hprocess
,disableboost
);
803 /* Say we can do it. I doubt the program will notice that we don't. */
807 /***********************************************************************
808 * ReadProcessMemory (KERNEL32)
809 * FIXME: check this, if we ever run win32 binaries in different addressspaces
810 * ... and add a sizecheck
812 BOOL32 WINAPI
ReadProcessMemory( HANDLE32 hProcess
, LPCVOID lpBaseAddress
,
813 LPVOID lpBuffer
, DWORD nSize
,
814 LPDWORD lpNumberOfBytesRead
)
816 memcpy(lpBuffer
,lpBaseAddress
,nSize
);
817 if (lpNumberOfBytesRead
) *lpNumberOfBytesRead
= nSize
;
821 /***********************************************************************
822 * WriteProcessMemory (KERNEL32)
823 * FIXME: check this, if we ever run win32 binaries in different addressspaces
824 * ... and add a sizecheck
826 BOOL32 WINAPI
WriteProcessMemory(HANDLE32 hProcess
, LPVOID lpBaseAddress
,
827 LPVOID lpBuffer
, DWORD nSize
,
828 LPDWORD lpNumberOfBytesWritten
)
830 memcpy(lpBaseAddress
,lpBuffer
,nSize
);
831 if (lpNumberOfBytesWritten
) *lpNumberOfBytesWritten
= nSize
;
835 /***********************************************************************
836 * RegisterServiceProcess (KERNEL, KERNEL32)
838 * A service process calls this function to ensure that it continues to run
839 * even after a user logged off.
841 DWORD WINAPI
RegisterServiceProcess(DWORD dwProcessId
, DWORD dwType
)
843 /* I don't think that Wine needs to do anything in that function */
844 return 1; /* success */
847 /***********************************************************************
848 * GetExitCodeProcess [KERNEL32.325]
850 * Gets termination status of specified process
856 BOOL32 WINAPI
GetExitCodeProcess(
857 HANDLE32 hProcess
, /* [I] handle to the process */
858 LPDWORD lpExitCode
) /* [O] address to receive termination status */
860 struct get_process_info_reply reply
;
861 int handle
= HANDLE_GetServerHandle( PROCESS_Current(), hProcess
,
862 K32OBJ_PROCESS
, PROCESS_QUERY_INFORMATION
);
864 CLIENT_SendRequest( REQ_GET_PROCESS_INFO
, -1, 1, &handle
, sizeof(handle
) );
865 if (CLIENT_WaitSimpleReply( &reply
, sizeof(reply
), NULL
)) return FALSE
;
866 if (lpExitCode
) *lpExitCode
= reply
.exit_code
;
870 /***********************************************************************
871 * GetProcessHeaps [KERNEL32.376]
873 DWORD WINAPI
GetProcessHeaps(DWORD nrofheaps
,HANDLE32
*heaps
) {
874 FIXME(win32
,"(%ld,%p), incomplete implementation.\n",nrofheaps
,heaps
);
877 heaps
[0] = GetProcessHeap();
878 /* ... probably SystemHeap too ? */
881 /* number of available heaps */
885 /***********************************************************************
886 * PROCESS_SuspendOtherThreads
889 void PROCESS_SuspendOtherThreads(void)
896 pdb
= PROCESS_Current();
897 entry
= pdb
->thread_list
->next
;
900 if (entry
->thread
!= THREAD_Current() && !THREAD_IsWin16(entry
->thread
))
902 HANDLE32 handle
= HANDLE_Alloc( PROCESS_Current(),
903 &entry
->thread
->header
,
904 THREAD_ALL_ACCESS
, FALSE
, -1 );
905 SuspendThread(handle
);
908 if (entry
== pdb
->thread_list
) break;
915 /***********************************************************************
916 * PROCESS_ResumeOtherThreads
919 void PROCESS_ResumeOtherThreads(void)
926 pdb
= PROCESS_Current();
927 entry
= pdb
->thread_list
->next
;
930 if (entry
->thread
!= THREAD_Current() && !THREAD_IsWin16(entry
->thread
))
932 HANDLE32 handle
= HANDLE_Alloc( PROCESS_Current(),
933 &entry
->thread
->header
,
934 THREAD_ALL_ACCESS
, FALSE
, -1 );
935 ResumeThread(handle
);
938 if (entry
== pdb
->thread_list
) break;