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

Last change on this file since 1280 was 1280, checked in by sandervl, 26 years ago

Heap fixes + dll load bugfixes

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