source: trunk/src/win32k/misc/OS2KTCB.c@ 3829

Last change on this file since 3829 was 3829, checked in by bird, 25 years ago

Early development.

File size: 3.3 KB
Line 
1/* $Id: OS2KTCB.c,v 1.1 2000-07-16 22:21:17 bird Exp $
2 *
3 * TCB - Thread Control Block access methods.
4 *
5 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 *
9 */
10
11
12/*******************************************************************************
13* Header Files *
14*******************************************************************************/
15#include <os2.h>
16#include <OS2KTCB.h>
17#include "options.h"
18
19
20/*******************************************************************************
21* External Data *
22*******************************************************************************/
23/*
24 * Requires the following import(s):
25 * pTCBCur
26 */
27
28
29/*******************************************************************************
30* Global Variables *
31*******************************************************************************/
32int offTCBFailErr = 0;
33
34
35
36/*******************************************************************************
37* Internal Functions *
38*******************************************************************************/
39static BOOL initTCB(void);
40
41
42/**
43 * Init the TCB offset(s).
44 * @returns Success indicator. (TRUE = success; FALSE = failure)
45 */
46static BOOL initTCB(void)
47{
48 /*
49 * !!IMPORTANT!!
50 * Please note that when we don't define top limits here. New fixpack may have
51 * other values. But since they very seldom do, we'll gamble on no change!
52 * (Applies to Warp 3 and WS4eB)
53 * !!IMPORTANT!!
54 *
55 * These values are derived from the kernel[d].SDFs and SG24-4640-00.
56 */
57
58 /* WS4eB GA and above. */
59 if (options.ulBuild >= 14039)
60 {
61 offTCBFailErr = isSMPKernel() ? 0x1fa : 0x1ea;
62 }
63 else /* Warp 4 GA - fp12 */
64 if (options.ulBuild >= 9023 && options.ulBuild <= 9036)
65 {
66 offTCBFailErr = 0x18e;
67 }
68 else /* Warp 3 fp32 - fp62. */
69 if (options.ulBuild >= 8255 && options.ulBuild <= 8285)
70 {
71 offTCBFailErr = isSMPKernel() ? 0x1ba : 0x14e;
72 }
73 else
74 return FALSE;
75 return TRUE;
76}
77
78
79
80/**
81 * Get the content of the TCB data member TCBFailErr.
82 * Intended used to save and restore the value in ldrOpenPath.
83 * @returns Value of TCBFaileErr. (0xffff on error)
84 * @param pTCB Pointer to TCB.
85 * @remark Only known kernels are supported!
86 */
87USHORT tcbGetTCBFailErr(PTCB pTCB)
88{
89 if (offTCBFailErr == 0 || !initTCB())
90 return 0xffff;
91
92 return *(PUSHORT)(void*)((char*)(void*)pTCB + offTCBFailErr);
93}
94
95
96
97/**
98 * Set the content of the TCB data member TCBFailErr.
99 * Intended used to save and restore the value in ldrOpenPath.
100 * @returns New Value of TCBFaileErr. (0xffff on error)
101 * @param pTCB Pointer to TCB.
102 * @param TCBFAileErr New value. (or rather the old one in the save-restore case..)
103 * @remark Only known kernels are supported!
104 */
105USHORT tcbSetTCBFailErr(PTCB pTCB, USHORT TCBFailErr)
106{
107 if (offTCBFailErr == 0 || !initTCB())
108 return 0xffff;
109
110 return *(PUSHORT)(void*)((char*)(void*)pTCB + offTCBFailErr) = TCBFailErr;
111}
112
113
Note: See TracBrowser for help on using the repository browser.