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 pathErrorUtils.ps1
More file actions
60 lines (54 loc) · 3.25 KB
/
ErrorUtils.ps1
File metadata and controls
60 lines (54 loc) · 3.25 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
<# ============================================================================= *
* SA-MP Injector - PowerShell injection ↓ *
* library for SA-MP (San Andreas Multiplayer) and OMP (Open Multiplayer) *
* ============================================================================= *
* *
* Copyright (c) 2025, SPC (SA-MP Programming Community) *
* All rights reserved. *
* *
* Developed by: Calasans *
* Repository: https://github.com/spc-samp/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. *
* *
* ============================================================================= #>
function Get_System_Error_Message {
param([Parameter(Mandatory = $true)][int]$error_code)
try {
$exception = New-Object System.ComponentModel.Win32Exception($error_code)
return $exception.Message
}
catch {
return "Unknown error (Code: $error_code)"
}
}
function Show_Error {
param([Parameter(Mandatory = $true)][string]$message, [Parameter(Mandatory = $true)][Inject_Type]$inject_type)
$title = if ($inject_type -eq [Inject_Type]::SAMP) {
$global:CONSTANTS.ERROR_TITLE_SAMP
}
else {
$global:CONSTANTS.ERROR_TITLE_OMP
}
try {
$message_box_flags = $global:CONSTANTS.MB_OK -bor $global:CONSTANTS.MB_ICONERROR -bor $global:CONSTANTS.MB_TOPMOST
[void][WinAPI]::MessageBoxW([System.IntPtr]::Zero, $message, $title, $message_box_flags)
}
catch {
Write-Host "[$title] $message" -ForegroundColor Red
}
}