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

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

exception handler changes + EB's HeapReAlloc fix

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