Ignore:
Timestamp:
Dec 9, 2011, 12:22:52 PM (14 years ago)
Author:
dmik
Message:

Port WINSPOOL and COMDLG32 to GCC/kBuild.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • branches/gcc-kmk/src/comdlg32/initterm.cpp

    r21842 r21871  
    1 /* $Id: initcomdlg32.cpp,v 1.5 2003-04-08 12:43:29 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.14 2001-09-05 12:12:02 bird Exp $ */
    22/*
    3  * DLL entry point
     3 * COMDLG32 DLL entry point
    44 *
    55 * Copyright 1998 Sander van Leeuwen
    66 * Copyright 1998 Peter Fitzsimmons
    77 *
    8  *
    98 * Project Odin Software License can be found in LICENSE.TXT
    10  *
    119 */
    1210
    13 /*-------------------------------------------------------------*/
    14 /* INITERM.C -- Source for a custom dynamic link library       */
    15 /*              initialization and termination (_DLL_InitTerm) */
    16 /*              function.                                      */
    17 /*                                                             */
    18 /* When called to perform initialization, this sample function */
    19 /* gets storage for an array of integers, and initializes its  */
    20 /* elements with random integers.  At termination time, it     */
    21 /* frees the array.  Substitute your own special processing.   */
    22 /*-------------------------------------------------------------*/
    23 
    24 
    25 /* Include files */
    2611#define  INCL_DOSMODULEMGR
    2712#define  INCL_DOSPROCESS
     
    3924#include <initdll.h>
    4025
    41 extern "C" {
    42  //Win32 resource table (produced by wrc)
    43  extern DWORD comdlg32_PEResTab;
    44 
    45  BOOL WINAPI COMDLG32_DllEntryPoint(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved);
    46 }
     26// Win32 resource table (produced by wrc)
     27extern DWORD comdlg32_PEResTab;
    4728
    4829static HMODULE dllHandle = 0;
    4930
    50 //******************************************************************************
    51 //******************************************************************************
     31BOOL WINAPI COMDLG32_DllEntryPoint(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved);
     32
    5233BOOL WINAPI LibMainComdlg32(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
    5334{
    54    switch (fdwReason)
    55    {
    56    case DLL_PROCESS_ATTACH:
    57        return COMDLG32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
     35    switch (fdwReason)
     36    {
     37    case DLL_PROCESS_ATTACH:
     38        return COMDLG32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
    5839
    59    case DLL_THREAD_ATTACH:
    60    case DLL_THREAD_DETACH:
    61    case DLL_PROCESS_DETACH:
    62        COMDLG32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
    63        return TRUE;
    64    }
    65    return FALSE;
     40    case DLL_THREAD_ATTACH:
     41    case DLL_THREAD_DETACH:
     42    case DLL_PROCESS_DETACH:
     43        COMDLG32_DllEntryPoint(hinstDLL, fdwReason, fImpLoad);
     44        return TRUE;
     45    }
     46    return FALSE;
    6647}
    67 /****************************************************************************/
    68 /* _DLL_InitTerm is the function that gets called by the operating system   */
    69 /* loader when it loads and frees this DLL for each process that accesses   */
    70 /* this DLL.  However, it only gets called the first time the DLL is loaded */
    71 /* and the last time it is freed for a particular process.  The system      */
    72 /* linkage convention MUST be used because the operating system loader is   */
    73 /* calling this function.                                                   */
    74 /****************************************************************************/
    75 ULONG APIENTRY inittermComdlg32(ULONG hModule, ULONG ulFlag)
     48
     49ULONG SYSTEM DLL_InitComdlg32(ULONG hModule)
    7650{
    77    size_t i;
    78    APIRET rc;
     51    CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    7952
    80    /*-------------------------------------------------------------------------*/
    81    /* If ulFlag is zero then the DLL is being loaded so initialization should */
    82    /* be performed.  If ulFlag is 1 then the DLL is being freed so            */
    83    /* termination should be performed.                                        */
    84    /*-------------------------------------------------------------------------*/
     53    dllHandle = RegisterLxDll(hModule, LibMainComdlg32, (PVOID)&comdlg32_PEResTab,
     54                              COMDLG32_MAJORIMAGE_VERSION, COMDLG32_MINORIMAGE_VERSION,
     55                              IMAGE_SUBSYSTEM_WINDOWS_GUI);
     56    if (dllHandle == 0)
     57           return -1;
    8558
    86    switch (ulFlag) {
    87       case 0 :
    88          dllHandle = RegisterLxDll(hModule, LibMainComdlg32, (PVOID)&comdlg32_PEResTab,
    89                                    COMDLG32_MAJORIMAGE_VERSION, COMDLG32_MINORIMAGE_VERSION,
    90                                    IMAGE_SUBSYSTEM_WINDOWS_GUI);
    91          if(dllHandle == 0)
    92              return 0UL;
     59    return 0;
     60}
    9361
    94          break;
    95       case 1 :
    96          if(dllHandle) {
    97              UnregisterLxDll(dllHandle);
    98          }
    99          break;
    100       default  :
    101          return 0UL;
    102    }
     62void SYSTEM DLL_TermComdlg32(ULONG hModule)
     63{
     64    if (dllHandle)
     65       UnregisterLxDll(dllHandle);
     66}
    10367
    104    /***********************************************************/
    105    /* A non-zero value must be returned to indicate success.  */
    106    /***********************************************************/
    107    return 1UL;
     68ULONG SYSTEM DLL_Init(ULONG hModule)
     69{
     70    if (DLL_InitDefault(hModule) == -1)
     71        return -1;
     72    return DLL_InitComdlg32(hModule);
    10873}
     74
     75void SYSTEM DLL_Term(ULONG hModule)
     76{
     77    DLL_TermComdlg32(hModule);
     78    DLL_TermDefault(hModule);
     79}
Note: See TracChangeset for help on using the changeset viewer.