| 1 | /* $Id: myldrClose.cpp,v 1.6 2000-09-02 21:08:07 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 |
|
|---|
| 17 | /*******************************************************************************
|
|---|
| 18 | * Header Files *
|
|---|
| 19 | *******************************************************************************/
|
|---|
| 20 | #include <os2.h>
|
|---|
| 21 |
|
|---|
| 22 | #include <memory.h>
|
|---|
| 23 | #include <stdlib.h>
|
|---|
| 24 |
|
|---|
| 25 | #include "devSegDf.h" /* Win32k segment definitions. */
|
|---|
| 26 | #include "log.h"
|
|---|
| 27 | #include "avl.h"
|
|---|
| 28 | #include <peexe.h>
|
|---|
| 29 | #include <exe386.h>
|
|---|
| 30 | #include "OS2Krnl.h"
|
|---|
| 31 | #include "ldr.h"
|
|---|
| 32 | #include "ldrCalls.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 | }
|
|---|