1 | /* $Id: myldrClose.cpp,v 1.7 2001-02-10 11:11:46 bird Exp $
|
---|
2 | *
|
---|
3 | * myldrClose - ldrClose
|
---|
4 | *
|
---|
5 | * Copyright (c) 1998-1999 knut st. osmundsen
|
---|
6 | *
|
---|
7 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
8 | *
|
---|
9 | */
|
---|
10 |
|
---|
11 | /*******************************************************************************
|
---|
12 | * Defined Constants And Macros *
|
---|
13 | *******************************************************************************/
|
---|
14 | #define INCL_DOSERRORS
|
---|
15 | #define INCL_NOPMAPI
|
---|
16 | #define INCL_OS2KRNL_LDR
|
---|
17 |
|
---|
18 | /*******************************************************************************
|
---|
19 | * Header Files *
|
---|
20 | *******************************************************************************/
|
---|
21 | #include <os2.h>
|
---|
22 |
|
---|
23 | #include <memory.h>
|
---|
24 | #include <stdlib.h>
|
---|
25 |
|
---|
26 | #include "devSegDf.h" /* Win32k segment definitions. */
|
---|
27 | #include "log.h"
|
---|
28 | #include "avl.h"
|
---|
29 | #include <peexe.h>
|
---|
30 | #include <exe386.h>
|
---|
31 | #include "OS2Krnl.h"
|
---|
32 | #include "ldr.h"
|
---|
33 | #include "ModuleBase.h"
|
---|
34 | #include "Pe2Lx.h"
|
---|
35 |
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Close a file.
|
---|
39 | * @returns NO_ERROR on success?
|
---|
40 | * error code on error?
|
---|
41 | * @param hFile Handle to file which is to be closed.
|
---|
42 | */
|
---|
43 | ULONG LDRCALL myldrClose(SFN hFile)
|
---|
44 | {
|
---|
45 | /* closes handle */
|
---|
46 | kprintf(("myldrClose: hFile = %.4x\n", hFile));
|
---|
47 | if (GetState(hFile) == HSTATE_OUR)
|
---|
48 | {
|
---|
49 | APIRET rc;
|
---|
50 |
|
---|
51 | #ifdef DEBUG
|
---|
52 | PMODULE pMod = getModuleBySFN(hFile);
|
---|
53 | if (pMod != NULL)
|
---|
54 | pMod->Data.pModule->dumpVirtualLxFile();
|
---|
55 | else
|
---|
56 | kprintf(("myldrClose: getModuleBySFN failed!!!"));
|
---|
57 | #endif
|
---|
58 |
|
---|
59 | rc = removeModule(hFile);
|
---|
60 | if (rc != NO_ERROR)
|
---|
61 | kprintf(("myldrClose: removeModule retured rc=%d\n", rc));
|
---|
62 |
|
---|
63 | #pragma info(notrd)
|
---|
64 | SetState(hFile, HSTATE_UNUSED);
|
---|
65 | #pragma info(restore)
|
---|
66 | }
|
---|
67 | /*
|
---|
68 | * Invalidate the odin32path if kernel32 is closed.
|
---|
69 | * (Might possible not be needed as Pe2Lx does invalides
|
---|
70 | * the odin32path on object destruction.)
|
---|
71 | */
|
---|
72 | else if (Pe2Lx::getKernel32SFN() == hFile)
|
---|
73 | Pe2Lx::invalidateOdin32Path();
|
---|
74 |
|
---|
75 | /*
|
---|
76 | * Finally call the real close function.
|
---|
77 | */
|
---|
78 | return ldrClose(hFile);
|
---|
79 | }
|
---|