win32.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9/* Inspired by previous work by Romeo Anghelache & Eric Stern. */
10
11#include "squid.h"
12
13#if _SQUID_WINDOWS_
14
15#include "fde.h"
16#include "win32.h"
17
18#include <csignal>
19#if HAVE_PSAPI_H
20#include <psapi.h>
21#endif
22#if HAVE_MSWSOCK_H
23#include <mswsock.h>
24#endif
25
26SQUIDCEXTERN LPCRITICAL_SECTION dbg_mutex;
28static LPTOP_LEVEL_EXCEPTION_FILTER Win32_Old_ExceptionHandler = nullptr;
29
30int
31Win32__WSAFDIsSet(int fd, fd_set FAR * set)
32{
33 fde *F = &fd_table[fd];
34 SOCKET s = F->win32.handle;
35
36 return __WSAFDIsSet(s, set);
37}
38
39LONG CALLBACK WIN32_ExceptionHandler(EXCEPTION_POINTERS* ep)
40{
41 EXCEPTION_RECORD* er;
42
43 er = ep->ExceptionRecord;
44
45 switch (er->ExceptionCode) {
46
47 case EXCEPTION_ACCESS_VIOLATION:
48 raise(SIGSEGV);
49 break;
50
51 case EXCEPTION_DATATYPE_MISALIGNMENT:
52
53 case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
54
55 case EXCEPTION_IN_PAGE_ERROR:
56 raise(SIGBUS);
57 break;
58
59 default:
60 break;
61 }
62
63 return EXCEPTION_CONTINUE_SEARCH;
64}
65
66void WIN32_ExceptionHandlerInit()
67{
68#if !defined(_DEBUG)
69
70 if (Win32_Old_ExceptionHandler == NULL)
71 Win32_Old_ExceptionHandler = SetUnhandledExceptionFilter(WIN32_ExceptionHandler);
72
73#endif
74}
75
77{
78 if (Win32_Old_ExceptionHandler != NULL)
79 SetUnhandledExceptionFilter(Win32_Old_ExceptionHandler);
80}
81
82#endif /* SQUID_WINDOWS_ */
83
void WIN32_ExceptionHandlerCleanup(void)
SQUIDCEXTERN LPCRITICAL_SECTION dbg_mutex
Definition: WinSvc.cc:48
Definition: fde.h:52
#define fd_table
Definition: fde.h:189
static uint32 F(uint32 X, uint32 Y, uint32 Z)
Definition: md4.c:46
#define SQUIDCEXTERN
Definition: squid.h:21
#define NULL
Definition: types.h:145

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors