mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
f4f4caab0e
I wanted a tiny scriptable meltdown proof way to run userspace programs and visualize how program execution impacts memory. It helps to explain how things like Actually Portable Executable works. It can show you how the GCC generated code is going about manipulating matrices and more. I didn't feel fully comfortable with Qemu and Bochs because I'm not smart enough to understand them. I wanted something like gVisor but with much stronger levels of assurances. I wanted a single binary that'll run, on all major operating systems with an embedded GPL barrier ZIP filesystem that is tiny enough to transpile to JavaScript and run in browsers too. https://justine.storage.googleapis.com/emulator625.mp4
83 lines
5.8 KiB
C
83 lines
5.8 KiB
C
#ifndef COSMOPOLITAN_LIBC_NT_PROCESS_H_
|
|
#define COSMOPOLITAN_LIBC_NT_PROCESS_H_
|
|
#include "libc/nt/enum/accessmask.h"
|
|
#include "libc/nt/enum/processaccess.h"
|
|
#include "libc/nt/enum/processcreationflags.h"
|
|
#include "libc/nt/startupinfo.h"
|
|
#include "libc/nt/thunk/msabi.h"
|
|
#if 0
|
|
/* ░░░░
|
|
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
|
|
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
|
|
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
|
|
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
|
|
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
|
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
|
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
|
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
|
|
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
|
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
|
|
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
|
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
|
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
|
|
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
|
|
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
|
|
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
|
|
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
|
|
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
|
|
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
|
|
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
|
|
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
|
|
│ cosmopolitan § new technology » processes ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
#endif
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
COSMOPOLITAN_C_START_
|
|
|
|
struct NtProcessInformation;
|
|
struct NtSecurityAttributes;
|
|
struct NtStartupInfo;
|
|
|
|
bool32 CreateProcess(const char16_t *opt_lpApplicationName,
|
|
char16_t *lpCommandLine,
|
|
struct NtSecurityAttributes *opt_lpProcessAttributes,
|
|
struct NtSecurityAttributes *opt_lpThreadAttributes,
|
|
bool32 bInheritHandles, uint32_t dwCreationFlags,
|
|
void *opt_lpEnvironment,
|
|
const char16_t *opt_lpCurrentDirectory,
|
|
const struct NtStartupInfo *lpStartupInfo,
|
|
struct NtProcessInformation *opt_out_lpProcessInformation)
|
|
paramsnonnull((2, 9));
|
|
|
|
uint32_t GetThreadId(int64_t Thread); /* cf. NT_TID */
|
|
uint32_t GetProcessId(int64_t Process); /* cf. NT_PID */
|
|
void SetLastError(uint32_t dwErrCode);
|
|
uint32_t FormatMessage(uint32_t dwFlags, const void *lpSource,
|
|
uint32_t dwMessageId, uint32_t dwLanguageId,
|
|
char16_t *lpBuffer, uint32_t nSize, va_list *Arguments);
|
|
int64_t OpenProcess(uint32_t dwDesiredAccess, bool32 bInheritHandle,
|
|
uint32_t dwProcessId);
|
|
uint32_t GetCurrentProcessId(void); /* %gs:0x40 */
|
|
uint32_t GetEnvironmentVariable(const char16_t *lpName, char16_t *lpBuffer,
|
|
uint32_t nSize);
|
|
uint32_t SetEnvironmentVariable(const char16_t *lpName, char16_t *lpValue);
|
|
int32_t SetEnvironmentStrings(char16_t *NewEnvironment);
|
|
bool32 GetProcessAffinityMask(int64_t hProcess,
|
|
uintptr_t *lpProcessAffinityMask,
|
|
uintptr_t *lpSystemAffinityMask);
|
|
uint64_t /*bool32*/ SetProcessAffinityMask(int64_t hProcess,
|
|
uintptr_t dwProcessAffinityMask);
|
|
|
|
/* e.g. kNtAboveNormalPriorityClass, kNtHighPriorityClass */
|
|
uint32_t GetPriorityClass(int64_t hProcess);
|
|
bool32 SetPriorityClass(int64_t hProcess, uint32_t dwPriorityClass);
|
|
bool32 SetProcessPriorityBoost(int64_t hProcess, bool32 bDisablePriorityBoost);
|
|
bool32 GetProcessPriorityBoost(int64_t hProcess, bool32 *pDisablePriorityBoost);
|
|
|
|
#if ShouldUseMsabiAttribute()
|
|
#include "libc/nt/thunk/process.inc"
|
|
#endif /* ShouldUseMsabiAttribute() */
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_LIBC_NT_PROCESS_H_ */
|