CyberEngineMkIII
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CYBWin32Syscalls.cpp
1 #include "CYB.hpp"
2 
3 //kernel changes every day and isn't documented, we have to use the winapi
4 
5 unsigned long long CYB::Platform::System::Sys::DoCall(const CallNumber) noexcept {
7 }
8 
9 unsigned long long CYB::Platform::System::Sys::DoCall(const CallNumber, const Union64) noexcept {
11 }
12 
13 unsigned long long CYB::Platform::System::Sys::DoCall(const CallNumber, const Union64, const Union64) noexcept {
15 }
16 
17 unsigned long long CYB::Platform::System::Sys::DoCall(const CallNumber, const Union64, const Union64, const Union64) noexcept {
19 }
20 
21 unsigned long long CYB::Platform::System::Sys::DoCall(const CallNumber, const Union64, const Union64, const Union64, const Union64) noexcept {
23 }
24 
25 unsigned long long CYB::Platform::System::Sys::DoCall(const CallNumber, const Union64, const Union64, const Union64, const Union64, const Union64) noexcept {
27 }
28 
29 unsigned long long CYB::Platform::System::Sys::DoCall(const CallNumber, const Union64, const Union64, const Union64, const Union64, const Union64, const Union64) noexcept {
31 }
32 
33 unsigned long long CYB::Platform::System::Sys::LinkedCall(const CallNumber ACallNumber) noexcept {
34  API::Assert::Equal(ACallNumber, GET_CURRENT_PROCESS);
35  return reinterpret_cast<unsigned long long>(Win32::GetCurrentProcess());
36 }
37 
38 unsigned long long CYB::Platform::System::Sys::LinkedCall(const CallNumber ACallNumber, const Union64 AArg1) noexcept {
39  switch (ACallNumber) {
40  case TERMINATE_PROC:
41  return static_cast<unsigned long long>(Win32::TerminateProcess(AArg1.FPointer, 0));
42  case CLOSE_LIBRARY:
43  Win32::FreeLibrary(static_cast<Win32::HMODULE>(AArg1.FPointer));
44  return 0;
45  case LOAD_LIBRARY:
46  {
47  CYB::API::String::Static String(static_cast<const char* const>(AArg1.FPointer));
48  wchar_t Unicode[MAX_PATH];
49  //+1 for the \0
50  if (Win32::MultiByteToWideChar(CP_UTF8, 0, String.CString(), static_cast<int>(String.RawLength() + 1), Unicode, MAX_PATH) > MAX_PATH)
51  return 0;
52  return reinterpret_cast<unsigned long long>(Win32::LoadLibraryW(Unicode));
53  }
54  case LOAD_SYMBOL:
55  case GET_CURRENT_PROCESS:
56  default:
58  }
59 }
60 
61 unsigned long long CYB::Platform::System::Sys::LinkedCall(const CallNumber ACallNumber, const Union64 AArg1, const Union64 AArg2) noexcept {
62  using namespace Win32;
63  switch (ACallNumber) {
64  case LOAD_SYMBOL:
65  return reinterpret_cast<unsigned long long>(GetProcAddress(static_cast<HMODULE>(AArg1.FPointer), static_cast<const char* const>(AArg2.FPointer)));
66  case TERMINATE_PROC:
67  case CLOSE_LIBRARY:
68  case LOAD_LIBRARY:
69  case GET_CURRENT_PROCESS:
70  default:
72  }
73 }
74 
75 unsigned long long CYB::Platform::System::Sys::LinkedCall(const CallNumber, const Union64, const Union64, const Union64) noexcept {
77 }
78 
79 unsigned long long CYB::Platform::System::Sys::LinkedCall(const CallNumber, const Union64, const Union64, const Union64, const Union64) noexcept {
81 }
82 
83 unsigned long long CYB::Platform::System::Sys::LinkedCall(const CallNumber, const Union64, const Union64, const Union64, const Union64, const Union64) noexcept {
85 }
86 
87 unsigned long long CYB::Platform::System::Sys::LinkedCall(const CallNumber, const Union64, const Union64, const Union64, const Union64, const Union64, const Union64) noexcept {
89 }
90 
91 void CYB::Platform::System::Sys::VerifyArgumentCount(const CallNumber, const unsigned long long) noexcept {
93 }
Used for passing arguments to calls to this class. If the call in question requires const...
Definition: CYBSyscalls.hpp:15
int RawLength(void) const noexcept
Get the byte length of the contained CString.
A string pointing to unchanging data in the stack above it or the data segment. Must have UTF-8 encod...
Definition: StaticString.hpp:7
static void HCF(void) noexcept
Indicates unreachable code. Implementation can be overriden by defining ASSERTION_OVERRIDE.
Definition: CYBEntry.cpp:26
static unsigned long long DoCall(const CallNumber ACallNumber) noexcept
Do an asm syscall for ACallNumber. The number of arguments must match system specification.
static unsigned long long LinkedCall(const CallNumber ACallNumber) noexcept
Do linked call for ACallNumber. The number of arguments must match system specification.
static void VerifyArgumentCount(const CallNumber ACallNumber, const unsigned long long ANumArgs) noexcept
Checks the number of arguments for syscalls and calls HCF if something is wrong.
static void Equal(const AType &ALHS, const AType &ARHS) noexcept
Equivalence assertion function. May not be evaluated.
Precompiled header for inter-engine operations.
const char * CString(void) const noexcept
Get the contained const CString.