Changeset 4658 for trunk/src/kernel32/wprocess.cpp
- Timestamp:
- Nov 21, 2000, 12:36:09 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/wprocess.cpp
r4555 r4658 1 /* $Id: wprocess.cpp,v 1.10 7 2000-11-05 13:40:47sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.108 2000-11-21 11:35:09 sandervl Exp $ */ 2 2 3 3 /* … … 71 71 72 72 //list of thread database structures 73 static T HDB*threadList = 0;73 static TEB *threadList = 0; 74 74 static VMutex threadListMutex; 75 75 … … 100 100 //****************************************************************************** 101 101 //****************************************************************************** 102 THDB *WIN32API GetThreadTHDB() 103 { 104 TEB *winteb; 105 THDB *thdb; 106 107 if(TIBFlatPtr == NULL) 108 return 0; 109 110 winteb = (TEB *)*TIBFlatPtr; 111 if(winteb == NULL) { 112 return NULL; 113 } 114 thdb = (THDB *)(winteb+1); 115 116 return thdb; 117 } 118 //****************************************************************************** 119 //****************************************************************************** 120 THDB *WIN32API GetTHDBFromThreadId(ULONG threadId) 121 { 122 THDB *thdb = threadList; 102 TEB *WIN32API GetTEBFromThreadId(ULONG threadId) 103 { 104 TEB *teb = threadList; 123 105 124 106 threadListMutex.enter(); 125 while(t hdb) {126 if(t hdb->threadId == threadId) {107 while(teb) { 108 if(teb->o.odin.threadId == threadId) { 127 109 break; 128 110 } 129 t hdb = thdb->next;111 teb = teb->o.odin.next; 130 112 } 131 113 threadListMutex.leave(); 132 return t hdb;133 } 134 //****************************************************************************** 135 //****************************************************************************** 136 T HDB *WIN32API GetTHDBFromThreadHandle(HANDLE hThread)137 { 138 T HDB *thdb = threadList;114 return teb; 115 } 116 //****************************************************************************** 117 //****************************************************************************** 118 TEB *WIN32API GetTEBFromThreadHandle(HANDLE hThread) 119 { 120 TEB *teb = threadList; 139 121 140 122 threadListMutex.enter(); 141 while(t hdb) {142 if(t hdb->hThread == hThread) {123 while(teb) { 124 if(teb->o.odin.hThread == hThread) { 143 125 break; 144 126 } 145 t hdb = thdb->next;127 teb = teb->o.odin.next; 146 128 } 147 129 threadListMutex.leave(); 148 return t hdb;130 return teb; 149 131 } 150 132 //****************************************************************************** … … 154 136 { 155 137 TEB *winteb; 156 THDB *thdb;157 138 ULONG hThreadMain; 158 139 USHORT tibsel; … … 170 151 hThreadMain = HMCreateThread(NULL, 0, 0, 0, 0, 0, TRUE); 171 152 } 172 if(OSLibAllocSel( PAGE_SIZE, &tibsel) == FALSE)153 if(OSLibAllocSel(sizeof(TEB), &tibsel) == FALSE) 173 154 { 174 155 dprintf(("InitializeTIB: selector alloc failed!!")); … … 183 164 return NULL; 184 165 } 185 memset(winteb, 0, PAGE_SIZE); 186 thdb = (THDB *)(winteb+1); 166 memset(winteb, 0, sizeof(TEB)); 187 167 *TIBFlatPtr = (DWORD)winteb; 188 168 … … 195 175 winteb->flags = TEBF_WIN32; /* 1c Flags */ 196 176 winteb->queue = 0; /* 28 Message queue */ 197 winteb->tls_ptr = & thdb->tls_array[0];/* 2c Pointer to TLS array */177 winteb->tls_ptr = &winteb->tls_array[0]; /* 2c Pointer to TLS array */ 198 178 winteb->process = &ProcessPDB; /* 30 owning process (used by NT3.51 applets)*/ 199 179 200 memcpy(&thdb->teb, winteb, sizeof(TEB)); 201 thdb->process = &ProcessPDB; 202 thdb->exit_code = 0x103; /* STILL_ACTIVE */ 203 thdb->teb_sel = tibsel; 204 thdb->OrgTIBSel = GetFS(); 205 thdb->pWsockData = NULL; 206 thdb->threadId = GetCurrentThreadId(); 180 winteb->process = &ProcessPDB; 181 winteb->exit_code = 0x103; /* STILL_ACTIVE */ 182 winteb->teb_sel = tibsel; 183 winteb->o.odin.OrgTIBSel = GetFS(); 184 winteb->o.odin.pWsockData = NULL; 185 winteb->o.odin.threadId = GetCurrentThreadId(); 207 186 if(fMainThread) { 208 thdb->hThread = hThreadMain;209 } 210 else thdb->hThread = GetCurrentThread();211 thdb->lcid = GetUserDefaultLCID();187 winteb->o.odin.hThread = hThreadMain; 188 } 189 else winteb->o.odin.hThread = GetCurrentThread(); 190 winteb->o.odin.lcid = GetUserDefaultLCID(); 212 191 213 192 threadListMutex.enter(); 214 T HDB *thdblast = threadList;215 if(!t hdblast) {216 threadList = thdb;193 TEB *teblast = threadList; 194 if(!teblast) { 195 threadList = winteb; 217 196 } 218 197 else { 219 while(t hdblast->next) {220 t hdblast = thdblast->next;221 } 222 t hdblast->next = thdb;223 } 224 thdb->next= NULL;198 while(teblast->o.odin.next) { 199 teblast = teblast->o.odin.next; 200 } 201 teblast->o.odin.next = winteb; 202 } 203 winteb->o.odin.next = NULL; 225 204 threadListMutex.leave(); 226 205 227 206 if(OSLibGetPIB(PIB_TASKTYPE) == TASKTYPE_PM) 228 207 { 229 thdb->flags = 0; //todo gui230 } 231 else thdb->flags = 0; //todo textmode208 winteb->flags = 0; //todo gui 209 } 210 else winteb->flags = 0; //todo textmode 232 211 233 212 //Initialize thread security objects (TODO: Not complete) … … 240 219 } 241 220 SID_IDENTIFIER_AUTHORITY sidIdAuth = {0}; 242 thdb->threadinfo.dwType = SECTYPE_PROCESS | SECTYPE_INITIALIZED;243 RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, & thdb->threadinfo.SidUser.User.Sid);244 thdb->threadinfo.SidUser.User.Attributes = 0; //?????????245 246 thdb->threadinfo.pTokenGroups = (TOKEN_GROUPS*)malloc(sizeof(TOKEN_GROUPS));247 thdb->threadinfo.pTokenGroups->GroupCount = 1;248 RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, & thdb->threadinfo.PrimaryGroup.PrimaryGroup);249 thdb->threadinfo.pTokenGroups->Groups[0].Sid = thdb->threadinfo.PrimaryGroup.PrimaryGroup;250 thdb->threadinfo.pTokenGroups->Groups[0].Attributes = 0; //????221 winteb->o.odin.threadinfo.dwType = SECTYPE_PROCESS | SECTYPE_INITIALIZED; 222 RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &winteb->o.odin.threadinfo.SidUser.User.Sid); 223 winteb->o.odin.threadinfo.SidUser.User.Attributes = 0; //????????? 224 225 winteb->o.odin.threadinfo.pTokenGroups = (TOKEN_GROUPS*)malloc(sizeof(TOKEN_GROUPS)); 226 winteb->o.odin.threadinfo.pTokenGroups->GroupCount = 1; 227 RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &winteb->o.odin.threadinfo.PrimaryGroup.PrimaryGroup); 228 winteb->o.odin.threadinfo.pTokenGroups->Groups[0].Sid = winteb->o.odin.threadinfo.PrimaryGroup.PrimaryGroup; 229 winteb->o.odin.threadinfo.pTokenGroups->Groups[0].Attributes = 0; //???? 251 230 // pPrivilegeSet = NULL; 252 231 // pTokenPrivileges= NULL; … … 254 233 // DefaultDACL = {0}; 255 234 // TokenSource = {0}; 256 thdb->threadinfo.TokenType = TokenPrimary;235 winteb->o.odin.threadinfo.TokenType = TokenPrimary; 257 236 258 237 if(fMainThread) … … 293 272 SHORT orgtibsel; 294 273 TEB *winteb; 295 THDB *thdb;296 274 297 275 dprintf(("DestroyTIB: FS = %x", GetFS())); … … 300 278 winteb = (TEB *)*TIBFlatPtr; 301 279 if(winteb) { 302 thdb = (THDB *)(winteb+1); 303 orgtibsel = thdb->OrgTIBSel; 280 orgtibsel = winteb->o.odin.OrgTIBSel; 281 282 dprintf(("DestroyTIB: OSLibFreeSel %x", winteb->teb_sel)); 304 283 305 284 threadListMutex.enter(); 306 T HDB *curthdb = threadList;307 if(curt hdb == thdb) {308 threadList = thdb->next;285 TEB *curteb = threadList; 286 if(curteb == winteb) { 287 threadList = winteb->o.odin.next; 309 288 } 310 289 else { 311 while(curt hdb->next != thdb) {312 curt hdb = curthdb->next;313 if(curt hdb == NULL) {314 dprintf(("DestroyTIB: couldn't find t hdb %x", thdb));290 while(curteb->o.odin.next != winteb) { 291 curteb = curteb->o.odin.next; 292 if(curteb == NULL) { 293 dprintf(("DestroyTIB: couldn't find teb %x", winteb)); 315 294 DebugInt3(); 316 295 break; 317 296 } 318 297 } 319 if(curt hdb) {320 curt hdb->next = thdb->next;298 if(curteb) { 299 curteb->o.odin.next = winteb->o.odin.next; 321 300 } 322 301 } … … 327 306 328 307 //And free our own 329 OSLibFreeSel( thdb->teb_sel);308 OSLibFreeSel(winteb->teb_sel); 330 309 331 310 *TIBFlatPtr = 0; … … 348 327 SHORT orgtibsel; 349 328 TEB *winteb; 350 THDB *thdb;351 329 352 330 //If we're running an Odin32 OS/2 application (not converted!), then we … … 358 336 winteb = (TEB *)*TIBFlatPtr; 359 337 if(winteb) { 360 thdb = (THDB *)(winteb+1); 361 orgtibsel = thdb->OrgTIBSel; 338 orgtibsel = winteb->o.odin.OrgTIBSel; 362 339 363 340 //Restore our original FS selector … … 371 348 SHORT win32tibsel; 372 349 TEB *winteb; 373 THDB *thdb;374 350 375 351 //If we're running an Odin32 OS/2 application (not converted!), then we … … 381 357 winteb = (TEB *)*TIBFlatPtr; 382 358 if(winteb) { 383 thdb = (THDB *)(winteb+1); 384 win32tibsel = thdb->teb_sel; 359 win32tibsel = winteb->teb_sel; 385 360 386 361 //Restore our win32 FS selector … … 395 370 return GetFS(); 396 371 } 397 thdb = (THDB *)(winteb+1); 398 win32tibsel = thdb->teb_sel; 372 win32tibsel = winteb->teb_sel; 399 373 400 374 //Restore our win32 FS selector … … 1538 1512 LPPROCESS_INFORMATION lpProcessInfo ) 1539 1513 { 1540 T HDB *pThreadDB = (THDB*)GetThreadTHDB();1514 TEB *pThreadDB = (TEB*)GetThreadTEB(); 1541 1515 char *cmdline = NULL; 1542 1516 BOOL rc; … … 1557 1531 if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL) 1558 1532 { 1559 if(pThreadDB-> pidDebuggee != 0)1533 if(pThreadDB->o.odin.pidDebuggee != 0) 1560 1534 { 1561 1535 // TODO: handle this … … 1564 1538 else 1565 1539 { 1566 pThreadDB-> pidDebuggee = lpProcessInfo->dwProcessId;1567 OSLibStartDebugger((ULONG*)&pThreadDB-> pidDebuggee);1540 pThreadDB->o.odin.pidDebuggee = lpProcessInfo->dwProcessId; 1541 OSLibStartDebugger((ULONG*)&pThreadDB->o.odin.pidDebuggee); 1568 1542 } 1569 1543 } 1570 else pThreadDB-> pidDebuggee = 0;1544 else pThreadDB->o.odin.pidDebuggee = 0; 1571 1545 1572 1546 return(TRUE); … … 1648 1622 if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL) 1649 1623 { 1650 if(pThreadDB-> pidDebuggee != 0)1624 if(pThreadDB->o.odin.pidDebuggee != 0) 1651 1625 { 1652 1626 // TODO: handle this … … 1655 1629 else 1656 1630 { 1657 pThreadDB-> pidDebuggee = lpProcessInfo->dwProcessId;1658 OSLibStartDebugger((ULONG*)&pThreadDB-> pidDebuggee);1631 pThreadDB->o.odin.pidDebuggee = lpProcessInfo->dwProcessId; 1632 OSLibStartDebugger((ULONG*)&pThreadDB->o.odin.pidDebuggee); 1659 1633 } 1660 1634 } 1661 1635 else 1662 pThreadDB-> pidDebuggee = 0;1636 pThreadDB->o.odin.pidDebuggee = 0; 1663 1637 } 1664 1638 if(cmdline)
Note:
See TracChangeset
for help on using the changeset viewer.