DebugServer2
Loading...
Searching...
No Matches
ExtraWrappers.h
1//
2// Copyright (c) 2014-present, Facebook, Inc.
3// All rights reserved.
4//
5// This source code is licensed under the University of Illinois/NCSA Open
6// Source License found in the LICENSE file in the root directory of this
7// source tree. An additional grant of patent rights can be found in the
8// PATENTS file in the same directory.
9//
10
11#pragma once
12
13#include "DebugServer2/Base.h"
14
15#include <cstdarg>
16#include <cstdio>
17#include <windows.h>
18
19#define DS2_EXCEPTION_UNCAUGHT_COM 0x800706BA
20#define DS2_EXCEPTION_UNCAUGHT_USER 0xE06D7363
21#define DS2_EXCEPTION_UNCAUGHT_WINRT 0x40080201
22#define DS2_EXCEPTION_VC_THREAD_NAME_SET 0x406D1388
23
24#if !defined(HAVE_WaitForDebugEventEx)
25#define WaitForDebugEventEx WaitForDebugEvent
26#endif
27
28// Some APIs are not exposed when building for UAP.
29#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
30
31#if !defined(DOXYGEN)
32
33// clang-format off
34extern "C" {
35
36#if !defined(UNLEN)
37#define UNLEN 256
38#endif
39
40#if !defined(HAVE_GetWindowsDirectoryW)
41WINBASEAPI UINT WINAPI GetWindowsDirectoryW(
42 _Out_ LPWSTR lpBuffer,
43 _In_ UINT uSize
44);
45#endif
46
47#if !defined(HAVE_GetModuleHandleA)
48WINBASEAPI HMODULE WINAPI GetModuleHandleA(
49 _In_opt_ LPCSTR lpModuleName
50);
51#endif
52
53#if !defined(HAVE_GetModuleHandleW)
54WINBASEAPI HMODULE WINAPI GetModuleHandleW(
55 _In_opt_ LPCWSTR lpModuleName
56);
57#endif
58
59#if !defined(HAVE_struct__STARTUPINFOW)
60typedef struct _STARTUPINFOW {
61 DWORD cb;
62 LPWSTR lpReserved;
63 LPWSTR lpDesktop;
64 LPWSTR lpTitle;
65 DWORD dwX;
66 DWORD dwY;
67 DWORD dwXSize;
68 DWORD dwYSize;
69 DWORD dwXCountChars;
70 DWORD dwYCountChars;
71 DWORD dwFillAttribute;
72 DWORD dwFlags;
73 WORD wShowWindow;
74 WORD cbReserved2;
75 LPBYTE lpReserved2;
76 HANDLE hStdInput;
77 HANDLE hStdOutput;
78 HANDLE hStdError;
79} STARTUPINFOW, *LPSTARTUPINFOW;
80#endif
81
82#if !defined(HAVE_struct__PROCESS_INFORMATION)
83typedef struct _PROCESS_INFORMATION {
84 HANDLE hProcess;
85 HANDLE hThread;
86 DWORD dwProcessId;
87 DWORD dwThreadId;
88} PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
89#endif
90
91#if !defined(HAVE_TerminateThread)
92WINBASEAPI BOOL WINAPI TerminateThread(
93 _Inout_ HANDLE hThread,
94 _In_ DWORD dwExitCode
95);
96#endif
97
98#if !defined(HAVE_SetThreadContext)
99WINBASEAPI BOOL WINAPI SetThreadContext(
100 _In_ HANDLE hThread,
101 _In_ const CONTEXT *lpContext
102);
103#endif
104
105#if !defined(HAVE_ReadProcessMemory)
106WINBASEAPI BOOL WINAPI ReadProcessMemory(
107 _In_ HANDLE hProcess,
108 _In_ LPCVOID lpBaseAddress,
109 _Out_ LPVOID lpBuffer,
110 _In_ SIZE_T nSize,
111 _Out_ SIZE_T *lpNumberOfBytesRead
112);
113#endif
114
115#if !defined(HAVE_WriteProcessMemory)
116WINBASEAPI BOOL WINAPI WriteProcessMemory(
117 _In_ HANDLE hProcess,
118 _In_ LPVOID lpBaseAddress,
119 _In_ LPCVOID lpBuffer,
120 _In_ SIZE_T nSize,
121 _Out_ SIZE_T *lpNumberOfBytesWritten
122);
123#endif
124
125#if !defined(HAVE_ContinueDebugEvent)
126WINBASEAPI BOOL WINAPI ContinueDebugEvent(
127 _In_ DWORD dwProcessId,
128 _In_ DWORD dwThreadId,
129 _In_ DWORD dwContinueStatus
130);
131#endif
132
133#if !defined(HAVE_DebugActiveProcess)
134WINBASEAPI BOOL WINAPI DebugActiveProcess(
135 _In_ DWORD dwProcessId
136);
137#endif
138
139#if !defined(HAVE_DebugActiveProcessStop)
140WINBASEAPI BOOL WINAPI DebugActiveProcessStop(
141 _In_ DWORD dwProcessId
142);
143#endif
144
145#if !defined(HAVE_VirtualAllocEx)
146WINBASEAPI LPVOID WINAPI VirtualAllocEx(
147 _In_ HANDLE hProcess,
148 _In_opt_ LPVOID lpAddress,
149 _In_ SIZE_T dwSize,
150 _In_ DWORD flAllocationType,
151 _In_ DWORD flProtect
152);
153#endif
154
155#if !defined(HAVE_VirtualFreeEx)
156WINBASEAPI BOOL WINAPI VirtualFreeEx(
157 _In_ HANDLE hProcess,
158 _In_ LPVOID lpAddress,
159 _In_ SIZE_T dwSize,
160 _In_ DWORD dwFreeType
161);
162#endif
163
164#if !defined(HAVE_VirtualQueryEx)
165WINBASEAPI SIZE_T WINAPI VirtualQueryEx(
166 _In_ HANDLE hProcess,
167 _In_opt_ LPCVOID lpAddress,
168 _Out_ PMEMORY_BASIC_INFORMATION lpBuffer,
169 _In_ SIZE_T dwLength
170);
171#endif
172
173#if !defined(TH32CS_SNAPTHREAD)
174#define TH32CS_SNAPTHREAD 0x00000004
175#endif
176
177#if !defined(HAVE_PTOP_LEVEL_EXCEPTION_FILTER)
178typedef LONG (WINAPI *PTOP_LEVEL_EXCEPTION_FILTER)(
179 _In_ struct _EXCEPTION_POINTERS *ExceptionInfo
180 );
181#endif
182
183#if !defined(HAVE_LPTOP_LEVEL_EXCEPTION_FILTER)
184typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
185#endif
186
187} // extern "C"
188// clang-format on
189
190#endif // !DOXYGEN
191
192#endif