2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis
17 static HANDLE32 ProcessHeap
= 0; /* FIXME: should be in process database */
19 /***********************************************************************
20 * ExitProcess (KERNEL32.100)
23 void ExitProcess(DWORD status
)
28 /***********************************************************************
29 * CreateMutexA (KERNEL32.52)
31 HANDLE32
CreateMutexA (SECURITY_ATTRIBUTES
*sa
, BOOL on
, const char *a
)
36 /***********************************************************************
37 * ReleaseMutex (KERNEL32.435)
39 BOOL
ReleaseMutex (HANDLE32 h
)
44 /***********************************************************************
45 * CreateEventA (KERNEL32.43)
47 HANDLE32
CreateEventA (SECURITY_ATTRIBUTES
*sa
, BOOL au
, BOOL on
, const char
52 /***********************************************************************
53 * SetEvent (KERNEL32.487)
55 BOOL
SetEvent (HANDLE32 h
)
59 /***********************************************************************
60 * ResetEvent (KERNEL32.439)
62 BOOL
ResetEvent (HANDLE32 h
)
66 /***********************************************************************
67 * WaitForSingleObject (KERNEL32.561)
69 DWORD
WaitForSingleObject(HANDLE32 h
, DWORD a
)
73 /***********************************************************************
74 * DuplicateHandle (KERNEL32.78)
76 BOOL
DuplicateHandle(HANDLE32 a
, HANDLE32 b
, HANDLE32 c
, HANDLE32
* d
, DWORD e
, BOOL f
, DWORD g
)
81 /***********************************************************************
82 * GetCurrentProcess (KERNEL32.198)
84 HANDLE32
GetCurrentProcess(void)
89 /***********************************************************************
90 * GetProcessHeap (KERNEL32.259)
92 HANDLE32
GetProcessHeap(void)
94 if (!ProcessHeap
) ProcessHeap
= HeapCreate( 0, 0x10000, 0 );
98 /***********************************************************************
99 * LoadLibraryA (KERNEL32.365)
100 * copied from LoadLibrary
101 * This does not currently support built-in libraries
103 HANDLE32
LoadLibraryA(char *libname
)
106 dprintf_module( stddeb
, "LoadLibrary: (%08x) %s\n", (int)libname
, libname
);
107 handle
= LoadModule( libname
, (LPVOID
)-1 );
108 if (handle
== (HANDLE
) -1)
111 strcpy( buffer
, libname
);
112 strcat( buffer
, ".dll" );
113 handle
= LoadModule( buffer
, (LPVOID
)-1 );
115 /* Obtain module handle and call initialization function */
117 if (handle
>= (HANDLE
)32) PE_InitializeDLLs( GetExePtr(handle
));
124 /***********************************************************************
125 * WIN32_GetProcAddress
127 void* WIN32_GetProcAddress(HANDLE32 hModule
, char* function
)
129 dprintf_module( stddeb
, "WIN32_GetProcAddress(%08x,%s)\n",
131 return PE_GetProcAddress(GetExePtr(hModule
),function
);
135 /**********************************************************************
136 * GetProcessAffinityMask
138 BOOL
GetProcessAffinityMask(HANDLE32 hProcess
, LPDWORD lpProcessAffinityMask
,
139 LPDWORD lpSystemAffinityMask
)
141 dprintf_task(stddeb
,"GetProcessAffinityMask(%x,%x,%x)\n",
142 hProcess
,(lpProcessAffinityMask
?*lpProcessAffinityMask
:0),
143 (lpSystemAffinityMask
?*lpSystemAffinityMask
:0));
144 /* It is definitely important for a process to know on what processor
146 if(lpProcessAffinityMask
)
147 *lpProcessAffinityMask
=1;
148 if(lpSystemAffinityMask
)
149 *lpSystemAffinityMask
=1;
153 /**********************************************************************
154 * SetThreadAffinityMask
156 BOOL
SetThreadAffinityMask(HANDLE32 hThread
, DWORD dwThreadAffinityMask
)
158 dprintf_task(stddeb
,"SetThreadAffinityMask(%x,%x)\n",hThread
,
159 dwThreadAffinityMask
);
160 /* FIXME: We let it fail */