39 lines
1.3 KiB
C
39 lines
1.3 KiB
C
// POSIX process startup. This file owns process-local POSIX personality initialization before main runs.
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <ntlite/exception.h>
|
|
#include <ntlite/syscall.h>
|
|
|
|
extern int main(int argc, char** argv, char** envp);
|
|
__declspec(dllimport) uint32_t __ntl_posix_process_start(void);
|
|
__declspec(dllimport) uint32_t __ntl_posix_process_vectors(int* argcOut,
|
|
char*** argvOut,
|
|
char*** envpOut);
|
|
|
|
// Initializes POSIX process state and exits with main's return value.
|
|
void PosixStart(void) {
|
|
KSTATUS status = NtlInitializeExceptionRuntime();
|
|
if (status != NTLSTATUS_SUCCESS) {
|
|
while (true) SysExitProcess((int32_t)status);
|
|
}
|
|
|
|
status = __ntl_posix_process_start();
|
|
if (status != NTLSTATUS_SUCCESS) {
|
|
while (true) SysExitProcess((int32_t)status);
|
|
}
|
|
|
|
int argc = 0;
|
|
char** argv = (char**)0;
|
|
char** envp = (char**)0;
|
|
status = __ntl_posix_process_vectors(&argc, &argv, &envp);
|
|
if (status != NTLSTATUS_SUCCESS) {
|
|
while (true) SysExitProcess((int32_t)status);
|
|
}
|
|
|
|
int exitCode = main(argc, argv, envp);
|
|
exit(exitCode);
|
|
while (true) {}
|
|
}
|