This repository was archived by the owner on Feb 27, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror_utils.hpp
More file actions
64 lines (58 loc) · 3.64 KB
/
error_utils.hpp
File metadata and controls
64 lines (58 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* ============================================================================= *
* SA-MP Injector - C++ injection ↓ *
* library for SA-MP (San Andreas Multiplayer) and OMP (Open Multiplayer) *
* ============================================================================= *
* *
* Copyright (c) 2025, AlderGrounds *
* All rights reserved. *
* *
* Developed by: Calasans *
* Provided by: AlderGrounds *
* Repository: https://github.com/aldergrounds/samp-injector *
* *
* ============================================================================= *
* *
* Licensed under the MIT License (MIT); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at: *
* *
* https://opensource.org/licenses/MIT *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN *
* THE SOFTWARE. *
* *
* ============================================================================= */
#pragma once
#include <string>
#include <windows.h>
//
#include "constants.hpp"
#include "types.hpp"
#include "version.hpp"
//
#if defined(SAMP_INJECTOR_CXX_MODERN)
#include <string_view>
#endif
namespace Error_Utils {
SAMP_INJECTOR_NODISCARD
inline std::wstring Get_System_Error_Message(DWORD error_code) {
if (error_code == 0)
return L"No error occurred.";
wchar_t buffer[512] = {0};
DWORD result = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, sizeof(buffer) / sizeof(wchar_t), nullptr);
return result ? std::wstring(buffer) : L"Unknown error (Code: " + std::to_wstring(error_code) + L")";
}
#if defined(SAMP_INJECTOR_CXX_MODERN)
inline void Show_Error(std::wstring_view message, Types::Inject_Type inject_type) {
#elif defined(SAMP_INJECTOR_CXX_14)
inline void Show_Error(const std::wstring& message, Types::Inject_Type inject_type) {
#endif
const std::wstring title = (inject_type == Types::Inject_Type::SAMP) ? Constants::ERROR_TITLE_SAMP : Constants::ERROR_TITLE_OMP;
MessageBoxW(nullptr, message.data(), title.c_str(), MB_OK | MB_ICONERROR);
}
}