mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 11:18:30 +00:00
Get life.com in MODE=tiny back down to 12kb
This commit is contained in:
parent
23b72eb617
commit
b90fa996b4
14 changed files with 199 additions and 72 deletions
|
@ -44,12 +44,12 @@ textwindows noasan struct DirectMap sys_mmap_nt(void *addr, size_t size,
|
|||
* combination of flags, that'll cause Windows to actually do this!
|
||||
*/
|
||||
upsize = ROUNDUP(size, FRAMESIZE);
|
||||
if ((dm.maphandle = CreateFileMappingNuma(
|
||||
-1, &kNtIsInheritable, kNtPageExecuteReadwrite, upsize >> 32,
|
||||
upsize, NULL, kNtNumaNoPreferredNode))) {
|
||||
if ((dm.addr = MapViewOfFileExNuma(
|
||||
dm.maphandle, kNtFileMapWrite | kNtFileMapExecute, 0, 0, upsize,
|
||||
addr, kNtNumaNoPreferredNode))) {
|
||||
if ((dm.maphandle =
|
||||
CreateFileMapping(-1, &kNtIsInheritable, kNtPageExecuteReadwrite,
|
||||
upsize >> 32, upsize, NULL))) {
|
||||
if ((dm.addr = MapViewOfFileEx(dm.maphandle,
|
||||
kNtFileMapWrite | kNtFileMapExecute, 0, 0,
|
||||
upsize, addr))) {
|
||||
for (i = 0; i < size; i += got) {
|
||||
got = 0;
|
||||
op.Internal = 0;
|
||||
|
@ -68,16 +68,15 @@ textwindows noasan struct DirectMap sys_mmap_nt(void *addr, size_t size,
|
|||
CloseHandle(dm.maphandle);
|
||||
}
|
||||
} else {
|
||||
if ((dm.maphandle = CreateFileMappingNuma(
|
||||
if ((dm.maphandle = CreateFileMapping(
|
||||
handle, &kNtIsInheritable,
|
||||
(prot & PROT_WRITE) ? kNtPageExecuteReadwrite : kNtPageExecuteRead,
|
||||
handle != -1 ? 0 : size >> 32, handle != -1 ? 0 : size, NULL,
|
||||
kNtNumaNoPreferredNode))) {
|
||||
if ((dm.addr = MapViewOfFileExNuma(
|
||||
dm.maphandle,
|
||||
(prot & PROT_WRITE) ? kNtFileMapWrite | kNtFileMapExecute
|
||||
: kNtFileMapRead | kNtFileMapExecute,
|
||||
off >> 32, off, size, addr, kNtNumaNoPreferredNode))) {
|
||||
handle != -1 ? 0 : size >> 32, handle != -1 ? 0 : size, NULL))) {
|
||||
if ((dm.addr = MapViewOfFileEx(dm.maphandle,
|
||||
(prot & PROT_WRITE)
|
||||
? kNtFileMapWrite | kNtFileMapExecute
|
||||
: kNtFileMapRead | kNtFileMapExecute,
|
||||
off >> 32, off, size, addr))) {
|
||||
return dm;
|
||||
}
|
||||
CloseHandle(dm.maphandle);
|
||||
|
|
|
@ -75,15 +75,13 @@ textwindows int ntspawn(
|
|||
block = NULL;
|
||||
if (__mkntpath(prog, prog16) == -1) return -1;
|
||||
blocksize = ROUNDUP(sizeof(*block), FRAMESIZE);
|
||||
if ((handle = CreateFileMappingNuma(
|
||||
if ((handle = CreateFileMapping(
|
||||
-1,
|
||||
&(struct NtSecurityAttributes){sizeof(struct NtSecurityAttributes),
|
||||
NULL, false},
|
||||
pushpop(kNtPageReadwrite), 0, blocksize, NULL,
|
||||
kNtNumaNoPreferredNode)) &&
|
||||
(block =
|
||||
MapViewOfFileExNuma(handle, kNtFileMapRead | kNtFileMapWrite, 0, 0,
|
||||
blocksize, NULL, kNtNumaNoPreferredNode))) {
|
||||
pushpop(kNtPageReadwrite), 0, blocksize, NULL)) &&
|
||||
(block = MapViewOfFileEx(handle, kNtFileMapRead | kNtFileMapWrite, 0, 0,
|
||||
blocksize, NULL))) {
|
||||
if (mkntcmdline(block->cmdline, prog, argv) != -1 &&
|
||||
mkntenvblock(block->envvars, envp, extravar) != -1) {
|
||||
if (CreateProcess(prog16, block->cmdline, opt_lpProcessAttributes,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue