source: trunk/src/kernel32/wprocess.cpp@ 1192

Last change on this file since 1192 was 1134, checked in by phaller, 26 years ago

Fix: DisableThreadLibraryCalls added

File size: 22.2 KB
Line 
1/* $Id: wprocess.cpp,v 1.35 1999-10-04 22:25:01 phaller Exp $ */
2
3/*
4 * Win32 process functions
5 *
6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#include <odin.h>
13#include <odinwrap.h>
14#include <os2win.h>
15#include <stdio.h>
16#include <stdlib.h>
17#include <string.h>
18
19#include <unicode.h>
20#include <windllbase.h>
21#include <winexebase.h>
22#include <windllpeldr.h>
23
24#ifdef __IBMCPP__
25#include <builtin.h>
26#endif
27
28#include "exceptutil.h"
29#include "oslibmisc.h"
30
31#include "console.h"
32#include "cio.h"
33#include "versionos2.h" /*PLF Wed 98-03-18 02:36:51*/
34#include <wprocess.h>
35#include "mmap.h"
36
37
38ODINDEBUGCHANNEL(KERNEL32-WPROCESS)
39
40
41//******************************************************************************
42//******************************************************************************
43BOOL fFreeLibrary = FALSE;
44
45//Process database
46PDB ProcessPDB = {0};
47USHORT ProcessTIBSel = 0;
48DWORD *TIBFlatPtr = 0;
49
50extern "C" ULONG QueryExceptionChain();
51
52
53//******************************************************************************
54//******************************************************************************
55TEB *WIN32API GetThreadTEB()
56{
57 return (TEB *)*TIBFlatPtr;
58}
59//******************************************************************************
60//******************************************************************************
61THDB *WIN32API GetThreadTHDB()
62{
63 TEB *winteb;
64 THDB *thdb;
65
66 winteb = (TEB *)*TIBFlatPtr;
67 if(winteb == NULL) {
68 return NULL;
69 }
70 thdb = (THDB *)(winteb+1);
71
72 return thdb;
73}
74//******************************************************************************
75// Set up the TIB selector and memory for the current thread
76//******************************************************************************
77TEB *InitializeTIB(BOOL fMainThread)
78{
79 TEB *winteb;
80 THDB *thdb;
81
82 USHORT tibsel;
83
84 //Allocate one dword to store the flat address of our TEB
85 if(fMainThread) {
86 TIBFlatPtr = (DWORD *)OSLibAllocThreadLocalMemory(1);
87 if(TIBFlatPtr == 0) {
88 dprintf(("InitializeTIB: local thread memory alloc failed!!"));
89 DebugInt3();
90 return NULL;
91 }
92 }
93 if(OSLibAllocSel(PAGE_SIZE, &tibsel) == FALSE)
94 {
95 dprintf(("InitializeTIB: selector alloc failed!!"));
96 DebugInt3();
97 return NULL;
98 }
99 winteb = (TEB *)OSLibSelToFlat(tibsel);
100 if(winteb == NULL)
101 {
102 dprintf(("InitializeTIB: DosSelToFlat failed!!"));
103 DebugInt3();
104 return NULL;
105 }
106 memset(winteb, 0, PAGE_SIZE);
107 thdb = (THDB *)(winteb+1);
108 *TIBFlatPtr = (DWORD)winteb;
109
110 winteb->except = (PVOID)-1; /* 00 Head of exception handling chain */
111 winteb->stack_top = (PVOID)OSLibGetTIB(TIB_STACKTOP); /* 04 Top of thread stack */
112 winteb->stack_low = (PVOID)OSLibGetTIB(TIB_STACKLOW); /* 08 Stack low-water mark */
113 winteb->htask16 = (USHORT)OSLibGetPIB(PIB_TASKHNDL); /* 0c Win16 task handle */
114 winteb->stack_sel = getSS(); /* 0e 16-bit stack selector */
115 winteb->self = winteb; /* 18 Pointer to this structure */
116 winteb->flags = TEBF_WIN32; /* 1c Flags */
117 winteb->queue = 0; /* 28 Message queue */
118 winteb->tls_ptr = &thdb->tls_array[0]; /* 2c Pointer to TLS array */
119 winteb->process = &ProcessPDB; /* 30 owning process (used by NT3.51 applets)*/
120
121 memcpy(&thdb->teb, winteb, sizeof(TEB));
122 thdb->process = &ProcessPDB;
123 thdb->exit_code = 0x103; /* STILL_ACTIVE */
124 thdb->teb_sel = tibsel;
125 thdb->OrgTIBSel = GetFS();
126
127 if(OSLibGetPIB(PIB_TASKTYPE) == TASKTYPE_PM)
128 {
129 thdb->flags = 0; //todo gui
130 }
131 else thdb->flags = 0; //todo textmode
132
133 if(fMainThread)
134 {
135 //todo initialize PDB during process creation
136 //todo: initialize TLS array if required
137 //TLS in executable always TLS index 0?
138 ProcessTIBSel = tibsel;
139 }
140 dprintf(("InitializeTIB setup TEB with selector %x", tibsel));
141 dprintf(("InitializeTIB: FS(%x):[0] = %x", GetFS(), QueryExceptionChain()));
142 return winteb;
143}
144//******************************************************************************
145// Destroy the TIB selector and memory for the current thread
146//******************************************************************************
147void DestroyTIB()
148{
149 SHORT orgtibsel;
150 TEB *winteb;
151 THDB *thdb;
152
153 dprintf(("DestroyTIB: FS = %x", GetFS()));
154 dprintf(("DestroyTIB: FS:[0] = %x", QueryExceptionChain()));
155
156 winteb = (TEB *)*TIBFlatPtr;
157 if(winteb) {
158 thdb = (THDB *)(winteb+1);
159 orgtibsel = thdb->OrgTIBSel;
160
161 //Restore our original FS selector
162 SetFS(orgtibsel);
163
164 //And free our own
165 OSLibFreeSel(thdb->teb_sel);
166 }
167 else dprintf(("Already destroyed TIB"));
168
169 dprintf(("DestroyTIB: FS(%x):[0] = %x", GetFS(), QueryExceptionChain()));
170 *TIBFlatPtr = 0;
171 return;
172}
173/******************************************************************************/
174/******************************************************************************/
175void WIN32API RestoreOS2TIB()
176{
177 SHORT orgtibsel;
178 TEB *winteb;
179 THDB *thdb;
180
181 winteb = (TEB *)*TIBFlatPtr;
182 if(winteb) {
183 thdb = (THDB *)(winteb+1);
184 orgtibsel = thdb->OrgTIBSel;
185
186 //Restore our original FS selector
187 SetFS(orgtibsel);
188 }
189}
190/******************************************************************************/
191/******************************************************************************/
192USHORT WIN32API SetWin32TIB()
193{
194 SHORT win32tibsel;
195 TEB *winteb;
196 THDB *thdb;
197
198 winteb = (TEB *)*TIBFlatPtr;
199 if(winteb) {
200 thdb = (THDB *)(winteb+1);
201 win32tibsel = thdb->teb_sel;
202
203 //Restore our win32 FS selector
204 return SetReturnFS(win32tibsel);
205 }
206 else {
207 //we didn't create this thread, so allocate a selector now
208 //NOTE: Possible memory leak (i.e. DART threads in WINMM)
209 winteb = InitializeTIB();
210 if(winteb == NULL) {
211 DebugInt3();
212 return GetFS();
213 }
214 thdb = (THDB *)(winteb+1);
215 win32tibsel = thdb->teb_sel;
216
217 //Restore our win32 FS selector
218 return SetReturnFS(win32tibsel);
219 }
220 // nested calls are OK, OS2ToWinCallback for instance
221 //else DebugInt3();
222
223 return GetFS();
224}
225//******************************************************************************
226//******************************************************************************
227void _System Win32DllExitList(ULONG reason)
228{
229 dprintf(("Win32DllExitList %d\n", reason));
230
231 if(WinExe) {
232 delete(WinExe);
233 WinExe = NULL;
234 }
235 return;
236}
237//******************************************************************************
238//******************************************************************************
239VOID WIN32API ExitProcess(DWORD exitcode)
240{
241 dprintf(("KERNEL32: ExitProcess %d\n", exitcode));
242 dprintf(("KERNEL32: ExitProcess FS = %x\n", GetFS()));
243
244 SetOS2ExceptionChain(-1);
245
246 //Flush and delete all open memory mapped files
247 Win32MemMap::deleteAll();
248
249 Win32DllExitList(0);
250
251 //Restore original OS/2 TIB selector
252 DestroyTIB();
253 SetExceptionChain((ULONG)-1);
254
255 //avoid crashes since win32 & OS/2 exception handler aren't identical
256 //(terminate process generates two exceptions)
257 /* @@@PH 1998/02/12 Added Console Support */
258 if (iConsoleIsActive())
259 iConsoleWaitClose();
260
261 O32_ExitProcess(exitcode);
262}
263//******************************************************************************
264//******************************************************************************
265BOOL WIN32API FreeLibrary(HINSTANCE hinstance)
266{
267 Win32DllBase *winmod;
268 BOOL rc;
269
270 dprintf(("FreeLibrary"));
271 winmod = Win32DllBase::findModule(hinstance);
272 if(winmod) {
273 winmod->Release();
274 return(TRUE);
275 }
276 dprintf(("KERNEL32: FreeLibrary %s %X\n", OSLibGetDllName(hinstance), hinstance));
277
278 //TODO: Not thread safe
279 fFreeLibrary = TRUE; //ditch dll
280 rc = O32_FreeLibrary(hinstance);
281 fFreeLibrary = FALSE;
282 dprintf(("FreeLibrary returned %X\n", rc));
283 return(TRUE);
284}
285/******************************************************************************/
286/******************************************************************************/
287static HINSTANCE iLoadLibraryA(LPCTSTR lpszLibFile, DWORD dwFlags)
288{
289 char modname[CCHMAXPATH];
290 HINSTANCE hDll;
291 Win32DllBase *module;
292
293 hDll = O32_LoadLibrary(lpszLibFile);
294 dprintf(("KERNEL32: iLoadLibraryA %s returned %X (%d)\n",
295 lpszLibFile,
296 hDll,
297 GetLastError()));
298 if(hDll)
299 {
300 return hDll; //converted dll or win32k took care of it
301 }
302
303 strcpy(modname, lpszLibFile);
304 strupr(modname);
305 if(!strstr(modname, ".DLL")) {
306 strcat(modname,".DLL");
307 }
308
309 if(Win32ImageBase::isPEImage((char *)modname))
310 {
311 module = Win32DllBase::findModule((char *)modname);
312 if(module) {//don't load it again
313 module->AddRef();
314 return module->getInstanceHandle();
315 }
316
317 Win32PeLdrDll *peldrDll = new Win32PeLdrDll((char *)modname);
318 if(peldrDll == NULL)
319 return(0);
320
321 peldrDll->init(0);
322 if(peldrDll->getError() != NO_ERROR) {
323 dprintf(("LoadLibary %s failed (::init)\n", lpszLibFile));
324 delete(peldrDll);
325 return(0);
326 }
327 if(dwFlags & DONT_RESOLVE_DLL_REFERENCES) {
328 peldrDll->setNoEntryCalls();
329 }
330
331 if(peldrDll->attachProcess() == FALSE) {
332 dprintf(("LoadLibary %s failed (::attachProcess)\n", lpszLibFile));
333 delete(peldrDll);
334 return(0);
335 }
336 peldrDll->AddRef();
337 return peldrDll->getInstanceHandle();
338 }
339 else return(0);
340}
341//******************************************************************************
342//******************************************************************************
343HINSTANCE WIN32API LoadLibraryA(LPCTSTR lpszLibFile)
344{
345 HINSTANCE hDll;
346
347 dprintf(("KERNEL32: LoadLibraryA(%s)\n",
348 lpszLibFile));
349
350 hDll = iLoadLibraryA(lpszLibFile, 0);
351 if (hDll == 0)
352 {
353 char * pszName;
354
355 // remove path from the image name
356 pszName = strrchr((char *)lpszLibFile,
357 '\\');
358 if (pszName != NULL)
359 {
360 pszName++; // skip backslash
361
362 // now try again without fully qualified path
363 hDll = iLoadLibraryA(pszName, 0);
364 }
365 }
366
367 return hDll;
368}
369//******************************************************************************
370//******************************************************************************
371HINSTANCE WIN32API LoadLibraryExA(LPCTSTR lpszLibFile, HANDLE hFile, DWORD dwFlags)
372{
373 HINSTANCE hDll;
374
375 dprintf(("KERNEL32: LoadLibraryExA %s (%X)\n", lpszLibFile, dwFlags));
376 hDll = iLoadLibraryA(lpszLibFile, dwFlags);
377 if (hDll == 0)
378 {
379 char * pszName;
380
381 // remove path from the image name
382 pszName = strrchr((char *)lpszLibFile,
383 '\\');
384 if (pszName != NULL)
385 {
386 pszName++; // skip backslash
387
388 // now try again without fully qualified path
389 hDll = iLoadLibraryA(pszName, dwFlags);
390 }
391 }
392
393 return hDll;
394}
395//******************************************************************************
396//******************************************************************************
397HINSTANCE WIN32API LoadLibraryW(LPCWSTR lpModule)
398{
399 char *asciimodule;
400 HINSTANCE rc;
401
402 asciimodule = UnicodeToAsciiString((LPWSTR)lpModule);
403 dprintf(("KERNEL32: OS2LoadLibraryW %s\n", asciimodule));
404 rc = LoadLibraryA(asciimodule);
405 free(asciimodule);
406 return(rc);
407}
408//******************************************************************************
409//******************************************************************************
410HINSTANCE WIN32API LoadLibraryExW(LPCWSTR lpModule, HANDLE hFile, DWORD dwFlags)
411{
412 char *asciimodule;
413 HINSTANCE rc;
414
415 asciimodule = UnicodeToAsciiString((LPWSTR)lpModule);
416 dprintf(("KERNEL32: OS2LoadLibraryExW %s (%d)\n", asciimodule, dwFlags));
417 rc = LoadLibraryExA(asciimodule, hFile, dwFlags);
418 free(asciimodule);
419 return(rc);
420}
421//******************************************************************************
422//******************************************************************************
423LPCSTR WIN32API GetCommandLineA()
424{
425 LPTSTR cmdline = NULL;
426
427 if(WinExe) {
428 cmdline = WinExe->getCommandLine();
429 }
430 if(cmdline == NULL) //not used for converted exes
431 cmdline = O32_GetCommandLine();
432
433 dprintf(("KERNEL32: GetCommandLine %s\n", cmdline));
434 dprintf(("KERNEL32: FS = %x\n", GetFS()));
435 return(cmdline);
436}
437//******************************************************************************
438//******************************************************************************
439LPCWSTR WIN32API GetCommandLineW(void)
440{
441 static WCHAR *UnicodeCmdLine = NULL;
442 char *asciicmdline = NULL;
443
444 dprintf(("KERNEL32: FS = %x\n", GetFS()));
445
446 if(UnicodeCmdLine)
447 return(UnicodeCmdLine); //already called before
448
449 if(WinExe) {
450 asciicmdline = WinExe->getCommandLine();
451 }
452 if(asciicmdline == NULL) //not used for converted exes
453 asciicmdline = O32_GetCommandLine();
454
455 if(asciicmdline) {
456 UnicodeCmdLine = (WCHAR *)malloc(strlen(asciicmdline)*2 + 2);
457 AsciiToUnicode(asciicmdline, UnicodeCmdLine);
458 dprintf(("KERNEL32: OS2GetCommandLineW: %s\n", asciicmdline));
459 return(UnicodeCmdLine);
460 }
461 dprintf(("KERNEL32: OS2GetCommandLineW: asciicmdline == NULL\n"));
462 return NULL;
463}
464//******************************************************************************
465//******************************************************************************
466DWORD WIN32API GetModuleFileNameA(HMODULE hinstModule, LPTSTR lpszPath, DWORD cchPath)
467{
468 DWORD rc;
469 Win32ImageBase *module;
470 char *fpath = NULL;
471
472 dprintf(("GetModuleFileName %X", hinstModule));
473 if(hinstModule == 0 || hinstModule == -1 || (WinExe && hinstModule == WinExe->getInstanceHandle())) {
474 module = (Win32ImageBase *)WinExe;
475 }
476 else {
477 module = (Win32ImageBase *)Win32DllBase::findModule(hinstModule);
478 }
479
480 if(module) {
481 fpath = module->getFullPath();
482 }
483 if(fpath) {
484 //SvL: 13-9-98: +1
485 rc = min(strlen(fpath)+1, cchPath);
486 strncpy(lpszPath, fpath, rc);
487 }
488 else rc = O32_GetModuleFileName(hinstModule, lpszPath, cchPath);
489
490 if(rc) {
491 dprintf(("KERNEL32: GetModuleFileName %s %d\n", lpszPath, hinstModule));
492 }
493 return(rc);
494}
495//******************************************************************************
496//******************************************************************************
497DWORD WIN32API GetModuleFileNameW(HMODULE hModule, LPWSTR lpFileName, DWORD nSize)
498{
499 char *asciifilename = (char *)malloc(nSize+1);
500 DWORD rc;
501
502 dprintf(("KERNEL32: OSLibGetModuleFileNameW\n"));
503 rc = GetModuleFileNameA(hModule, asciifilename, nSize);
504 if(rc) AsciiToUnicode(asciifilename, lpFileName);
505 free(asciifilename);
506 return(rc);
507}
508//******************************************************************************
509//NOTE: GetModuleHandleA does NOT support files with multiple dots (i.e.
510// very.weird.exe)
511//******************************************************************************
512HANDLE WIN32API GetModuleHandleA(LPCTSTR lpszModule)
513{
514 HANDLE hMod;
515 Win32DllBase *windll;
516 char szModule[CCHMAXPATH];
517 BOOL fDllModule = FALSE;
518
519 if(lpszModule == NULL) {
520 if(WinExe)
521 hMod = WinExe->getInstanceHandle();
522 else hMod = -1;
523 }
524 else {
525 strcpy(szModule, OSLibStripPath((char *)lpszModule));
526 strupr(szModule);
527 if(strstr(szModule, ".DLL")) {
528 fDllModule = TRUE;
529 }
530 else {
531 if(!strstr(szModule, ".")) {
532 //if there's no extension or trainling dot, we
533 //assume it's a dll (see Win32 SDK docs)
534 fDllModule = TRUE;
535 }
536 }
537 char *dot = strstr(szModule, ".");
538 if(dot)
539 *dot = 0;
540
541 if(!fDllModule && WinExe && !strcmpi(lpszModule, WinExe->getModuleName())) {
542 hMod = WinExe->getInstanceHandle();
543 }
544 else {
545 windll = Win32DllBase::findModule(szModule);
546 if(windll) {
547 hMod = windll->getInstanceHandle();
548 }
549 else hMod = OSLibiGetModuleHandleA((char *)lpszModule);
550 }
551 }
552
553 eprintf(("KERNEL32: GetModuleHandle %s returned %X\n", lpszModule, hMod));
554 return(hMod);
555}
556//******************************************************************************
557//******************************************************************************
558HMODULE WIN32API GetModuleHandleW(LPCWSTR arg1)
559{
560 HMODULE rc;
561 char *astring;
562
563 astring = UnicodeToAsciiString((LPWSTR)arg1);
564 rc = GetModuleHandleA(astring);
565 dprintf(("KERNEL32: OS2GetModuleHandleW %s returned %X\n", astring, rc));
566 FreeAsciiString(astring);
567 return(rc);
568}
569//******************************************************************************
570//******************************************************************************
571BOOL WIN32API CreateProcessA(LPCSTR lpszImageName, LPSTR lpszCommandLine,
572 PSECURITY_ATTRIBUTES arg3,
573 PSECURITY_ATTRIBUTES arg4, BOOL arg5, DWORD arg6,
574 PVOID arg7, LPCSTR arg8, LPSTARTUPINFOA arg9,
575 LPPROCESS_INFORMATION arg10)
576{
577 BOOL rc;
578 char *cmdline;
579 BOOL fAllocStr = FALSE;
580
581 if(O32_CreateProcess(lpszImageName, lpszCommandLine, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) == TRUE)
582 return(TRUE);
583
584 //probably a win32 exe, so run it in the pe loader
585 if(lpszImageName) {
586 if(lpszCommandLine) {
587 cmdline = (char *)malloc(strlen(lpszImageName)+strlen(lpszCommandLine) + 16);
588 sprintf(cmdline, "%s %s", lpszImageName, lpszCommandLine);
589 fAllocStr = TRUE;
590 }
591 else cmdline = (char *)lpszImageName;
592 }
593 else cmdline = (char *)lpszCommandLine;
594
595 dprintf(("KERNEL32: CreateProcess %s\n", cmdline));
596 rc = O32_CreateProcess("PE.EXE", (LPCSTR)cmdline, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
597 if(fAllocStr)
598 free(cmdline);
599
600 dprintf(("KERNEL32: CreateProcess returned %d\n", rc));
601 return(rc);
602}
603//******************************************************************************
604//******************************************************************************
605BOOL WIN32API CreateProcessW(LPCWSTR arg1, LPWSTR arg2,
606 PSECURITY_ATTRIBUTES arg3,
607 PSECURITY_ATTRIBUTES arg4,
608 BOOL arg5, DWORD arg6, PVOID arg7,
609 LPCWSTR arg8, LPSTARTUPINFOW arg9,
610 LPPROCESS_INFORMATION arg10)
611{
612 BOOL rc;
613 char *astring1, *astring2, *astring3;
614
615 dprintf(("KERNEL32: OS2CreateProcessW DOESN't WORK"));
616 astring1 = UnicodeToAsciiString((LPWSTR)arg1);
617 astring2 = UnicodeToAsciiString(arg2);
618 astring3 = UnicodeToAsciiString((LPWSTR)arg8);
619 // NOTE: This will not work as is (needs UNICODE support)
620 rc = CreateProcessA(astring1, astring2, arg3, arg4, arg5, arg6, arg7,
621 astring3, (LPSTARTUPINFOA)arg9, arg10);
622 FreeAsciiString(astring3);
623 FreeAsciiString(astring2);
624 FreeAsciiString(astring1);
625 return(rc);
626}
627//******************************************************************************
628//******************************************************************************
629FARPROC WIN32API GetProcAddress(HMODULE hModule, LPCSTR lpszProc)
630{
631 Win32DllBase *winmod;
632 FARPROC proc;
633 ULONG ulAPIOrdinal;
634
635 winmod = Win32DllBase::findModule((HINSTANCE)hModule);
636 if(winmod) {
637 ulAPIOrdinal = (ULONG)lpszProc;
638 if (ulAPIOrdinal <= 0x0000FFFF) {
639 proc = (FARPROC)winmod->getApi((int)ulAPIOrdinal);
640 }
641 else proc = (FARPROC)winmod->getApi((char *)lpszProc);
642 if(proc == 0) {
643 SetLastError(ERROR_PROC_NOT_FOUND);
644 }
645 return proc;
646 }
647 proc = O32_GetProcAddress(hModule, lpszProc);
648 dprintf(("KERNEL32: GetProcAddress %s from %X returned %X\n", lpszProc, hModule, proc));
649 return(proc);
650}
651//******************************************************************************
652//Retrieve the version
653//******************************************************************************
654BOOL SYSTEM GetVersionStruct(char *modname, char *verstruct, ULONG bufLength)
655{
656 Win32ImageBase *winimage;
657
658 dprintf(("GetVersionStruct"));
659 if(WinExe && !strcmp(WinExe->getFullPath(), modname)) {
660 winimage = (Win32ImageBase *)WinExe;
661 }
662 else {
663 winimage = (Win32ImageBase *)Win32DllBase::findModule(modname);
664 if(winimage == NULL) {
665 dprintf(("GetVersionStruct can't find Win32Image for %s\n", modname));
666 return(FALSE);
667 }
668 }
669 return winimage->getVersionStruct(verstruct, bufLength);
670}
671//******************************************************************************
672//******************************************************************************
673ULONG SYSTEM GetVersionSize(char *modname)
674{
675 Win32ImageBase *winimage;
676
677 dprintf(("GetVersionSize of %s\n", modname));
678
679 if(WinExe && !strcmp(WinExe->getFullPath(), modname)) {
680 winimage = (Win32ImageBase *)WinExe;
681 }
682 else {
683 winimage = (Win32ImageBase *)Win32DllBase::findModule(modname);
684 if(winimage == NULL) {
685 dprintf(("GetVersionSize can't find Win32Image for %s\n", modname));
686 return(FALSE);
687 }
688 }
689 return winimage->getVersionSize();
690}
691//******************************************************************************
692//******************************************************************************
693
694
695/***********************************************************************
696 * RegisterServiceProcess (KERNEL, KERNEL32)
697 *
698 * A service process calls this function to ensure that it continues to run
699 * even after a user logged off.
700 */
701DWORD WIN32API RegisterServiceProcess(DWORD dwProcessId,
702 DWORD dwType)
703{
704 dprintf(("KERNEL32: RegisterServiceProcess(%08xh,%08xh) not implemented.\n",
705 dwProcessId,
706 dwType));
707
708 /* I don't think that Wine needs to do anything in that function */
709 return 1; /* success */
710}
711
712//******************************************************************************
713//TODO:What does this do exactly??
714//******************************************************************************
715ODINFUNCTION1(BOOL,DisableThreadLibraryCalls,HMODULE,hModule)
716{
717 Win32DllBase *winmod;
718 FARPROC proc;
719 ULONG ulAPIOrdinal;
720
721 winmod = Win32DllBase::findModule((HINSTANCE)hModule);
722 if(winmod)
723 {
724 // don't call ATTACH/DETACH thread functions in DLL
725 winmod->setThreadLibraryCalls(FALSE);
726 return TRUE;
727 }
728 else
729 {
730 // raise error condition
731 SetLastError(ERROR_INVALID_HANDLE);
732 return FALSE;
733 }
734}
735
Note: See TracBrowser for help on using the repository browser.