WKern
Loading...
Searching...
No Matches
wexent.c
Go to the documentation of this file.
1/*
2WKern - A Bare Metal OS / Kernel I am maKing (For Fun)
3Copyright (C) 2025 Wdboyes13
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 3 of the License, or
8any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <https://www.gnu.org/licenses/>.
17*/
18
19#include <io/kio.h>
20#include <wex/stdwex.h>
21
22// Read First Values
23// Reads 0x00 - 0x09
30int *read_vals(const unsigned char *exec) {
31 static int epa;
32 static int sts;
33 static int fvals[2];
34
35 epa = exec[0];
36 sts = exec[1];
37 fvals[0] = epa;
38 fvals[1] = sts;
39
40 return fvals;
41}
42
51int chKwex(const unsigned char *smt, int smt_len, const unsigned char *st,
52 int st_len) {
53 for (int i = 0; i < smt_len; i++) {
54 int valid = 0;
55 for (int j = 0; j < st_len; j++) {
56 if (smt[i] == st[j]) {
57 valid = 1;
58 break;
59 }
60 }
61 if (!valid) {
62 return 1; // Invalid symbol found
63 }
64 }
65 return 0; // All symbols valid
66}
67
73void Runwex(unsigned char *wexexecu) {
74 int *fvals = read_vals(wexexecu);
75 int sts = fvals[1];
76 unsigned char st[sts];
77 for (int i = 0; i < sts; i++) {
78 st[i] = wexexecu[i + 2];
79 }
80 chKwex(st, sts, smt, 5);
81 Exec(wexexecu);
82}
void Exec(unsigned char *exec)
Definition wexexec.c:29
int chKwex(const unsigned char *smt, int smt_len, const unsigned char *st, int st_len)
Verify symbols in executable.
Definition wexent.c:51
void Runwex(unsigned char *wexexecu)
Automatically checks and executes an executable.
Definition wexent.c:73
int * read_vals(const unsigned char *exec)
Read First Values of WEX Executable.
Definition wexent.c:30