muteki
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1
/*
2
* Copyright 2021-present dogtopus
3
* SPDX-License-Identifier: MIT
4
*/
5
13
#ifndef __MUTEKI_COMMON_H__
14
#define __MUTEKI_COMMON_H__
15
16
#ifdef __cplusplus
17
extern
"C"
{
18
#endif
19
20
#if defined(_MSC_VER) && _MSC_VER > 0
21
#error "MSVC is not yet supported."
22
#endif
23
24
#ifndef __GHIDRA__
25
#include <stdint.h>
26
#include <stdbool.h>
27
#include <stddef.h>
28
#if (defined(__MUTEKI_IS_BOOTSTRAPPING__) && __MUTEKI_IS_BOOTSTRAPPING__ == 1)
29
typedef
long
ssize_t;
30
#else
31
#include <sys/types.h>
// for ssize_t
32
#endif
33
34
// This only supports GCC, LLVM and probably also MSVC at the moment.
35
#if defined(__WCHAR_TYPE__) && (__WCHAR_MAX__ < 0x10000)
36
typedef
__WCHAR_TYPE__ __BESTA_UTF_TYPE;
37
#define __BESTA_UTF_LITERAL(x) (L ## x)
38
#elif defined(__CHAR16_TYPE__) && (__CHAR16_MAX__ < 0x10000)
39
typedef
__CHAR16_TYPE__ __BESTA_UTF_TYPE;
40
#define __BESTA_UTF_LITERAL(x) (u ## x)
41
#elif defined(_MSC_VER) && _MSC_VER > 0
42
#include <wchar.h>
43
typedef
wchar_t
__BESTA_UTF_TYPE;
44
#define __BESTA_UTF_LITERAL(x) (L ## x)
45
#else
46
#error "Compiler does not support any 2 bytes wide string literal."
47
#endif
48
54
#define UTF16 __BESTA_UTF_TYPE
55
61
#define _BUL(x) __BESTA_UTF_LITERAL(x)
62
63
#define __SYS_DWORD __attribute__((packed, aligned(4)))
64
#define __SYS_ALIGN(n) __attribute__((aligned(n)))
65
#define __SYS_IS_PRINTF(arg_index_str, arg_index_fmt) __attribute__((format(printf, arg_index_str, arg_index_fmt)))
66
80
#define SYS_DWORD __SYS_DWORD
81
86
#define SYS_ALIGN(n) __SYS_ALIGN(n)
87
92
#define SYS_IS_PRINTF(arg_index_str, arg_index_fmt) __SYS_IS_PRINTF(arg_index_str, arg_index_fmt)
93
94
#else
// defined(__GHIDRA__)
95
96
// Type stubs for Ghidra
97
98
// TODO get rid of these and find a way to let ghidra use system includes seamlessly
99
typedef
long
int32_t;
100
typedef
uchar uint8_t;
101
typedef
ulong size_t;
102
typedef
ulong uintptr_t;
103
104
#define UTF16 wchar16
105
#define _BUL(x) x
106
#define SYS_DWORD
107
#define SYS_ALIGN(n)
108
#define SYS_IS_PRINTF(arg_index_str, arg_index_fmt)
109
110
#endif
// defined(__GHIDRA__)
111
112
#ifdef __cplusplus
113
}
// extern "C"
114
#endif
115
116
#endif
// __MUTEKI_COMMON_H__
include
muteki
common.h
Generated by
1.9.8