Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.8 KiB

  1. //
  2. // thread.cpp
  3. //
  4. #include "private.h"
  5. #include "tlhelp32.h"
  6. #include "osver.h"
  7. #include "thdutil.h"
  8. #include "vdmdbg.h"
  9. #include "immxutil.h"
  10. //+---------------------------------------------------------------------------
  11. //
  12. // Is16bit()
  13. //
  14. //----------------------------------------------------------------------------
  15. typedef INT (*VDMENUMTASKWOW)(DWORD dwProcessId, TASKENUMPROC fp, LPARAM lParam);
  16. typedef struct tag_MYENUMWOW {
  17. DWORD dwThreadId;
  18. BOOL bRet;
  19. } MYENUMWOW;
  20. BOOL TaskEnumProc(DWORD dwThreadId, WORD hMod16, WORD hTask16, LPARAM lParam )
  21. {
  22. MYENUMWOW *pewow = (MYENUMWOW *)lParam;
  23. if (pewow->dwThreadId == dwThreadId)
  24. {
  25. pewow->bRet = TRUE;
  26. return TRUE;
  27. }
  28. return FALSE;
  29. }
  30. BOOL NTIs16bit(DWORD dwProcessId, DWORD dwThreadId)
  31. {
  32. static VDMENUMTASKWOW fpEnumTask = NULL;
  33. MYENUMWOW ewow;
  34. if (!fpEnumTask)
  35. {
  36. HINSTANCE hMod = LoadSystemLibrary("vdmdbg.dll");
  37. fpEnumTask = (VDMENUMTASKWOW)GetProcAddress(hMod, "VDMEnumTaskWOW");
  38. if (!fpEnumTask)
  39. return FALSE;
  40. }
  41. ewow.dwThreadId = dwThreadId;
  42. ewow.bRet = FALSE;
  43. fpEnumTask(dwProcessId, TaskEnumProc, (LPARAM)&ewow);
  44. return ewow.bRet;
  45. }
  46. BOOL Is16bitThread(DWORD dwProcessId, DWORD dwThreadId)
  47. {
  48. if (IsOnNT51())
  49. {
  50. GUITHREADINFO guiti;
  51. guiti.cbSize = sizeof(GUITHREADINFO);
  52. if (GetGUIThreadInfo(dwThreadId, &guiti))
  53. {
  54. return (guiti.flags & GUI_16BITTASK) ? TRUE : FALSE;
  55. }
  56. }
  57. else if (IsOnNT())
  58. {
  59. return NTIs16bit(dwProcessId, dwThreadId);
  60. }
  61. else
  62. {
  63. // Win9xEnumProcess(Win9xEnumProcessProc, NULL);
  64. // not implemented yet.
  65. Assert(0);
  66. }
  67. return FALSE;
  68. }