error.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**
  2. * WinPR: Windows Portable Runtime
  3. * Error Handling Functions
  4. *
  5. * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. */
  19. #ifdef HAVE_CONFIG_H
  20. #include "config.h"
  21. #endif
  22. #include <winpr/error.h>
  23. #ifndef _WIN32
  24. #include <stdio.h>
  25. #include <winpr/nt.h>
  26. UINT GetErrorMode(void)
  27. {
  28. return 0;
  29. }
  30. UINT SetErrorMode(UINT uMode)
  31. {
  32. return 0;
  33. }
  34. DWORD GetLastError(VOID)
  35. {
  36. PTEB pt = NtCurrentTeb();
  37. if (pt)
  38. {
  39. DWORD tmp = NtCurrentTeb()->LastErrorValue;
  40. if (tmp == 0) {
  41. tmp = errno;
  42. }
  43. else {
  44. pt->LastErrorValue = 0;
  45. }
  46. return tmp;
  47. }
  48. //return ERROR_OUTOFMEMORY;
  49. return errno;
  50. }
  51. VOID SetLastError(DWORD dwErrCode)
  52. {
  53. PTEB pt = NtCurrentTeb();
  54. if (pt)
  55. {
  56. pt->LastErrorValue = dwErrCode;
  57. }
  58. }
  59. VOID RestoreLastError(DWORD dwErrCode)
  60. {
  61. }
  62. VOID RaiseException(DWORD dwExceptionCode, DWORD dwExceptionFlags, DWORD nNumberOfArguments,
  63. CONST ULONG_PTR* lpArguments)
  64. {
  65. }
  66. LONG UnhandledExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo)
  67. {
  68. return 0;
  69. }
  70. LPTOP_LEVEL_EXCEPTION_FILTER
  71. SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
  72. {
  73. return NULL;
  74. }
  75. PVOID AddVectoredExceptionHandler(ULONG First, PVECTORED_EXCEPTION_HANDLER Handler)
  76. {
  77. return NULL;
  78. }
  79. ULONG RemoveVectoredExceptionHandler(PVOID Handle)
  80. {
  81. return 0;
  82. }
  83. PVOID AddVectoredContinueHandler(ULONG First, PVECTORED_EXCEPTION_HANDLER Handler)
  84. {
  85. return NULL;
  86. }
  87. ULONG RemoveVectoredContinueHandler(PVOID Handle)
  88. {
  89. return 0;
  90. }
  91. #endif