Skip to content

Commit

Permalink
[DLL] Proper initializers
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyTy committed May 23, 2024
1 parent df4ec67 commit 370218b
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 101 deletions.
48 changes: 43 additions & 5 deletions dlls/advapi32.dll/advapiMain.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,54 @@
// Entry point of the project

@customHeader('
#if 0
#define HEXA_NEW(z) HeapAlloc(0,0,z)
void *tmemcpy(void *dest, const void *src, uint64_t count) {
uint8_t *dst8 = (uint8_t *)dest;
const uint8_t *src8 = (const uint8_t *)src;
while (count--) {
*dst8++ = *src8++;
}
return dest;
}
// TODO
#define memcpy(z,u,x) tmemcpy(z,u,x)
// TODO just import kernel32
#define wprintf(z,...) {}
#define HEAP_ZERO_MEMORY 0
#define fflush(z) {}
#define stdout ((void*)0)
#define GetProcessHeap() 0
int64_t _fltused = 0;
#ifdef bit64
#define ADVAPI32_DLL __declspec(dllexport)
#else
#define ADVAPI32_DLL __declspec(dllexport) __stdcall
int64_t __alldiv() asm("__alldiv");
int64_t __alldiv() { return 0; } // TODO
int64_t __allrem() asm("__allrem");
int64_t __allrem() { return 0; } // TODO
uint64_t __aulldiv() asm("__aulldiv");
uint64_t __aulldiv() { return 0; } // TODO
uint64_t __aullrem() asm("__aullrem");
uint64_t __aullrem() { return 0; } // TODO
void _memset() asm("_memset");
void _memset() {
} // TODO TODO TODO
void _memcpy() asm("_memcpy");
void _memcpy() {
} // TODO TODO TODO
#endif
void startup() {
// TODO hexa
HEXA_MAIN(0, nullptr);
}
#ifdef bit64
Expand All @@ -39,6 +78,5 @@
// TODO must return something?
}
#endif
#endif
')
declare fun entryTODO() Void
56 changes: 28 additions & 28 deletions dlls/advapi32.dll/hexa.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"name": "Advapeh",
"version": "1.0.0",
"description": "Greentea OS",
"author": "PeyTy",
"license": "LGPL-3.0-only",
"global": [
"../types",
"../../kernel/syscalls/syscalls",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"../gdi32.dll/gdiMain",
"advapiMain"
],
"targets": [
{
"name": "default",
"generator": "c",
"output": "advapi32.64.c",
"options": []
},
{
"name": "i386",
"generator": "c",
"output": "advapi32.32.c",
"options": []
}
],
"entry": "advapi32"
"name": "Advapeh",
"version": "1.0.0",
"description": "Greentea OS",
"author": "PeyTy",
"license": "LGPL-3.0-only",
"global": [
"../types",
"../../kernel/syscalls/syscalls",
"../tofita32.dll/tofita32.header",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"advapiMain"
],
"targets": [
{
"name": "default",
"generator": "c",
"output": "advapi32.64.c",
"options": []
},
{
"name": "i386",
"generator": "c",
"output": "advapi32.32.c",
"options": []
}
],
"entry": "advapi32"
}
59 changes: 30 additions & 29 deletions dlls/comctl32.dll/hexa.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
{
"name": "CommonControls",
"version": "1.0.0",
"description": "Greentea OS",
"author": "PeyTy",
"license": "LGPL-3.0-only",
"global": [
"../types",
"../../kernel/syscalls/syscalls",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"comctl32.header",
"comctlMain",
"comctl32Vars"
],
"targets": [
{
"name": "default",
"generator": "c",
"output": "comctl32.64.c",
"options": []
},
{
"name": "i386",
"generator": "c",
"output": "comctl32.32.c",
"options": []
}
],
"entry": "comctl32"
"name": "CommonControls",
"version": "1.0.0",
"description": "Greentea OS",
"author": "PeyTy",
"license": "LGPL-3.0-only",
"global": [
"../types",
"../../kernel/syscalls/syscalls",
"../tofita32.dll/tofita32.header",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"comctl32.header",
"comctlMain",
"comctl32Vars"
],
"targets": [
{
"name": "default",
"generator": "c",
"output": "comctl32.64.c",
"options": []
},
{
"name": "i386",
"generator": "c",
"output": "comctl32.32.c",
"options": []
}
],
"entry": "comctl32"
}
1 change: 1 addition & 0 deletions dlls/gdi32.dll/hexa.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"global": [
"../types",
"../../kernel/syscalls/syscalls",
"../tofita32.dll/tofita32.header",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"gdi32.header",
Expand Down
2 changes: 1 addition & 1 deletion dlls/kernel32.dll/kernel32.header.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fun localAlloc(flags UInt32, bytes SizeOfPointer) HLocal
@dllImport
@rename('HeapAlloc')
declare
fun heapAlloc(heap UInt32, flags UInt32, bytes SizeOfPointer) ArrayPointer<Void>
fun heapAlloc(heap SizeOfPointer, flags UInt32, bytes SizeOfPointer) ArrayPointer<Void>
// TODO
// let kernel32 = "kernel32.dll" (uppercase?)
// @dllImport(kernel32) (fpc)
Expand Down
21 changes: 17 additions & 4 deletions dlls/kernel32.dll/kernelMain.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,25 @@
// Entry point of the project

@customHeader('
void *tmemcpy(void *dest, const void *src, uint64_t count) {
tofitaDebugLog_(L"tmemcpy", (uint64_t)((int32_t)0), (uint64_t)((int32_t)0));
uint8_t *dst8 = (uint8_t *)dest;
const uint8_t *src8 = (const uint8_t *)src;
while (count--) {
*dst8++ = *src8++;
}
return dest;
}
// TODO
#define memcpy(z,u,x) tmemcpy(z,u,x)
#define HEXA_NO_DEFAULT_INCLUDES
#define HEXA_MAIN mainHexa
#define HEXA_NEW(z) ((void*)0)
#define HeapAlloc(z,...) ((void*)0)
#define HeapAlloc heapAlloc_
#define GetProcessHeap() 0
// TODO ^
#define memcpy(z,...) {}
#define wprintf(z,...) {}
#define HEAP_ZERO_MEMORY ((void*)0)
#define fflush(z) {}
Expand Down Expand Up @@ -50,6 +63,7 @@ void _memset() { } // TODO TODO TODO
void startup() {
// TODO hexa
HEXA_MAIN(0, nullptr);
}
#ifdef bit64
Expand All @@ -62,6 +76,5 @@ __attribute__((stdcall)) void _DllMainCRTStartup(void *, void *, void *) {
startup();
}
#endif
')
declare fun entry() Void
60 changes: 31 additions & 29 deletions dlls/msvcrt.dll/hexa.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
{
"name": "ClangRuntime",
"version": "1.0.0",
"description": "Greentea OS",
"author": "PeyTy",
"license": "LGPL-3.0-only",
"global": [
"../types",
"../../kernel/syscalls/syscalls",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"msvcrt.header",
"msvcrtMain",
"msvcrtVars"
],
"targets": [
{
"name": "default",
"generator": "c",
"output": "msvcrt.64.c",
"options": []
},
{
"name": "i386",
"generator": "c",
"output": "msvcrt.32.c",
"options": []
}
],
"entry": "msvcrt"
"name": "ClangRuntime",
"version": "1.0.0",
"description": "Greentea OS",
"author": "PeyTy",
"license": "LGPL-3.0-only",
"global": [
"../types",
"../../kernel/syscalls/syscalls",
"../tofita32.dll/tofita32.header",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"msvcrt.header",
"msvcrtMain",
"msvcrtVars"
],
"targets": [
{
"name": "default",
"generator": "c",
"output": "msvcrt.64.c",
"options": []
},
{
"name": "i386",
"generator": "c",
"output": "msvcrt.32.c",
"options": [
]
}
],
"entry": "msvcrt"
}
11 changes: 6 additions & 5 deletions dlls/msvcrt.dll/msvcrt.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ fun stub() {}
@linkName('_DllMainCRTStartup_TODO')
#if bit32
@stdcall
@stdcall
#else
@fastcall
@fastcall
#end
fun _DllMainCRTStartup(
unusedX Any,
unusedY Any,
unusedZ Any
unusedX Any,
unusedY Any,
unusedZ Any
) Void {
// TODO
// TODO
}

0 comments on commit 370218b

Please sign in to comment.