Ignore:
Timestamp:
Jun 17, 1999, 11:52:01 PM (26 years ago)
Author:
phaller
Message:

Fix: preparing support for HandleManager on kernel objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/KERNEL32.CPP

    r111 r114  
    1 /* $Id: KERNEL32.CPP,v 1.5 1999-06-17 18:21:36 phaller Exp $ */
     1/* $Id: KERNEL32.CPP,v 1.6 1999-06-17 21:52:00 phaller Exp $ */
    22
    33/*
     
    4646
    4747/*****************************************************************************
    48  * Name      : BOOL WIN32API CreateEventA
    49  * Purpose   : forward call to Open32
    50  * Parameters:
    51  * Variables :
    52  * Result    :
    53  * Remark    :
    54  * Status    :
    55  *
    56  * Author    : Patrick Haller [Fri, 1998/06/12 03:44]
    57  *****************************************************************************/
    58 
    59 HANDLE WIN32API CreateEventA(LPSECURITY_ATTRIBUTES lpsa,
    60                                 BOOL                  fManualReset,
    61                                 BOOL                  fInitialState,
    62                                 LPCTSTR               lpszEventName)
    63 {
    64   ULONG  rc;                                               /* API returncode */
    65   HANDLE hOS2;                                         /* 32-bit OS/2 handle */
    66   HANDLE hWindows;                                  /* 16-bit Windows handle */
    67 
    68   dprintf(("KERNEL32::CreateEventA(%08xh, %08xh, %08xh, %s)\n",
    69            lpsa,
    70            fManualReset,
    71            fInitialState,
    72            lpszEventName));
    73 
    74   hOS2 = O32_CreateEvent(lpsa,                         /* create event semaphore */
    75                      fManualReset,
    76                      fInitialState,
    77                      lpszEventName);
    78   if (hOS2 != 0)                                             /* check handle */
    79   {
    80     rc = HMHandleAllocate(&hWindows,                      /* allocate handle */
    81                           hOS2);
    82     if (rc == NO_ERROR)                                  /* check for errors */
    83       return (hWindows);                         /* return translated handle */
    84     else
    85       return (0);                                   /* raise error condition */
    86   }
    87 
    88   return (hOS2);                 /* should have the correct error value here */
    89 }
    90 
    91 /*****************************************************************************
    9248 * Name      : BOOL WIN32API CloseHandle
    9349 * Purpose   : forward call to Open32
     
    10965
    11066
    111 /*****************************************************************************
    112  * Name      : BOOL WIN32API CreateEventW
    113  * Purpose   : forward call to Open32
    114  * Parameters:
    115  * Variables :
    116  * Result    :
    117  * Remark    : handle translation is done in CreateEventA
    118  * Status    :
    119  *
    120  * Author    : Patrick Haller [Fri, 1998/06/12 03:44]
    121  *****************************************************************************/
    122 
    123 HANDLE WIN32API CreateEventW(PSECURITY_ATTRIBUTES arg1,
    124                              BOOL                 arg2,
    125                              BOOL                 arg3,
    126                              LPCWSTR               arg4)
    127 {
    128   HANDLE rc;
    129   char  *astring;
    130 
    131   dprintf(("KERNEL32::CreateEventW>(%08xh, %08xh, %08xh, %s)\n",
    132            arg1,
    133            arg2,
    134            arg3,
    135            arg4));
    136 
    137   astring = UnicodeToAsciiString((LPWSTR)arg4);
    138 
    139   rc = O32_CreateEvent(arg1,
    140                    arg2,
    141                    arg3,
    142                    astring);
    143 
    144   FreeAsciiString(astring);
    145 
    146   return(rc);
    147 }
    148 ///@@@PH handlemanager
    149 //******************************************************************************
    150 //******************************************************************************
    151 HANDLE WIN32API CreateMutexA(LPSECURITY_ATTRIBUTES lpsa,
    152                                 BOOL                  fInitialOwner,
    153                                 LPCTSTR               lpszMutexName)
    154 {
    155   dprintf(("KERNEL32:  CreateMutex\n"));
    156 
    157   return(O32_CreateMutex(lpsa,
    158                      fInitialOwner,
    159                      lpszMutexName));
    160 }
    161 //******************************************************************************
    162 //******************************************************************************
    163 HANDLE WIN32API CreateMutexW(PSECURITY_ATTRIBUTES arg1,
    164                              BOOL                 arg2,
    165                              LPCWSTR              arg3)
    166 {
    167  HANDLE rc;
    168  char  *astring;
    169 
    170   dprintf(("KERNEL32:  OS2CreateMutexW\n"));
    171 
    172   astring = UnicodeToAsciiString((LPWSTR)arg3);
    173   rc = O32_CreateMutex(arg1,
    174                    arg2,
    175                    astring);
    176   FreeAsciiString(astring);
    177 
    178   return(rc);
    179 }
    180 //******************************************************************************
    18167//******************************************************************************
    18268HANDLE WIN32API GetModuleHandleA(LPCTSTR lpszModule)
     
    218104//******************************************************************************
    219105//******************************************************************************
    220 BOOL WIN32API ReleaseMutex(HANDLE mutex)
    221 {
    222   dprintf(("KERNEL32:  ReleaseMutex\n"));
    223   return(O32_ReleaseMutex(mutex));
    224 }
    225 //******************************************************************************
    226 //******************************************************************************
    227 BOOL WIN32API SetEvent(HANDLE hEvent)
    228 {
    229   dprintf(("KERNEL32:  SetEvent\n"));
    230   return(O32_SetEvent(hEvent));
    231 }
    232 //******************************************************************************
    233 //******************************************************************************
    234106BOOL WIN32API SetStdHandle(DWORD  IDStdHandle,
    235107                              HANDLE hHandle)
     
    273145  return(O32_TlsSetValue(index, val));
    274146}
    275 //******************************************************************************
    276 //******************************************************************************
    277 DWORD WIN32API WaitForSingleObject(HANDLE hObject,
    278                                       DWORD  timeout)
    279 {
    280   dprintf(("KERNEL32:  WaitForSingleObject (%08xh, %08xh)\n",
    281            hObject,
    282            timeout));
    283 
    284   return(O32_WaitForSingleObject(hObject,
    285                              timeout));
    286 }
    287 //******************************************************************************
    288 
    289 
    290 /*****************************************************************************
    291  * Name      : DWORD OS2WaitForSingleObjectEx
    292  * Purpose   : The WaitForSingleObjectEx function is an extended wait function
    293  *             that can be used to perform an alertable wait. This enables the
    294  *             function to return when the system queues an I/O completion
    295  *             routine to be executed by the calling thread. The function also
    296  *             returns when the specified object is in the signaled state or
    297  *             when the time-out interval elapses.
    298  * Parameters: HANDLE hObject     handle of object to wait for
    299  *             DWORD  dwTimeout   time-out interval in milliseconds
    300  *             BOOL   fAlertable  alertable wait flag
    301  * Variables :
    302  * Result    : 0xFFFFFFFF in case of error
    303  * Remark    : only really required for async I/O
    304  * Status    : UNTESTED STUB
    305  *
    306  * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
    307  *****************************************************************************/
    308 
    309 DWORD WIN32API WaitForSingleObjectEx(HANDLE hObject,
    310                                         DWORD        dwTimeout,
    311                                         BOOL         fAlertable)
    312 {
    313   dprintf(("Kernel32: WaitForSingleObjectEx(%08xh,%08xh,%08xh) not implemented correctly.\n",
    314            hObject,
    315            dwTimeout,
    316            fAlertable));
    317 
    318   return(O32_WaitForSingleObject(hObject,
    319                              dwTimeout));
    320 }
    321 
    322147//******************************************************************************
    323148//******************************************************************************
     
    404229//******************************************************************************
    405230//******************************************************************************
    406 BOOL WIN32API FlushFileBuffers(HANDLE hFile)
    407 {
    408   dprintf(("KERNEL32:  FlushFileBuffers\n"));
    409   return(O32_FlushFileBuffers(hFile));
    410 }
    411 //******************************************************************************
    412 //******************************************************************************
    413231LONG WIN32API InterlockedDecrement(LPLONG lplVal)
    414232{
     
    429247    dprintf(("KERNEL32:  InterlockedExchange\n"));
    430248    return O32_InterlockedExchange(arg1, arg2);
    431 }
    432 //******************************************************************************
    433 //******************************************************************************
    434 UINT WIN32API SetHandleCount(UINT cHandles)
    435 {
    436   dprintf(("KERNEL32:  GetHandleCount\n"));
    437   return(O32_SetHandleCount(cHandles));
    438249}
    439250//******************************************************************************
     
    762573}
    763574//******************************************************************************
    764 //SvL: 24-6-'97 - Added
    765 //SvL: 28-6-'97: Fix for timeSetEvent in Red Alert Map Editor
    766 //******************************************************************************
    767 BOOL WIN32API DuplicateHandle(HANDLE srcprocess, HANDLE srchandle, HANDLE destprocess,
    768                                  PHANDLE desthandle, DWORD arg5, BOOL arg6, DWORD  arg7)
    769 {
    770  BOOL rc;
    771 
    772 #if 0
    773     //SvL:
    774     //If source & destination process are identical, just copy handle
    775     //(if target pointer != NULL)
    776     //timeSetEvent's timer handler expects to be called from another process,
    777     //but we just create a separate timer thread inside the client process
    778     if(srcprocess == destprocess) {
    779         if(desthandle != NULL)
    780                 *desthandle = srchandle;
    781         return(TRUE);
    782     }
    783 #endif
    784     rc = O32_DuplicateHandle(srcprocess, srchandle, destprocess, desthandle, arg5, arg6, arg7);
    785 ////    dprintf(("KERNEL32:  OS2DuplicateHandle returned %d\n", rc));
    786     return(rc);
    787 }
    788 //******************************************************************************
    789575//******************************************************************************
    790576BOOL WIN32API Beep( DWORD arg1, DWORD  arg2)
     
    792578    dprintf(("KERNEL32:  OS2Beep\n"));
    793579    return O32_Beep(arg1, arg2);
    794 }
    795 //******************************************************************************
    796 //******************************************************************************
    797 HANDLE WIN32API CreateSemaphoreA(PSECURITY_ATTRIBUTES arg1, LONG arg2, LONG arg3, LPCSTR arg4)
    798 {
    799     dprintf(("KERNEL32:  OS2CreateSemaphoreA\n"));
    800     return O32_CreateSemaphore(arg1, arg2, arg3, (LPSTR)arg4);
    801 }
    802 //******************************************************************************
    803 //******************************************************************************
    804 HANDLE WIN32API CreateSemaphoreW(PSECURITY_ATTRIBUTES arg1,
    805                                  LONG arg2, LONG arg3,
    806                                  LPCWSTR arg4)
    807 {
    808  HANDLE rc;
    809  char   *astring;
    810 
    811     dprintf(("KERNEL32:  OS2CreateSemaphoreW"));
    812     astring = UnicodeToAsciiString((LPWSTR)arg4);
    813     rc = O32_CreateSemaphore(arg1, arg2, arg3, astring);
    814     FreeAsciiString(astring);
    815     return(rc);
    816580}
    817581//******************************************************************************
     
    867631//******************************************************************************
    868632//******************************************************************************
    869 BOOL WIN32API GetOverlappedResult(HANDLE arg1, LPOVERLAPPED arg2, LPDWORD arg3, BOOL  arg4)
    870 {
    871     dprintf(("KERNEL32:  OS2GetOverlappedResult\n"));
    872     return O32_GetOverlappedResult(arg1, arg2, arg3, arg4);
    873 }
    874 //******************************************************************************
    875 //******************************************************************************
    876633BOOL WIN32API IsBadHugeReadPtr( const void * arg1, UINT  arg2)
    877634{
     
    909666//******************************************************************************
    910667//******************************************************************************
    911 HANDLE WIN32API OpenEventA( DWORD arg1, BOOL arg2, LPCSTR  arg3)
    912 {
    913     dprintf(("KERNEL32:  OS2OpenEventA\n"));
    914     return O32_OpenEvent(arg1, arg2, arg3);
    915 }
    916 //******************************************************************************
    917 //******************************************************************************
    918 HANDLE WIN32API OpenEventW(DWORD dwDesiredAccess, BOOL bInheritHandle,
    919                            LPCWSTR lpName)
    920 {
    921  char  *asciiname;
    922  HANDLE rc;
    923 
    924     dprintf(("KERNEL32:  OS2OpenEventW\n"));
    925     asciiname = UnicodeToAsciiString((LPWSTR)lpName);
    926     rc = O32_OpenEvent(dwDesiredAccess, bInheritHandle, asciiname);
    927     FreeAsciiString(asciiname);
    928     return(rc);
    929 }
    930 //******************************************************************************
    931 //******************************************************************************
    932 HANDLE WIN32API OpenMutexA( DWORD arg1, BOOL arg2, LPCSTR  arg3)
    933 {
    934     dprintf(("KERNEL32:  OS2OpenMutexA\n"));
    935     return O32_OpenMutex(arg1, arg2, arg3);
    936 }
    937 //******************************************************************************
    938 //******************************************************************************
    939 HANDLE WIN32API OpenMutexW(DWORD dwDesiredAccess, BOOL bInheritHandle,
    940                            LPCWSTR lpName)
    941 {
    942  char  *asciiname;
    943  HANDLE rc;
    944 
    945     dprintf(("KERNEL32:  OS2OpenMutexW\n"));
    946     asciiname = UnicodeToAsciiString((LPWSTR)lpName);
    947     rc = O32_OpenMutex(dwDesiredAccess, bInheritHandle, asciiname);
    948     FreeAsciiString(asciiname);
    949     return(rc);
    950 }
    951 //******************************************************************************
    952 //******************************************************************************
    953668HANDLE WIN32API OpenProcess(DWORD arg1, BOOL arg2, DWORD arg3)
    954669{
    955670    dprintf(("KERNEL32:  OS2OpenProcess\n"));
    956671    return O32_OpenProcess(arg1, arg2, arg3);
    957 }
    958 //******************************************************************************
    959 //******************************************************************************
    960 HANDLE WIN32API OpenSemaphoreA( DWORD arg1, BOOL arg2, LPCSTR  arg3)
    961 {
    962     dprintf(("KERNEL32:  OS2OpenSemaphoreA"));
    963     return O32_OpenSemaphore(arg1, arg2, arg3);
    964 }
    965 //******************************************************************************
    966 //******************************************************************************
    967 HANDLE WIN32API OpenSemaphoreW(DWORD dwDesiredAccess, BOOL bInheritHandle,
    968                                LPCWSTR lpName)
    969 {
    970  char  *asciiname;
    971  HANDLE rc;
    972 
    973     dprintf(("KERNEL32:  OS2OpenSemaphoreW"));
    974     asciiname = UnicodeToAsciiString((LPWSTR)lpName);
    975     rc = O32_OpenSemaphore(dwDesiredAccess, bInheritHandle, asciiname);
    976     FreeAsciiString(asciiname);
    977     return(rc);
    978 }
    979 //******************************************************************************
    980 //******************************************************************************
    981 BOOL WIN32API PulseEvent( HANDLE arg1)
    982 {
    983     dprintf(("KERNEL32:  OS2PulseEvent\n"));
    984     return O32_PulseEvent(arg1);
    985 }
    986 //******************************************************************************
    987 //******************************************************************************
    988 BOOL WIN32API ReleaseSemaphore( HANDLE arg1, LONG arg2, PLONG  arg3)
    989 {
    990     dprintf(("KERNEL32:  OS2ReleaseSemaphore"));
    991     return O32_ReleaseSemaphore(arg1, arg2, arg3);
    992 }
    993 //******************************************************************************
    994 //******************************************************************************
    995 BOOL WIN32API ResetEvent(HANDLE arg1)
    996 {
    997   dprintf(("KERNEL32: ResetEvent(%08xh)\n",
    998            arg1));
    999 
    1000   return O32_ResetEvent(arg1);
    1001 }
    1002 //******************************************************************************
    1003 //******************************************************************************
    1004 DWORD WIN32API WaitForMultipleObjects( DWORD arg1, const HANDLE * arg2, BOOL arg3, DWORD  arg4)
    1005 {
    1006     dprintf(("KERNEL32:  OS2WaitForMultipleObjects"));
    1007     return O32_WaitForMultipleObjects(arg1, arg2, arg3, arg4);
    1008 }
    1009 
    1010 
    1011 /*****************************************************************************
    1012  * Name      : DWORD OS2WaitForMultipleObjectsEx
    1013  * Purpose   : The WaitForMultipleObjectsEx function is an extended wait
    1014  *             function that can be used to perform an alertable wait. This
    1015  *             enables the function to return when the system queues an I/O
    1016  *             completion routine to be executed by the calling thread. The
    1017  *             function also returns either when any one or when all of the
    1018  *             specified objects are in the signaled state, or when the
    1019  *             time-out interval elapses.
    1020  * Parameters: DWORD  cObjects    number of handles in handle array
    1021  *             HANDLE *lphObjects address of object-handle array
    1022  *             BOOL   fWaitAll    wait flag
    1023  *             DWORD  dwTimeout   time-out interval in milliseconds
    1024  *             BOOL   fAlertable  alertable wait flag
    1025  * Variables :
    1026  * Result    : 0xFFFFFFFF in case of error
    1027  * Remark    : only really required for async I/O
    1028  * Status    : UNTESTED STUB
    1029  *
    1030  * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
    1031  *****************************************************************************/
    1032 
    1033 DWORD WIN32API WaitForMultipleObjectsEx(DWORD        cObjects,
    1034                                            CONST HANDLE *lphObjects,
    1035                                            BOOL         fWaitAll,
    1036                                            DWORD        dwTimeout,
    1037                                            BOOL         fAlertable)
    1038 {
    1039   dprintf(("Kernel32: WaitForMultipleObjectsEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented correctly.\n",
    1040            cObjects,
    1041            lphObjects,
    1042            fWaitAll,
    1043            dwTimeout,
    1044            fAlertable));
    1045 
    1046   return(O32_WaitForMultipleObjects(cObjects,
    1047                                    lphObjects,
    1048                                    fWaitAll,
    1049                                    dwTimeout));
    1050672}
    1051673//******************************************************************************
     
    14581080}
    14591081
    1460 HANDLE WIN32API ConvertToGlobalHandle(HANDLE hHandle)
    1461 //HANDLE WIN32API ConvertToGlobalHandle(HANDLE hHandle,
    1462 //                                      BOOL   fInherit)
    1463 {
    1464   return (hHandle);
    1465 }
    1466 
    14671082BOOL WIN32API FindCloseChangeNotification(HANDLE hChange)
    14681083{
Note: See TracChangeset for help on using the changeset viewer.