CommonLibSSE (powerof3)
WinAPI.h
Go to the documentation of this file.
1 #pragma once
2 
3 namespace SKSE::WinAPI
4 {
5  inline constexpr auto CP_UTF8{ static_cast<unsigned int>(65001) };
6  inline constexpr auto IMAGE_SCN_MEM_EXECUTE{ static_cast<std::uint32_t>(0x20000000) };
7  inline constexpr auto IMAGE_SCN_MEM_WRITE{ static_cast<std::uint32_t>(0x80000000) };
8  inline const auto INVALID_HANDLE_VALUE{ reinterpret_cast<void*>(static_cast<std::intptr_t>(-1)) };
9  inline constexpr auto MAX_PATH{ static_cast<std::uint32_t>(260) };
10  inline constexpr auto MEM_RELEASE{ static_cast<std::uint32_t>(0x00008000) };
11  inline constexpr auto PAGE_EXECUTE_READWRITE{ static_cast<std::uint32_t>(0x40) };
12 
14  {
15  public:
16  // members
17  void* DebugInfo; // 00
18  std::int32_t LockCount; // 08
19  std::int32_t RecursionCount; // 0C
20  void* OwningThread; // 10
21  void* LockSemaphore; // 18
22  std::uint64_t* SpinCount; // 20
23  };
24  static_assert(sizeof(CRITICAL_SECTION) == 0x28);
25 
26  struct _FILETIME
27  {
28  public:
29  // members
30  std::uint32_t dwLowDateTime; // 00
31  std::uint32_t dwHighDateTime; // 04
32  };
33  static_assert(sizeof(_FILETIME) == 0x8);
35 
36  struct HWND__;
37  using HWND = HWND__*;
38 
39  struct HINSTANCE__;
40  using HINSTANCE = HINSTANCE__*;
41 
43  {
44  public:
45  // members
46  std::uint32_t dwFileAttributes;
50  std::uint32_t nFileSizeHigh;
51  std::uint32_t nFileSizeLow;
52  std::uint32_t dwReserved0;
53  std::uint32_t dwReserved1;
56  };
57  static_assert(sizeof(_WIN32_FIND_DATAA) == 0x140);
59 
60  [[nodiscard]] void* GetCurrentModule() noexcept;
61 
62  [[nodiscard]] void* GetCurrentProcess() noexcept;
63 
64  [[nodiscard]] std::uint32_t GetCurrentThreadID() noexcept;
65 
66  [[nodiscard]] std::uint32_t GetEnvironmentVariable(
67  const char* a_name,
68  char* a_buffer,
69  std::uint32_t a_size) noexcept;
70 
71  [[nodiscard]] std::uint32_t GetEnvironmentVariable(
72  const wchar_t* a_name,
73  wchar_t* a_buffer,
74  std::uint32_t a_size) noexcept;
75 
76  [[nodiscard]] bool GetFileVersionInfo(
77  const char* a_filename,
78  std::uint32_t a_handle,
79  std::uint32_t a_len,
80  void* a_data) noexcept;
81 
82  [[nodiscard]] bool GetFileVersionInfo(
83  const wchar_t* a_filename,
84  std::uint32_t a_handle,
85  std::uint32_t a_len,
86  void* a_data) noexcept;
87 
88  [[nodiscard]] std::uint32_t GetFileVersionInfoSize(
89  const char* a_filename,
90  std::uint32_t* a_handle) noexcept;
91 
92  [[nodiscard]] std::uint32_t GetFileVersionInfoSize(
93  const wchar_t* a_filename,
94  std::uint32_t* a_handle) noexcept;
95 
96  [[nodiscard]] std::size_t GetMaxPath() noexcept;
97 
98  [[nodiscard]] std::uint32_t GetModuleFileName(
99  void* a_module,
100  char* a_filename,
101  std::uint32_t a_size) noexcept;
102 
103  [[nodiscard]] std::uint32_t GetModuleFileName(
104  void* a_module,
105  wchar_t* a_filename,
106  std::uint32_t a_size) noexcept;
107 
108  [[nodiscard]] void* GetModuleHandle(const char* a_moduleName) noexcept;
109 
110  [[nodiscard]] void* GetModuleHandle(const wchar_t* a_moduleName) noexcept;
111 
112  [[nodiscard]] void* GetProcAddress(
113  void* a_module,
114  const char* a_procName) noexcept;
115 
116  std::int32_t MessageBox(
117  void* a_wnd,
118  const char* a_text,
119  const char* a_caption,
120  unsigned int a_type) noexcept;
121 
122  std::int32_t MessageBox(
123  void* a_wnd,
124  const wchar_t* a_text,
125  const wchar_t* a_caption,
126  unsigned int a_type) noexcept;
127 
128  [[nodiscard]] int MultiByteToWideChar(
129  unsigned int a_codePage,
130  std::uint32_t a_flags,
131  const char* a_multiByteStr,
132  int a_multiByte,
133  wchar_t* a_wideCharStr,
134  int a_wideChar);
135 
137  const char* a_outputString) noexcept;
138 
140  const wchar_t* a_outputString) noexcept;
141 
142  [[noreturn]] void TerminateProcess(
143  void* a_process,
144  unsigned int a_exitCode) noexcept;
145 
146  [[nodiscard]] void* TlsGetValue(std::uint32_t a_tlsIndex) noexcept;
147 
149  std::uint32_t a_tlsIndex,
150  void* a_tlsValue) noexcept;
151 
153  void* a_address,
154  std::size_t a_size,
155  std::uint32_t a_freeType) noexcept;
156 
157  [[nodiscard]] bool VerQueryValue(
158  const void* a_block,
159  const char* a_subBlock,
160  void** a_buffer,
161  unsigned int* a_len) noexcept;
162 
163  [[nodiscard]] bool VerQueryValue(
164  const void* a_block,
165  const wchar_t* a_subBlock,
166  void** a_buffer,
167  unsigned int* a_len) noexcept;
168 
169  [[nodiscard]] bool VirtualProtect(
170  void* a_address,
171  std::size_t a_size,
172  std::uint32_t a_newProtect,
173  std::uint32_t* a_oldProtect) noexcept;
174 
175  [[nodiscard]] int WideCharToMultiByte(
176  unsigned int a_codePage,
177  std::uint32_t a_flags,
178  const wchar_t* a_wideCharStr,
179  int a_wideChar,
180  char* a_multiByteStr,
181  int a_multiByte,
182  const char* a_defaultChar,
183  int* a_usedDefaultChar);
184 }
185 
186 namespace RE::DirectX
187 {
188  struct XMFLOAT4X4
189  {
190  public:
191  // members
192  float m[4][4];
193  };
194  static_assert(sizeof(XMFLOAT4X4) == 0x40);
195 }
Definition: AbsorbEffect.h:6
Definition: WinAPI.h:4
std::uint32_t GetFileVersionInfoSize(const char *a_filename, std::uint32_t *a_handle) noexcept
std::uint32_t GetEnvironmentVariable(const char *a_name, char *a_buffer, std::uint32_t a_size) noexcept
void * TlsGetValue(std::uint32_t a_tlsIndex) noexcept
bool VirtualProtect(void *a_address, std::size_t a_size, std::uint32_t a_newProtect, std::uint32_t *a_oldProtect) noexcept
std::size_t GetMaxPath() noexcept
void OutputDebugString(const char *a_outputString) noexcept
void * GetCurrentModule() noexcept
constexpr auto IMAGE_SCN_MEM_WRITE
Definition: WinAPI.h:7
std::uint32_t GetModuleFileName(void *a_module, char *a_filename, std::uint32_t a_size) noexcept
std::uint32_t GetCurrentThreadID() noexcept
constexpr auto MEM_RELEASE
Definition: WinAPI.h:10
constexpr auto PAGE_EXECUTE_READWRITE
Definition: WinAPI.h:11
HWND__ * HWND
Definition: WinAPI.h:37
void * GetModuleHandle(const char *a_moduleName) noexcept
bool TlsSetValue(std::uint32_t a_tlsIndex, void *a_tlsValue) noexcept
bool GetFileVersionInfo(const char *a_filename, std::uint32_t a_handle, std::uint32_t a_len, void *a_data) noexcept
constexpr auto IMAGE_SCN_MEM_EXECUTE
Definition: WinAPI.h:6
int MultiByteToWideChar(unsigned int a_codePage, std::uint32_t a_flags, const char *a_multiByteStr, int a_multiByte, wchar_t *a_wideCharStr, int a_wideChar)
bool VerQueryValue(const void *a_block, const char *a_subBlock, void **a_buffer, unsigned int *a_len) noexcept
void * GetProcAddress(void *a_module, const char *a_procName) noexcept
std::int32_t MessageBox(void *a_wnd, const char *a_text, const char *a_caption, unsigned int a_type) noexcept
constexpr auto CP_UTF8
Definition: WinAPI.h:5
const auto INVALID_HANDLE_VALUE
Definition: WinAPI.h:8
HINSTANCE__ * HINSTANCE
Definition: WinAPI.h:40
int WideCharToMultiByte(unsigned int a_codePage, std::uint32_t a_flags, const wchar_t *a_wideCharStr, int a_wideChar, char *a_multiByteStr, int a_multiByte, const char *a_defaultChar, int *a_usedDefaultChar)
void * GetCurrentProcess() noexcept
void TerminateProcess(void *a_process, unsigned int a_exitCode) noexcept
bool VirtualFree(void *a_address, std::size_t a_size, std::uint32_t a_freeType) noexcept
constexpr auto MAX_PATH
Definition: WinAPI.h:9
Definition: NiBinaryStream.h:94
Definition: WinAPI.h:189
Definition: WinAPI.h:14
void * DebugInfo
Definition: WinAPI.h:17
void * LockSemaphore
Definition: WinAPI.h:21
std::uint64_t * SpinCount
Definition: WinAPI.h:22
std::int32_t LockCount
Definition: WinAPI.h:18
std::int32_t RecursionCount
Definition: WinAPI.h:19
void * OwningThread
Definition: WinAPI.h:20
Definition: WinAPI.h:27
std::uint32_t dwLowDateTime
Definition: WinAPI.h:30
std::uint32_t dwHighDateTime
Definition: WinAPI.h:31
Definition: WinAPI.h:43
std::uint32_t nFileSizeLow
Definition: WinAPI.h:51
char cFileName[MAX_PATH]
Definition: WinAPI.h:54
std::uint32_t dwReserved1
Definition: WinAPI.h:53
std::uint32_t dwFileAttributes
Definition: WinAPI.h:46
std::uint32_t nFileSizeHigh
Definition: WinAPI.h:50
FILETIME ftCreationTime
Definition: WinAPI.h:47
char cAlternateFileName[14]
Definition: WinAPI.h:55
std::uint32_t dwReserved0
Definition: WinAPI.h:52
FILETIME ftLastAccessTime
Definition: WinAPI.h:48
FILETIME ftLastWriteTime
Definition: WinAPI.h:49