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.

78 lines
1.3 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. vdmtib.c
  5. Abstract:
  6. This module contains routines that provide secure access to
  7. the vdmtib from user-mode or kernel-mode object
  8. Author:
  9. Vadim Bluvshteyn (vadimb) Jul-28-1998
  10. Revision History:
  11. --*/
  12. #include "vdmp.h"
  13. #ifdef ALLOC_PRAGMA
  14. #pragma alloc_text(PAGE, VdmpGetVdmTib)
  15. #endif
  16. NTSTATUS
  17. VdmpGetVdmTib(
  18. OUT PVDM_TIB *ppVdmTib
  19. )
  20. /*++
  21. Routine Description:
  22. Arguments:
  23. Return Value:
  24. NTStatus reflecting results of the probe made to the user-mode
  25. vdmtib memory
  26. --*/
  27. {
  28. PVDM_TIB VdmTib;
  29. NTSTATUS Status = STATUS_SUCCESS;
  30. PAGED_CODE();
  31. try {
  32. VdmTib = NtCurrentTeb()->Vdm;
  33. if (VdmTib == NULL) {
  34. Status = STATUS_UNSUCCESSFUL;
  35. leave;
  36. }
  37. //
  38. // Make sure it is a valid VdmTib
  39. //
  40. ProbeForWriteSmallStructure(VdmTib, sizeof(VDM_TIB), sizeof(UCHAR));
  41. if (VdmTib->Size != sizeof(VDM_TIB)) {
  42. Status = STATUS_UNSUCCESSFUL;
  43. VdmTib = NULL;
  44. leave;
  45. }
  46. } except(EXCEPTION_EXECUTE_HANDLER) {
  47. return GetExceptionCode();
  48. }
  49. *ppVdmTib = VdmTib;
  50. return Status;
  51. }