aboutsummaryrefslogtreecommitdiff
path: root/core/sys
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-05-12 13:54:40 +0100
committergingerBill <bill@gingerbill.org>2022-05-12 13:54:40 +0100
commitd1fc9d3073ac85e643199d7558c6fce548084ba3 (patch)
tree4a35537c595ff1be3a4ee00177601698e8552cee /core/sys
parent2fb351bf04ee2af9c43858f7178d1bee1e1c7a06 (diff)
Add more libraries
Diffstat (limited to 'core/sys')
-rw-r--r--core/sys/windows/advapi32.odin6
-rw-r--r--core/sys/windows/kernel32.odin3
-rw-r--r--core/sys/windows/ole32.odin18
-rw-r--r--core/sys/windows/shlwapi.odin11
-rw-r--r--core/sys/windows/types.odin143
5 files changed, 169 insertions, 12 deletions
diff --git a/core/sys/windows/advapi32.odin b/core/sys/windows/advapi32.odin
index a2a24242f..20badb5da 100644
--- a/core/sys/windows/advapi32.odin
+++ b/core/sys/windows/advapi32.odin
@@ -3,6 +3,8 @@ package sys_windows
foreign import advapi32 "system:Advapi32.lib"
+HCRYPTPROV :: distinct HANDLE
+
@(default_calling_convention="stdcall")
foreign advapi32 {
@(link_name = "SystemFunction036")
@@ -10,6 +12,10 @@ foreign advapi32 {
OpenProcessToken :: proc(ProcessHandle: HANDLE,
DesiredAccess: DWORD,
TokenHandle: ^HANDLE) -> BOOL ---
+
+ CryptAcquireContextW :: proc(hProv: ^HCRYPTPROV, szContainer, szProvider: wstring, dwProvType, dwFlags: DWORD) -> DWORD ---
+ CryptGenRandom :: proc(hProv: HCRYPTPROV, dwLen: DWORD, buf: LPVOID) -> DWORD ---
+ CryptReleaseContext :: proc(hProv: HCRYPTPROV, dwFlags: DWORD) -> DWORD ---
}
// Necessary to create a token to impersonate a user with for CreateProcessAsUser
diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin
index e235b45ed..f52fb46e6 100644
--- a/core/sys/windows/kernel32.odin
+++ b/core/sys/windows/kernel32.odin
@@ -21,7 +21,8 @@ foreign kernel32 {
GetConsoleMode :: proc(hConsoleHandle: HANDLE,
lpMode: LPDWORD) -> BOOL ---
-
+ SetConsoleMode :: proc(hConsoleHandle: HANDLE,
+ dwMode: DWORD) -> BOOL ---
GetFileInformationByHandle :: proc(hFile: HANDLE, lpFileInformation: LPBY_HANDLE_FILE_INFORMATION) -> BOOL ---
SetHandleInformation :: proc(hObject: HANDLE,
diff --git a/core/sys/windows/ole32.odin b/core/sys/windows/ole32.odin
new file mode 100644
index 000000000..23fe888d2
--- /dev/null
+++ b/core/sys/windows/ole32.odin
@@ -0,0 +1,18 @@
+// +build windows
+package sys_windows
+
+foreign import "system:Ole32.lib"
+
+//objbase.h
+COINIT :: enum DWORD {
+ APARTMENTTHREADED = 0x2,
+ MULTITHREADED,
+ DISABLE_OLE1DDE = 0x4,
+ SPEED_OVER_MEMORY = 0x8,
+}
+
+@(default_calling_convention="stdcall")
+foreign Ole32 {
+ CoInitializeEx :: proc(reserved: rawptr, co_init: COINIT) -> HRESULT ---
+ CoUninitialize :: proc() ---
+}
diff --git a/core/sys/windows/shlwapi.odin b/core/sys/windows/shlwapi.odin
new file mode 100644
index 000000000..1852d536f
--- /dev/null
+++ b/core/sys/windows/shlwapi.odin
@@ -0,0 +1,11 @@
+// +build windows
+package sys_windows
+
+foreign import shlwapi "system:shlwapi.lib"
+
+@(default_calling_convention="stdcall")
+foreign shlwapi {
+ PathFileExistsW :: proc(pszPath: wstring) -> BOOL ---
+ PathFindExtensionW :: proc(pszPath: wstring) -> wstring ---
+ PathFindFileNameW :: proc(pszPath: wstring) -> wstring ---
+}
diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin
index 4f594e22d..b497f181e 100644
--- a/core/sys/windows/types.odin
+++ b/core/sys/windows/types.odin
@@ -3,19 +3,21 @@ package sys_windows
import "core:c"
-c_char :: c.char
-c_uchar :: c.uchar
-c_int :: c.int
-c_uint :: c.uint
-c_long :: c.long
-c_longlong :: c.longlong
-c_ulong :: c.ulong
-c_short :: c.short
-c_ushort :: c.ushort
-size_t :: c.size_t
-wchar_t :: c.wchar_t
+c_char :: c.char
+c_uchar :: c.uchar
+c_int :: c.int
+c_uint :: c.uint
+c_long :: c.long
+c_longlong :: c.longlong
+c_ulong :: c.ulong
+c_ulonglong :: c.ulonglong
+c_short :: c.short
+c_ushort :: c.ushort
+size_t :: c.size_t
+wchar_t :: c.wchar_t
DWORD :: c_ulong
+QWORD :: c.ulonglong
HANDLE :: distinct LPVOID
HINSTANCE :: HANDLE
HMODULE :: distinct HINSTANCE
@@ -2170,3 +2172,122 @@ SYSTEMTIME :: struct {
second: WORD,
milliseconds: WORD,
}
+
+
+@(private="file")
+IMAGE_DOS_HEADER :: struct {
+ e_magic: WORD,
+ e_cblp: WORD,
+ e_cp: WORD,
+ e_crlc: WORD,
+ e_cparhdr: WORD,
+ e_minalloc: WORD,
+ e_maxalloc: WORD,
+ e_ss: WORD,
+ e_sp: WORD,
+ e_csum: WORD,
+ e_ip: WORD,
+ e_cs: WORD,
+ e_lfarlc: WORD,
+ e_ovno: WORD,
+ e_res_0: WORD,
+ e_res_1: WORD,
+ e_res_2: WORD,
+ e_res_3: WORD,
+ e_oemid: WORD,
+ e_oeminfo: WORD,
+ e_res2_0: WORD,
+ e_res2_1: WORD,
+ e_res2_2: WORD,
+ e_res2_3: WORD,
+ e_res2_4: WORD,
+ e_res2_5: WORD,
+ e_res2_6: WORD,
+ e_res2_7: WORD,
+ e_res2_8: WORD,
+ e_res2_9: WORD,
+ e_lfanew: DWORD,
+}
+
+IMAGE_DATA_DIRECTORY :: struct {
+ VirtualAddress: DWORD,
+ Size: DWORD,
+}
+
+IMAGE_FILE_HEADER :: struct {
+ Machine: WORD,
+ NumberOfSections: WORD,
+ TimeDateStamp: DWORD,
+ PointerToSymbolTable: DWORD,
+ NumberOfSymbols: DWORD,
+ SizeOfOptionalHeader: WORD,
+ Characteristics: WORD,
+}
+
+IMAGE_OPTIONAL_HEADER64 :: struct {
+ Magic: WORD,
+ MajorLinkerVersion: BYTE,
+ MinorLinkerVersion: BYTE,
+ SizeOfCode: DWORD,
+ SizeOfInitializedData: DWORD,
+ SizeOfUninitializedData: DWORD,
+ AddressOfEntryPoint: DWORD,
+ BaseOfCode: DWORD,
+ ImageBase: QWORD,
+ SectionAlignment: DWORD,
+ FileAlignment: DWORD,
+ MajorOperatingSystemVersion: WORD,
+ MinorOperatingSystemVersion: WORD,
+ MajorImageVersion: WORD,
+ MinorImageVersion: WORD,
+ MajorSubsystemVersion: WORD,
+ MinorSubsystemVersion: WORD,
+ Win32VersionValue: DWORD,
+ SizeOfImage: DWORD,
+ SizeOfHeaders: DWORD,
+ CheckSum: DWORD,
+ Subsystem: WORD,
+ DllCharacteristics: WORD,
+ SizeOfStackReserve: QWORD,
+ SizeOfStackCommit: QWORD,
+ SizeOfHeapReserve: QWORD,
+ SizeOfHeapCommit: QWORD,
+ LoaderFlags: DWORD,
+ NumberOfRvaAndSizes: DWORD,
+ ExportTable: IMAGE_DATA_DIRECTORY,
+ ImportTable: IMAGE_DATA_DIRECTORY,
+ ResourceTable: IMAGE_DATA_DIRECTORY,
+ ExceptionTable: IMAGE_DATA_DIRECTORY,
+ CertificateTable: IMAGE_DATA_DIRECTORY,
+ BaseRelocationTable: IMAGE_DATA_DIRECTORY,
+ Debug: IMAGE_DATA_DIRECTORY,
+ Architecture: IMAGE_DATA_DIRECTORY,
+ GlobalPtr: IMAGE_DATA_DIRECTORY,
+ TLSTable: IMAGE_DATA_DIRECTORY,
+ LoadConfigTable: IMAGE_DATA_DIRECTORY,
+ BoundImport: IMAGE_DATA_DIRECTORY,
+ IAT: IMAGE_DATA_DIRECTORY,
+ DelayImportDescriptor: IMAGE_DATA_DIRECTORY,
+ CLRRuntimeHeader: IMAGE_DATA_DIRECTORY,
+ Reserved: IMAGE_DATA_DIRECTORY,
+}
+
+IMAGE_NT_HEADERS64 :: struct {
+ Signature: DWORD,
+ FileHeader: IMAGE_FILE_HEADER,
+ OptionalHeader: IMAGE_OPTIONAL_HEADER64,
+}
+
+IMAGE_EXPORT_DIRECTORY :: struct {
+ Characteristics: DWORD,
+ TimeDateStamp: DWORD,
+ MajorVersion: WORD,
+ MinorVersion: WORD,
+ Name: DWORD,
+ Base: DWORD,
+ NumberOfFunctions: DWORD,
+ NumberOfNames: DWORD,
+ AddressOfFunctions: DWORD, // RVA from base of image
+ AddressOfNames: DWORD, // RVA from base of image
+ AddressOfNameOrdinals: DWORD, // RVA from base of image
+} \ No newline at end of file