- Timestamp:
- Mar 16, 2000, 8:21:54 PM (25 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r2802 r3128 1 /* $Id: HandleManager.cpp,v 1.3 5 2000-02-16 14:23:57sandervl Exp $ */1 /* $Id: HandleManager.cpp,v 1.36 2000-03-16 19:20:36 sandervl Exp $ */ 2 2 3 3 /* … … 57 57 #include "HMComm.h" 58 58 #include "HMToken.h" 59 #include <winconst.h> 59 #include "HMThread.h" 60 #include <vmutex.h> 60 61 61 62 #define DBG_LOCALLOG DBG_handlemanager … … 109 110 /* the device name is repeated here to enable device alias names */ 110 111 static PHMDEVICE TabWin32Devices = NULL; 112 111 113 static HMHANDLE TabWin32Handles[MAX_OS2_HMHANDLES]; /* static handle table */ 112 114 VMutex handleMutex; 113 115 114 116 struct _HMGlobals … … 128 130 HMDeviceHandler *pHMComm; /* serial communication */ 129 131 HMDeviceHandler *pHMToken; /* security tokens */ 132 HMDeviceHandler *pHMThread; 130 133 131 134 ULONG ulHandleLast; /* index of last used handle */ … … 195 198 register ULONG ulLoop; 196 199 200 handleMutex.enter(); 201 197 202 for (ulLoop = 1; // @@@PH Note, this is an experimental change 198 203 // 0L as hHandle is sometimes considered invalid! … … 205 210 TabWin32Handles[ulLoop].hmHandleData.dwUserData = 0; 206 211 TabWin32Handles[ulLoop].hmHandleData.dwInternalType = HMTYPE_UNKNOWN; 212 handleMutex.leave(); 207 213 return (ulLoop); /* OK, then return it to the caller */ 208 214 } 209 215 } 210 216 217 handleMutex.leave(); 211 218 return (INVALID_HANDLE_VALUE); /* haven't found any free handle */ 212 219 } … … 326 333 HMGlobals.fIsInitialized = TRUE; /* OK, done */ 327 334 335 handleMutex.enter(); 328 336 // fill handle table 329 for (ulIndex = 0;330 ulIndex < MAX_OS2_HMHANDLES;331 ulIndex++)332 TabWin32Handles[ulIndex].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE;337 for(ulIndex = 0; ulIndex < MAX_OS2_HMHANDLES; ulIndex++) { 338 TabWin32Handles[ulIndex].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 339 } 340 handleMutex.leave(); 333 341 334 342 dprintf(("KERNEL32:HandleManager:HMInitialize() storing handles.\n")); … … 338 346 sizeof(HMGlobals)); 339 347 340 348 /* copy standard handles from OS/2's Open32 Subsystem */ 341 349 HMSetStdHandle(STD_INPUT_HANDLE, GetStdHandle(STD_INPUT_HANDLE)); 342 350 HMSetStdHandle(STD_OUTPUT_HANDLE, GetStdHandle(STD_OUTPUT_HANDLE)); … … 351 359 HMGlobals.pHMComm = new HMDeviceCommClass("\\\\COM\\"); 352 360 HMGlobals.pHMToken = new HMDeviceTokenClass("\\\\TOKEN\\"); 361 HMGlobals.pHMThread = new HMDeviceThreadClass("\\\\THREAD\\"); 353 362 } 354 363 return (NO_ERROR); … … 408 417 *****************************************************************************/ 409 418 410 DWORD 411 419 DWORD HMHandleAllocate (PULONG phHandle16, 420 ULONG hHandleOS2) 412 421 { 413 422 register ULONG ulHandle; … … 421 430 ulHandle = HMGlobals.ulHandleLast; /* get free handle */ 422 431 432 handleMutex.enter(); 433 423 434 if(ulHandle == 0) { 424 435 ulHandle = 1; //SvL: Start searching from index 1 … … 426 437 do 427 438 { 428 439 /* check if handle is free */ 429 440 if (TabWin32Handles[ulHandle].hmHandleData.hHMHandle == INVALID_HANDLE_VALUE) 430 441 { 431 *phHandle16 = ulHandle; 432 TabWin32Handles[ulHandle].hmHandleData.hHMHandle = hHandleOS2; 433 HMGlobals.ulHandleLast = ulHandle; /* to shorten search times */ 434 435 return (NO_ERROR); /* OK */ 442 *phHandle16 = ulHandle; 443 TabWin32Handles[ulHandle].hmHandleData.hHMHandle = hHandleOS2; 444 HMGlobals.ulHandleLast = ulHandle; /* to shorten search times */ 445 446 handleMutex.leave(); 447 return (NO_ERROR); /* OK */ 436 448 } 437 449 … … 442 454 } 443 455 while (ulHandle != HMGlobals.ulHandleLast); 456 457 handleMutex.leave(); 444 458 445 459 return (ERROR_TOO_MANY_OPEN_FILES); /* OK, we're done */ … … 2910 2924 return STATUS_SUCCESS; 2911 2925 } 2912 2926 /***************************************************************************** 2927 * Name : HMCreateThread 2928 * Purpose : router function for CreateThread 2929 * Parameters: 2930 * Variables : 2931 * Result : 2932 * Remark : 2933 * Status : 2934 * 2935 * Author : SvL 2936 *****************************************************************************/ 2937 HANDLE HMCreateThread(LPSECURITY_ATTRIBUTES lpsa, 2938 DWORD cbStack, 2939 LPTHREAD_START_ROUTINE lpStartAddr, 2940 LPVOID lpvThreadParm, 2941 DWORD fdwCreate, 2942 LPDWORD lpIDThread) 2943 { 2944 int iIndex; /* index into the handle table */ 2945 int iIndexNew; /* index into the handle table */ 2946 HMDeviceHandler *pDeviceHandler; /* device handler for this handle */ 2947 PHMHANDLEDATA pHMHandleData; 2948 HANDLE rc; /* API return code */ 2949 2950 SetLastError(ERROR_SUCCESS); 2951 2952 pDeviceHandler = HMGlobals.pHMThread; /* device is predefined */ 2953 2954 iIndexNew = _HMHandleGetFree(); /* get free handle */ 2955 if (-1 == iIndexNew) /* oops, no free handles ! */ 2956 { 2957 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */ 2958 return 0; 2959 } 2960 2961 /* initialize the complete HMHANDLEDATA structure */ 2962 pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData; 2963 pHMHandleData->dwType = FILE_TYPE_UNKNOWN; /* unknown handle type */ 2964 pHMHandleData->dwAccess = 0; 2965 pHMHandleData->dwShare = 0; 2966 pHMHandleData->dwCreation = 0; 2967 pHMHandleData->dwFlags = 0; 2968 pHMHandleData->lpHandlerData = NULL; 2969 2970 2971 /* we've got to mark the handle as occupied here, since another device */ 2972 /* could be created within the device handler -> deadlock */ 2973 2974 /* write appropriate entry into the handle table if open succeeded */ 2975 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew; 2976 TabWin32Handles[iIndexNew].pDeviceHandler = pDeviceHandler; 2977 2978 /* call the device handler */ 2979 2980 // @@@PH: Note: hFile is a Win32-style handle, it's not (yet) converted to 2981 // a valid HandleManager-internal handle! 2982 rc = pDeviceHandler->CreateThread(&TabWin32Handles[iIndexNew].hmHandleData, 2983 lpsa, cbStack, lpStartAddr, 2984 lpvThreadParm, fdwCreate, lpIDThread); 2985 2986 if (rc == 0) /* oops, creation failed within the device handler */ 2987 { 2988 TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE; 2989 return 0; /* signal error */ 2990 } 2991 2992 return iIndexNew; 2993 } 2994 /***************************************************************************** 2995 * Name : HMGetThreadPriority 2996 * Purpose : router function for GetThreadPriority 2997 * Parameters: 2998 * Variables : 2999 * Result : 3000 * Remark : 3001 * Status : 3002 * 3003 * Author : SvL 3004 *****************************************************************************/ 3005 INT HMGetThreadPriority(HANDLE hThread) 3006 { 3007 int iIndex; /* index into the handle table */ 3008 INT lpResult; /* result from the device handler's API */ 3009 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 3010 3011 SetLastError(ERROR_SUCCESS); 3012 /* validate handle */ 3013 iIndex = _HMHandleQuery(hThread); /* get the index */ 3014 if (-1 == iIndex) /* error ? */ 3015 { 3016 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 3017 return (-1); /* signal failure */ 3018 } 3019 3020 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 3021 lpResult = pHMHandle->pDeviceHandler->GetThreadPriority(&TabWin32Handles[iIndex].hmHandleData); 3022 3023 return (lpResult); /* deliver return code */ 3024 } 3025 /***************************************************************************** 3026 * Name : HMSuspendThread 3027 * Purpose : router function for SuspendThread 3028 * Parameters: 3029 * Variables : 3030 * Result : 3031 * Remark : 3032 * Status : 3033 * 3034 * Author : SvL 3035 *****************************************************************************/ 3036 DWORD HMSuspendThread(HANDLE hThread) 3037 { 3038 int iIndex; /* index into the handle table */ 3039 HANDLE lpResult; /* result from the device handler's API */ 3040 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 3041 3042 SetLastError(ERROR_SUCCESS); 3043 /* validate handle */ 3044 iIndex = _HMHandleQuery(hThread); /* get the index */ 3045 if (-1 == iIndex) /* error ? */ 3046 { 3047 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 3048 return -1; /* signal failure */ 3049 } 3050 3051 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 3052 lpResult = pHMHandle->pDeviceHandler->SuspendThread(&TabWin32Handles[iIndex].hmHandleData); 3053 3054 return (lpResult); /* deliver return code */ 3055 } 3056 /***************************************************************************** 3057 * Name : HMSetThreadPriority 3058 * Purpose : router function for SetThreadPriority 3059 * Parameters: 3060 * Variables : 3061 * Result : 3062 * Remark : 3063 * Status : 3064 * 3065 * Author : SvL 3066 *****************************************************************************/ 3067 BOOL HMSetThreadPriority(HANDLE hThread, int priority) 3068 { 3069 int iIndex; /* index into the handle table */ 3070 BOOL lpResult; /* result from the device handler's API */ 3071 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 3072 3073 SetLastError(ERROR_SUCCESS); 3074 /* validate handle */ 3075 iIndex = _HMHandleQuery(hThread); /* get the index */ 3076 if (-1 == iIndex) /* error ? */ 3077 { 3078 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 3079 return FALSE; /* signal failure */ 3080 } 3081 3082 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 3083 lpResult = pHMHandle->pDeviceHandler->SetThreadPriority(&TabWin32Handles[iIndex].hmHandleData, priority); 3084 3085 return (lpResult); /* deliver return code */ 3086 } 3087 /***************************************************************************** 3088 * Name : HMGetThreadContext 3089 * Purpose : router function for GetThreadContext 3090 * Parameters: 3091 * Variables : 3092 * Result : 3093 * Remark : 3094 * Status : 3095 * 3096 * Author : SvL 3097 *****************************************************************************/ 3098 BOOL HMGetThreadContext(HANDLE hThread, CONTEXT *lpContext) 3099 { 3100 int iIndex; /* index into the handle table */ 3101 BOOL lpResult; /* result from the device handler's API */ 3102 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 3103 3104 SetLastError(ERROR_SUCCESS); 3105 /* validate handle */ 3106 iIndex = _HMHandleQuery(hThread); /* get the index */ 3107 if (-1 == iIndex) /* error ? */ 3108 { 3109 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 3110 return FALSE; /* signal failure */ 3111 } 3112 3113 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 3114 lpResult = pHMHandle->pDeviceHandler->GetThreadContext(&TabWin32Handles[iIndex].hmHandleData, lpContext); 3115 3116 return (lpResult); /* deliver return code */ 3117 } 3118 /***************************************************************************** 3119 * Name : HMSetThreadContext 3120 * Purpose : router function for SetThreadContext 3121 * Parameters: 3122 * Variables : 3123 * Result : 3124 * Remark : 3125 * Status : 3126 * 3127 * Author : SvL 3128 *****************************************************************************/ 3129 BOOL HMSetThreadContext(HANDLE hThread, const CONTEXT *lpContext) 3130 { 3131 int iIndex; /* index into the handle table */ 3132 BOOL lpResult; /* result from the device handler's API */ 3133 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 3134 3135 SetLastError(ERROR_SUCCESS); 3136 /* validate handle */ 3137 iIndex = _HMHandleQuery(hThread); /* get the index */ 3138 if (-1 == iIndex) /* error ? */ 3139 { 3140 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 3141 return FALSE; /* signal failure */ 3142 } 3143 3144 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 3145 lpResult = pHMHandle->pDeviceHandler->SetThreadContext(&TabWin32Handles[iIndex].hmHandleData, lpContext); 3146 3147 return (lpResult); /* deliver return code */ 3148 } 3149 /***************************************************************************** 3150 * Name : HMTerminateThread 3151 * Purpose : router function for TerminateThread 3152 * Parameters: 3153 * Variables : 3154 * Result : 3155 * Remark : 3156 * Status : 3157 * 3158 * Author : SvL 3159 *****************************************************************************/ 3160 BOOL HMTerminateThread(HANDLE hThread, DWORD exitcode) 3161 { 3162 int iIndex; /* index into the handle table */ 3163 BOOL lpResult; /* result from the device handler's API */ 3164 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 3165 3166 SetLastError(ERROR_SUCCESS); 3167 /* validate handle */ 3168 iIndex = _HMHandleQuery(hThread); /* get the index */ 3169 if (-1 == iIndex) /* error ? */ 3170 { 3171 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 3172 return FALSE; /* signal failure */ 3173 } 3174 3175 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 3176 lpResult = pHMHandle->pDeviceHandler->TerminateThread(&TabWin32Handles[iIndex].hmHandleData, exitcode); 3177 3178 return (lpResult); /* deliver return code */ 3179 } 3180 /***************************************************************************** 3181 * Name : HMResumeThread 3182 * Purpose : router function for ResumeThread 3183 * Parameters: 3184 * Variables : 3185 * Result : 3186 * Remark : 3187 * Status : 3188 * 3189 * Author : SvL 3190 *****************************************************************************/ 3191 DWORD HMResumeThread(HANDLE hThread) 3192 { 3193 int iIndex; /* index into the handle table */ 3194 DWORD lpResult; /* result from the device handler's API */ 3195 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 3196 3197 SetLastError(ERROR_SUCCESS); 3198 /* validate handle */ 3199 iIndex = _HMHandleQuery(hThread); /* get the index */ 3200 if (-1 == iIndex) /* error ? */ 3201 { 3202 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 3203 return -1; /* signal failure */ 3204 } 3205 3206 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 3207 lpResult = pHMHandle->pDeviceHandler->ResumeThread(&TabWin32Handles[iIndex].hmHandleData); 3208 3209 return (lpResult); /* deliver return code */ 3210 } 3211 3212 /***************************************************************************** 3213 * Name : HMGetExitCodeThread 3214 * Purpose : router function for GetExitCodeThread 3215 * Parameters: 3216 * Variables : 3217 * Result : 3218 * Remark : 3219 * Status : 3220 * 3221 * Author : SvL 3222 *****************************************************************************/ 3223 BOOL HMGetExitCodeThread(HANDLE hThread, LPDWORD lpExitCode) 3224 { 3225 int iIndex; /* index into the handle table */ 3226 BOOL lpResult; /* result from the device handler's API */ 3227 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 3228 3229 SetLastError(ERROR_SUCCESS); 3230 /* validate handle */ 3231 iIndex = _HMHandleQuery(hThread); /* get the index */ 3232 if (-1 == iIndex) /* error ? */ 3233 { 3234 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 3235 return FALSE; /* signal failure */ 3236 } 3237 3238 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 3239 lpResult = pHMHandle->pDeviceHandler->GetExitCodeThread(&TabWin32Handles[iIndex].hmHandleData, lpExitCode); 3240 3241 return (lpResult); /* deliver return code */ 3242 } 3243 /***************************************************************************** 3244 * Name : HMSetThreadTerminated 3245 * Purpose : 3246 * Parameters: 3247 * Variables : 3248 * Result : 3249 * Remark : 3250 * Status : 3251 * 3252 * Author : SvL 3253 *****************************************************************************/ 3254 BOOL HMSetThreadTerminated(HANDLE hThread) 3255 { 3256 int iIndex; /* index into the handle table */ 3257 BOOL lpResult; /* result from the device handler's API */ 3258 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */ 3259 3260 SetLastError(ERROR_SUCCESS); 3261 /* validate handle */ 3262 iIndex = _HMHandleQuery(hThread); /* get the index */ 3263 if (-1 == iIndex) /* error ? */ 3264 { 3265 SetLastError(ERROR_INVALID_HANDLE); /* set win32 error information */ 3266 return FALSE; /* signal failure */ 3267 } 3268 3269 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 3270 lpResult = pHMHandle->pDeviceHandler->SetThreadTerminated(&TabWin32Handles[iIndex].hmHandleData); 3271 3272 return (lpResult); /* deliver return code */ 3273 } -
trunk/src/kernel32/dbglocal.cpp
r3059 r3128 1 /* $Id: dbglocal.cpp,v 1. 3 2000-03-09 19:03:18sandervl Exp $ */1 /* $Id: dbglocal.cpp,v 1.4 2000-03-16 19:20:37 sandervl Exp $ */ 2 2 3 3 /* … … 112 112 "oslibdebug", 113 113 "registry", 114 "queue" 114 "queue", 115 "hmthread", 116 "hmprocess" 115 117 }; 116 118 //****************************************************************************** -
trunk/src/kernel32/dbglocal.h
r3059 r3128 1 /* $Id: dbglocal.h,v 1. 3 2000-03-09 19:03:18sandervl Exp $ */1 /* $Id: dbglocal.h,v 1.4 2000-03-16 19:20:37 sandervl Exp $ */ 2 2 3 3 /* … … 113 113 #define DBG_registry 92 114 114 #define DBG_queue 93 115 #define DBG_MAXFILES 94 115 #define DBG_hmthread 94 116 #define DBG_hmprocess 95 117 #define DBG_MAXFILES 96 116 118 117 119 extern USHORT DbgEnabled[DBG_MAXFILES]; -
trunk/src/kernel32/hmdevice.cpp
r2802 r3128 1 /* $Id: hmdevice.cpp,v 1.1 6 2000-02-16 14:23:58sandervl Exp $ */1 /* $Id: hmdevice.cpp,v 1.17 2000-03-16 19:20:37 sandervl Exp $ */ 2 2 3 3 /* … … 1173 1173 return ERROR_INVALID_HANDLE; 1174 1174 } 1175 /***************************************************************************** 1176 * Name : DWORD HMDeviceHandler::CreateThread 1177 * Purpose : 1178 * Variables : 1179 * Result : 1180 * Remark : 1181 * Status : 1182 * 1183 * Author : SvL 1184 *****************************************************************************/ 1185 HANDLE HMDeviceHandler::CreateThread(PHMHANDLEDATA pHMHandleData, 1186 LPSECURITY_ATTRIBUTES lpsa, 1187 DWORD cbStack, 1188 LPTHREAD_START_ROUTINE lpStartAddr, 1189 LPVOID lpvThreadParm, 1190 DWORD fdwCreate, 1191 LPDWORD lpIDThread) 1192 { 1193 dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::CreateThread %08xh", 1194 pHMHandleData->hHMHandle)); 1195 1196 return ERROR_INVALID_HANDLE; 1197 } 1198 /***************************************************************************** 1199 * Name : DWORD HMDeviceHandler::GetThreadPriority 1200 * Purpose : 1201 * Variables : 1202 * Result : 1203 * Remark : 1204 * Status : 1205 * 1206 * Author : SvL 1207 *****************************************************************************/ 1208 INT HMDeviceHandler::GetThreadPriority(PHMHANDLEDATA pHMHandleData) 1209 { 1210 dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::GetThreadPriority %08xh", 1211 pHMHandleData->hHMHandle)); 1212 1213 return ERROR_INVALID_HANDLE; 1214 } 1215 /***************************************************************************** 1216 * Name : DWORD HMDeviceHandler::SuspendThread 1217 * Purpose : 1218 * Variables : 1219 * Result : 1220 * Remark : 1221 * Status : 1222 * 1223 * Author : SvL 1224 *****************************************************************************/ 1225 DWORD HMDeviceHandler::SuspendThread(PHMHANDLEDATA pHMHandleData) 1226 { 1227 dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::SuspendThread %08xh", 1228 pHMHandleData->hHMHandle)); 1229 1230 return ERROR_INVALID_HANDLE; 1231 } 1232 /***************************************************************************** 1233 * Name : DWORD HMDeviceHandler::SetThreadPriority 1234 * Purpose : 1235 * Variables : 1236 * Result : 1237 * Remark : 1238 * Status : 1239 * 1240 * Author : SvL 1241 *****************************************************************************/ 1242 BOOL HMDeviceHandler::SetThreadPriority(PHMHANDLEDATA pHMHandleData, int priority) 1243 { 1244 dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::SetThreadPriority %08xh", 1245 pHMHandleData->hHMHandle)); 1246 1247 return ERROR_INVALID_HANDLE; 1248 } 1249 /***************************************************************************** 1250 * Name : DWORD HMDeviceHandler::GetThreadContext 1251 * Purpose : 1252 * Variables : 1253 * Result : 1254 * Remark : 1255 * Status : 1256 * 1257 * Author : SvL 1258 *****************************************************************************/ 1259 BOOL HMDeviceHandler::GetThreadContext(PHMHANDLEDATA pHMHandleData, PCONTEXT lpContext) 1260 { 1261 dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::GetThreadContext %08xh", 1262 pHMHandleData->hHMHandle)); 1263 1264 return ERROR_INVALID_HANDLE; 1265 } 1266 /***************************************************************************** 1267 * Name : DWORD HMDeviceHandler::SetThreadContext 1268 * Purpose : 1269 * Variables : 1270 * Result : 1271 * Remark : 1272 * Status : 1273 * 1274 * Author : SvL 1275 *****************************************************************************/ 1276 BOOL HMDeviceHandler::SetThreadContext(PHMHANDLEDATA pHMHandleData, const CONTEXT *lpContext) 1277 { 1278 dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::SetThreadContext %08xh", 1279 pHMHandleData->hHMHandle)); 1280 1281 return ERROR_INVALID_HANDLE; 1282 } 1283 /***************************************************************************** 1284 * Name : DWORD HMDeviceHandler::TerminateThread 1285 * Purpose : 1286 * Variables : 1287 * Result : 1288 * Remark : 1289 * Status : 1290 * 1291 * Author : SvL 1292 *****************************************************************************/ 1293 BOOL HMDeviceHandler::TerminateThread(PHMHANDLEDATA pHMHandleData, DWORD exitcode) 1294 { 1295 dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::TerminateThread %08xh", 1296 pHMHandleData->hHMHandle)); 1297 1298 return ERROR_INVALID_HANDLE; 1299 } 1300 /***************************************************************************** 1301 * Name : DWORD HMDeviceHandler::ResumeThread 1302 * Purpose : 1303 * Variables : 1304 * Result : 1305 * Remark : 1306 * Status : 1307 * 1308 * Author : SvL 1309 *****************************************************************************/ 1310 DWORD HMDeviceHandler::ResumeThread(PHMHANDLEDATA pHMHandleData) 1311 { 1312 dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::ResumeThread %08xh", 1313 pHMHandleData->hHMHandle)); 1314 1315 return ERROR_INVALID_HANDLE; 1316 } 1317 /***************************************************************************** 1318 * Name : DWORD HMDeviceHandler::GetExitCodeThread 1319 * Purpose : 1320 * Variables : 1321 * Result : 1322 * Remark : 1323 * Status : 1324 * 1325 * Author : SvL 1326 *****************************************************************************/ 1327 BOOL HMDeviceHandler::GetExitCodeThread(PHMHANDLEDATA pHMHandleData, LPDWORD lpExitCode) 1328 { 1329 dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::GetExitCodeThread %08xh", 1330 pHMHandleData->hHMHandle)); 1331 1332 return ERROR_INVALID_HANDLE; 1333 } 1334 /***************************************************************************** 1335 * Name : DWORD HMDeviceHandler::SetThreadTerminated 1336 * Purpose : 1337 * Variables : 1338 * Result : 1339 * Remark : 1340 * Status : 1341 * 1342 * Author : SvL 1343 *****************************************************************************/ 1344 BOOL HMDeviceHandler::SetThreadTerminated(PHMHANDLEDATA pHMHandleData) 1345 { 1346 return FALSE; 1347 } -
trunk/src/kernel32/hmdevice.h
r2329 r3128 1 /* $Id: hmdevice.h,v 1.1 5 2000-01-05 19:39:56sandervl Exp $ */1 /* $Id: hmdevice.h,v 1.16 2000-03-16 19:20:38 sandervl Exp $ */ 2 2 3 3 /* … … 30 30 #define HMTYPE_PROCESSTOKEN 3 31 31 #define HMTYPE_THREADTOKEN 4 32 #define HMTYPE_THREAD 5 33 32 34 //..... 33 35 … … 66 68 67 69 HMDeviceHandler(LPCSTR lpDeviceName); /* constructor with device name */ 68 69 70 70 71 /*********************************** … … 302 303 HANDLE ProcessHandle); 303 304 305 virtual HANDLE CreateThread(PHMHANDLEDATA pHMHandleData, 306 LPSECURITY_ATTRIBUTES lpsa, 307 DWORD cbStack, 308 LPTHREAD_START_ROUTINE lpStartAddr, 309 LPVOID lpvThreadParm, 310 DWORD fdwCreate, 311 LPDWORD lpIDThread); 312 313 virtual INT GetThreadPriority(PHMHANDLEDATA pHMHandleData); 314 virtual DWORD SuspendThread(PHMHANDLEDATA pHMHandleData); 315 virtual BOOL SetThreadPriority(PHMHANDLEDATA pHMHandleData, int priority); 316 317 virtual BOOL GetThreadContext(PHMHANDLEDATA pHMHandleData, PCONTEXT lpContext); 318 virtual BOOL SetThreadContext(PHMHANDLEDATA pHMHandleData, const CONTEXT *lpContext); 319 320 virtual BOOL TerminateThread(PHMHANDLEDATA pHMHandleData, DWORD exitcode); 321 virtual DWORD ResumeThread(PHMHANDLEDATA pHMHandleData); 322 virtual BOOL SetThreadTerminated(PHMHANDLEDATA pHMHandleData); 323 324 virtual BOOL GetExitCodeThread(PHMHANDLEDATA pHMHandleData, LPDWORD lpExitCode); 304 325 }; 305 326 -
trunk/src/kernel32/initterm.cpp
r3074 r3128 1 /* $Id: initterm.cpp,v 1.3 8 2000-03-10 16:11:59 sandervl Exp $ */1 /* $Id: initterm.cpp,v 1.39 2000-03-16 19:20:39 sandervl Exp $ */ 2 2 3 3 /* … … 159 159 OSLibDosSetInitialMaxFileHandles(ODIN_DEFAULT_MAX_FILEHANDLES); 160 160 161 InitializeTIB(TRUE);162 161 //SvL: Do it here instead of during the exe object creation 163 162 //(std handles can be used in win32 dll initialization routines 164 163 HMInitialize(); /* store standard handles within HandleManager */ 164 InitializeTIB(TRUE); //MUST be done after HMInitialize! 165 165 InitDirectories(); 166 166 RegisterDevices(); … … 192 192 //Flush and delete all open memory mapped files 193 193 Win32MemMap::deleteAll(); 194 WinExe = NULL; 194 195 195 196 WriteOutProfiles(); -
trunk/src/kernel32/kobjects.cpp
r2802 r3128 1 /* $Id: kobjects.cpp,v 1. 9 2000-02-16 14:25:41sandervl Exp $ */1 /* $Id: kobjects.cpp,v 1.10 2000-03-16 19:20:39 sandervl Exp $ */ 2 2 3 3 /* … … 786 786 } 787 787 788 788 //****************************************************************************** 789 //****************************************************************************** 790 ODINFUNCTION6(HANDLE,CreateThread,LPSECURITY_ATTRIBUTES, lpsa, 791 DWORD, cbStack, 792 LPTHREAD_START_ROUTINE, lpStartAddr, 793 LPVOID, lpvThreadParm, 794 DWORD, fdwCreate, 795 LPDWORD, lpIDThread) 796 { 797 return HMCreateThread(lpsa, cbStack, lpStartAddr, lpvThreadParm, fdwCreate, lpIDThread); 798 } 799 //****************************************************************************** 800 //****************************************************************************** 801 INT WIN32API GetThreadPriority(HANDLE hThread) 802 { 803 return HMGetThreadPriority(hThread); 804 } 805 //****************************************************************************** 806 //****************************************************************************** 807 DWORD WIN32API SuspendThread(HANDLE hThread) 808 { 809 return HMSuspendThread(hThread); 810 } 811 //****************************************************************************** 812 //****************************************************************************** 813 BOOL WIN32API SetThreadPriority(HANDLE hThread, int priority) 814 { 815 return HMSetThreadPriority(hThread, priority); 816 } 817 //****************************************************************************** 818 //****************************************************************************** 819 BOOL WIN32API GetThreadContext(HANDLE hThread, PCONTEXT lpContext) 820 { 821 return HMGetThreadContext(hThread, lpContext); 822 } 823 //****************************************************************************** 824 //****************************************************************************** 825 BOOL WIN32API SetThreadContext(HANDLE hThread, const CONTEXT *lpContext) 826 { 827 return HMSetThreadContext(hThread, lpContext); 828 } 829 //****************************************************************************** 830 //****************************************************************************** 831 BOOL WIN32API TerminateThread(HANDLE hThread, DWORD exitcode) 832 { 833 return HMTerminateThread(hThread, exitcode); 834 } 835 //****************************************************************************** 836 //****************************************************************************** 837 DWORD WIN32API ResumeThread(HANDLE hThread) 838 { 839 return HMResumeThread(hThread); 840 } 841 //****************************************************************************** 842 //****************************************************************************** 843 BOOL WIN32API GetExitCodeThread(HANDLE hThread, LPDWORD arg2) 844 { 845 return HMGetExitCodeThread(hThread, arg2); 846 } 847 //****************************************************************************** 848 //****************************************************************************** -
trunk/src/kernel32/makefile
r3059 r3128 1 # $Id: makefile,v 1.9 0 2000-03-09 19:03:19 sandervl Exp $1 # $Id: makefile,v 1.91 2000-03-16 19:20:39 sandervl Exp $ 2 2 3 3 # … … 118 118 $(OBJDIR)\registry.obj \ 119 119 $(OBJDIR)\queue.obj \ 120 $(OBJDIR)\hmthread.obj \ 120 121 $(OBJDIR)\kernelrsrc.obj 121 122 -
trunk/src/kernel32/thread.H
r126 r3128 1 /* $Id: thread.H,v 1. 5 1999-06-20 10:55:36sandervl Exp $ */1 /* $Id: thread.H,v 1.6 2000-03-16 19:20:40 sandervl Exp $ */ 2 2 3 3 /* … … 20 20 { 21 21 public: 22 Win32Thread(LPTHREAD_START_ROUTINE pUserCallback, LPVOID lpData, DWORD dwFlags); 23 ~Win32Thread(); 22 Win32Thread(LPTHREAD_START_ROUTINE pUserCallback, LPVOID lpData, DWORD dwFlags, HANDLE hThread); 24 23 25 PTHREAD_START_ROUTINE_O32 GetOS2Callback(); 24 PTHREAD_START_ROUTINE_O32 GetOS2Callback() { return Win32ThreadProc; }; 25 26 26 private: 27 27 … … 29 29 LPTHREAD_START_ROUTINE pCallback; 30 30 DWORD dwFlags; 31 HANDLE hThread; 31 32 32 friend staticDWORD OPEN32API Win32ThreadProc(LPVOID lpData);33 friend DWORD OPEN32API Win32ThreadProc(LPVOID lpData); 33 34 }; 34 35 -
trunk/src/kernel32/thread.cpp
r2802 r3128 1 /* $Id: thread.cpp,v 1.2 3 2000-02-16 14:23:12sandervl Exp $ */1 /* $Id: thread.cpp,v 1.24 2000-03-16 19:20:40 sandervl Exp $ */ 2 2 3 3 /* … … 24 24 #include <string.h> 25 25 #include "thread.h" 26 #include "exceptutil.h"27 26 #include <misc.h> 28 27 #include <wprocess.h> … … 31 30 #include "exceptutil.h" 32 31 #include "oslibmisc.h" 32 #include <handlemanager.h> 33 33 34 34 #define DBG_LOCALLOG DBG_thread … … 37 37 ODINDEBUGCHANNEL(KERNEL32-THREAD) 38 38 39 40 static DWORD OPEN32API Win32ThreadProc(LPVOID lpData);41 42 43 //******************************************************************************44 //******************************************************************************45 ODINFUNCTION6(HANDLE,CreateThread,LPSECURITY_ATTRIBUTES, lpsa,46 DWORD, cbStack,47 LPTHREAD_START_ROUTINE, lpStartAddr,48 LPVOID, lpvThreadParm,49 DWORD, fdwCreate,50 LPDWORD, lpIDThread)51 {52 Win32Thread *winthread;53 54 winthread = new Win32Thread(lpStartAddr, lpvThreadParm, fdwCreate);55 56 if(winthread == 0)57 return(0);58 59 #ifdef DEBUG60 // @@@PH Note: with debug code enabled, ODIN might request more stack space!61 if (cbStack > 0)62 cbStack <<= 1; // double stack63 else64 cbStack = 1048576; // per default 1MB stack per thread65 #endif66 67 return(O32_CreateThread(lpsa,68 cbStack,69 winthread->GetOS2Callback(),70 (LPVOID)winthread,71 fdwCreate,72 lpIDThread));73 }74 39 //****************************************************************************** 75 40 //****************************************************************************** … … 83 48 HANDLE WIN32API GetCurrentThread() 84 49 { 85 //// dprintf(("GetCurrentThread\n")); 86 return(O32_GetCurrentThread()); 87 } 88 //****************************************************************************** 89 //****************************************************************************** 90 BOOL WIN32API GetExitCodeThread(HANDLE hThread, LPDWORD arg2) 91 { 92 dprintf(("GetExitCodeThread (%08xh,%08xh)\n", 93 hThread, 94 arg2)); 50 THDB *thdb; 95 51 96 return O32_GetExitCodeThread(hThread, arg2); 97 } 98 //****************************************************************************** 99 //****************************************************************************** 100 BOOL WIN32API TerminateThread(HANDLE hThread, DWORD arg2) 101 { 102 dprintf(("TerminateThread (%08xh,%08xh)\n", 103 hThread, 104 arg2)); 105 106 return O32_TerminateThread(hThread, arg2); 107 } 108 //****************************************************************************** 109 //****************************************************************************** 110 DWORD WIN32API ResumeThread(HANDLE hThread) 111 { 112 dprintf(("ResumeThread (%08xh)\n", 113 hThread)); 114 115 return O32_ResumeThread(hThread); 116 } 117 //****************************************************************************** 118 //****************************************************************************** 119 INT WIN32API GetThreadPriority(HANDLE hThread) 120 { 121 dprintf(("OS2GetThreadPriority(%08xh)\n", 122 hThread)); 123 124 return O32_GetThreadPriority(hThread); 125 } 126 //****************************************************************************** 127 //****************************************************************************** 128 DWORD WIN32API SuspendThread(HANDLE hThread) 129 { 130 dprintf(("OS2SuspendThread %08xh)\n", 131 hThread)); 132 133 return O32_SuspendThread(hThread); 134 } 135 //****************************************************************************** 136 //****************************************************************************** 137 BOOL WIN32API SetThreadPriority(HANDLE hThread, int priority) 138 { 139 dprintf(("OS2SetThreadPriority (%08xh,%08xh)\n", 140 hThread, 141 priority)); 142 143 return O32_SetThreadPriority(hThread, priority); 144 } 145 //****************************************************************************** 146 //TODO: Implement this?? 147 //****************************************************************************** 148 BOOL WIN32API GetThreadContext(HANDLE hThread, PCONTEXT lpContext) 149 { 150 dprintf(("GetThreadContext NOT IMPLEMENTED!! (TRUE)\n")); 151 memset(lpContext, 0, sizeof(CONTEXT)); 152 153 /* make up some plausible values for segment registers */ 154 lpContext->SegCs = getCS(); 155 lpContext->SegDs = getDS(); 156 lpContext->SegSs = getSS(); 157 lpContext->SegEs = getES(); 158 lpContext->SegGs = getGS(); 159 lpContext->SegFs = GetFS(); 160 161 return TRUE; 162 } 163 //****************************************************************************** 164 //TODO: Implement this?? 165 //****************************************************************************** 166 BOOL WIN32API SetThreadContext(HANDLE hThread, const CONTEXT *lpContext) 167 { 168 dprintf(("SetThreadContext NOT IMPLEMENTED!!\n")); 169 170 return FALSE; 52 thdb = GetThreadTHDB(); 53 if(thdb == 0) { 54 SetLastError(ERROR_INVALID_HANDLE); //todo 55 return 0; 56 } 57 return thdb->hThread; 171 58 } 172 59 //****************************************************************************** … … 174 61 VOID WIN32API ExitThread(DWORD exitcode) 175 62 { 176 dprintf(("ExitThread (%08xu)\n",177 exitcode));63 EXCEPTION_FRAME *exceptFrame; 64 THDB *thdb; 178 65 66 dprintf(("ExitThread %x (%x)", GetCurrentThread(), exitcode)); 67 68 thdb = GetThreadTHDB(); 69 if(thdb != 0) { 70 exceptFrame = (EXCEPTION_FRAME *)thdb->exceptFrame; 71 } 72 else DebugInt3(); 73 74 HMSetThreadTerminated(GetCurrentThread()); 179 75 Win32DllBase::detachThreadFromAllDlls(); //send DLL_THREAD_DETACH message to all dlls 180 76 Win32DllBase::tlsDetachThreadFromAllDlls(); //destroy TLS structures of all dlls 181 77 WinExe->tlsDetachThread(); //destroy TLS structure of main exe 182 78 DestroyTIB(); 79 80 if(exceptFrame) OS2UnsetExceptionHandler((void *)exceptFrame); 81 183 82 O32_ExitThread(exitcode); 184 83 } 185 84 //****************************************************************************** 186 85 //****************************************************************************** 187 Win32Thread::Win32Thread(LPTHREAD_START_ROUTINE pUserCallback, LPVOID lpData, DWORD dwFlags )86 Win32Thread::Win32Thread(LPTHREAD_START_ROUTINE pUserCallback, LPVOID lpData, DWORD dwFlags, HANDLE hThread) 188 87 { 189 88 lpUserData = lpData; 190 89 pCallback = pUserCallback; 191 90 this->dwFlags = dwFlags; 91 this->hThread = hThread; 192 92 } 193 93 //****************************************************************************** 194 94 //****************************************************************************** 195 Win32Thread::~Win32Thread() 196 { 197 198 } 199 //****************************************************************************** 200 //****************************************************************************** 201 PTHREAD_START_ROUTINE_O32 Win32Thread::GetOS2Callback() 202 { 203 return Win32ThreadProc; 204 } 205 //****************************************************************************** 206 //****************************************************************************** 207 static DWORD OPEN32API Win32ThreadProc(LPVOID lpData) 95 DWORD OPEN32API Win32ThreadProc(LPVOID lpData) 208 96 { 209 97 EXCEPTION_FRAME exceptFrame; … … 211 99 WIN32THREADPROC winthread = me->pCallback; 212 100 LPVOID userdata = me->lpUserData; 101 HANDLE hThread = me->hThread; 213 102 DWORD rc; 214 103 … … 227 116 thdb->entry_point = (void *)winthread; 228 117 thdb->entry_arg = (void *)userdata; 118 thdb->hThread = hThread; 229 119 230 120 thdb->hab = OSLibWinInitialize(); … … 235 125 // in OS/2 236 126 OS2SetExceptionHandler((void *)&exceptFrame); 127 thdb->exceptFrame = (ULONG)&exceptFrame; 237 128 238 129 SetWin32TIB(); … … 243 134 rc = winthread(userdata); 244 135 136 HMSetThreadTerminated(GetCurrentThread()); 137 thdb->exceptFrame = 0; 245 138 Win32DllBase::detachThreadFromAllDlls(); //send DLL_THREAD_DETACH message to all dlls 246 139 Win32DllBase::tlsDetachThreadFromAllDlls(); //destroy TLS structures of all dlls -
trunk/src/kernel32/wprocess.cpp
r3059 r3128 1 /* $Id: wprocess.cpp,v 1.7 2 2000-03-09 19:03:23sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.73 2000-03-16 19:20:40 sandervl Exp $ */ 2 2 3 3 /* … … 26 26 #include "winfakepeldr.h" 27 27 #include <vmutex.h> 28 #include <handlemanager.h> 28 29 29 30 #ifdef __IBMCPP__ … … 126 127 TEB *winteb; 127 128 THDB *thdb; 128 129 ULONG hThreadMain; 129 130 USHORT tibsel; 130 131 131 132 //Allocate one dword to store the flat address of our TEB 132 133 if(fMainThread) { 133 TIBFlatPtr = (DWORD *)OSLibAllocThreadLocalMemory(1); 134 if(TIBFlatPtr == 0) { 135 dprintf(("InitializeTIB: local thread memory alloc failed!!")); 136 DebugInt3(); 137 return NULL; 138 } 134 TIBFlatPtr = (DWORD *)OSLibAllocThreadLocalMemory(1); 135 if(TIBFlatPtr == 0) { 136 dprintf(("InitializeTIB: local thread memory alloc failed!!")); 137 DebugInt3(); 138 return NULL; 139 } 140 HMHandleAllocate(&hThreadMain, O32_GetCurrentThread()); 139 141 } 140 142 if(OSLibAllocSel(PAGE_SIZE, &tibsel) == FALSE) 141 143 { 142 dprintf(("InitializeTIB: selector alloc failed!!"));143 DebugInt3();144 return NULL;144 dprintf(("InitializeTIB: selector alloc failed!!")); 145 DebugInt3(); 146 return NULL; 145 147 } 146 148 winteb = (TEB *)OSLibSelToFlat(tibsel); 147 149 if(winteb == NULL) 148 150 { 149 dprintf(("InitializeTIB: DosSelToFlat failed!!"));150 DebugInt3();151 return NULL;151 dprintf(("InitializeTIB: DosSelToFlat failed!!")); 152 DebugInt3(); 153 return NULL; 152 154 } 153 155 memset(winteb, 0, PAGE_SIZE); … … 173 175 thdb->pWsockData = NULL; 174 176 thdb->threadId = GetCurrentThreadId(); 175 thdb->hThread = GetCurrentThread(); 177 if(fMainThread) { 178 thdb->hThread = hThreadMain; 179 } 180 else thdb->hThread = GetCurrentThread(); 176 181 177 182 threadListMutex.enter();
Note:
See TracChangeset
for help on using the changeset viewer.