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

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

More TIB changes

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