mirror of
https://github.com/UzixLS/KernelEx.git
synced 2025-07-18 23:11:19 +03:00
import KernelEx-4.0-Final
This commit is contained in:
0
kexcrt/LICENSE
Executable file → Normal file
0
kexcrt/LICENSE
Executable file → Normal file
0
kexcrt/README
Executable file → Normal file
0
kexcrt/README
Executable file → Normal file
0
kexcrt/_vsnprintf.c
Executable file → Normal file
0
kexcrt/_vsnprintf.c
Executable file → Normal file
6
kexcrt/abort.c
Normal file
6
kexcrt/abort.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include <windows.h>
|
||||
|
||||
void __cdecl abort(void)
|
||||
{
|
||||
RaiseException(0xdeafcafe, EXCEPTION_NONCONTINUABLE, 0, NULL);
|
||||
}
|
0
kexcrt/atoi.c
Executable file → Normal file
0
kexcrt/atoi.c
Executable file → Normal file
0
kexcrt/atol.c
Executable file → Normal file
0
kexcrt/atol.c
Executable file → Normal file
0
kexcrt/atoll.c
Executable file → Normal file
0
kexcrt/atoll.c
Executable file → Normal file
0
kexcrt/atox.c
Executable file → Normal file
0
kexcrt/atox.c
Executable file → Normal file
0
kexcrt/ctype/ctypefunc.h
Executable file → Normal file
0
kexcrt/ctype/ctypefunc.h
Executable file → Normal file
0
kexcrt/ctype/isalnum.c
Executable file → Normal file
0
kexcrt/ctype/isalnum.c
Executable file → Normal file
0
kexcrt/ctype/isalpha.c
Executable file → Normal file
0
kexcrt/ctype/isalpha.c
Executable file → Normal file
0
kexcrt/ctype/isascii.c
Executable file → Normal file
0
kexcrt/ctype/isascii.c
Executable file → Normal file
0
kexcrt/ctype/isblank.c
Executable file → Normal file
0
kexcrt/ctype/isblank.c
Executable file → Normal file
0
kexcrt/ctype/iscntrl.c
Executable file → Normal file
0
kexcrt/ctype/iscntrl.c
Executable file → Normal file
0
kexcrt/ctype/isdigit.c
Executable file → Normal file
0
kexcrt/ctype/isdigit.c
Executable file → Normal file
0
kexcrt/ctype/isgraph.c
Executable file → Normal file
0
kexcrt/ctype/isgraph.c
Executable file → Normal file
0
kexcrt/ctype/islower.c
Executable file → Normal file
0
kexcrt/ctype/islower.c
Executable file → Normal file
0
kexcrt/ctype/isprint.c
Executable file → Normal file
0
kexcrt/ctype/isprint.c
Executable file → Normal file
0
kexcrt/ctype/ispunct.c
Executable file → Normal file
0
kexcrt/ctype/ispunct.c
Executable file → Normal file
0
kexcrt/ctype/isspace.c
Executable file → Normal file
0
kexcrt/ctype/isspace.c
Executable file → Normal file
0
kexcrt/ctype/isupper.c
Executable file → Normal file
0
kexcrt/ctype/isupper.c
Executable file → Normal file
0
kexcrt/ctype/isxdigit.c
Executable file → Normal file
0
kexcrt/ctype/isxdigit.c
Executable file → Normal file
0
kexcrt/ctype/tolower.c
Executable file → Normal file
0
kexcrt/ctype/tolower.c
Executable file → Normal file
0
kexcrt/ctype/toupper.c
Executable file → Normal file
0
kexcrt/ctype/toupper.c
Executable file → Normal file
0
kexcrt/ctypes.c
Executable file → Normal file
0
kexcrt/ctypes.c
Executable file → Normal file
0
kexcrt/ctypes.h
Executable file → Normal file
0
kexcrt/ctypes.h
Executable file → Normal file
9
kexcrt/exit.c
Normal file
9
kexcrt/exit.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <windows.h>
|
||||
|
||||
void __exit(void);
|
||||
|
||||
void exit(int v)
|
||||
{
|
||||
__exit();
|
||||
ExitProcess(v);
|
||||
}
|
27
kexcrt/gcc/dllcrt0.c
Normal file
27
kexcrt/gcc/dllcrt0.c
Normal file
@ -0,0 +1,27 @@
|
||||
#include <windows.h>
|
||||
#include "init.h"
|
||||
|
||||
extern BOOL WINAPI DllMain(
|
||||
HINSTANCE hDllHandle,
|
||||
DWORD dwReason,
|
||||
LPVOID lpReserved
|
||||
);
|
||||
|
||||
BOOL WINAPI _DllMainCRTStartup(
|
||||
HINSTANCE hDllHandle,
|
||||
DWORD dwReason,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
__init();
|
||||
|
||||
ret = DllMain(hDllHandle, dwReason, lpReserved);
|
||||
|
||||
if (dwReason == DLL_PROCESS_DETACH)
|
||||
__exit();
|
||||
|
||||
return ret;
|
||||
}
|
105
kexcrt/gcc/init.c
Normal file
105
kexcrt/gcc/init.c
Normal file
@ -0,0 +1,105 @@
|
||||
#include <stdlib.h>
|
||||
#include "init.h"
|
||||
|
||||
#define MAX_ATEXIT 32
|
||||
|
||||
typedef void (__cdecl *_PVFV)(void);
|
||||
|
||||
static _PVFV _atexitlist[MAX_ATEXIT];
|
||||
static int _atexitlist_cnt;
|
||||
|
||||
extern _PVFV __CTOR_LIST__[];
|
||||
extern _PVFV __DTOR_LIST__[];
|
||||
|
||||
extern void _pei386_runtime_relocator (void);
|
||||
|
||||
int atexit(_PVFV func)
|
||||
{
|
||||
if (_atexitlist_cnt < MAX_ATEXIT)
|
||||
{
|
||||
_atexitlist[_atexitlist_cnt++] = func;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
__do_global_dtors (void)
|
||||
{
|
||||
static _PVFV *p = __DTOR_LIST__ + 1;
|
||||
|
||||
/*
|
||||
* Call each destructor in the destructor list until a null pointer
|
||||
* is encountered.
|
||||
*/
|
||||
while (*p)
|
||||
{
|
||||
(*(p)) ();
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__do_global_ctors (void)
|
||||
{
|
||||
unsigned long nptrs = (unsigned long) __CTOR_LIST__[0];
|
||||
unsigned i;
|
||||
|
||||
/*
|
||||
* If the first entry in the constructor list is -1 then the list
|
||||
* is terminated with a null entry. Otherwise the first entry was
|
||||
* the number of pointers in the list.
|
||||
*/
|
||||
if (nptrs == -1)
|
||||
{
|
||||
for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++)
|
||||
;
|
||||
}
|
||||
|
||||
/*
|
||||
* Go through the list backwards calling constructors.
|
||||
*/
|
||||
for (i = nptrs; i >= 1; i--)
|
||||
{
|
||||
__CTOR_LIST__[i] ();
|
||||
}
|
||||
|
||||
/*
|
||||
* Register the destructors for processing on exit.
|
||||
*/
|
||||
atexit (__do_global_dtors);
|
||||
}
|
||||
|
||||
static int initialized = 0;
|
||||
|
||||
void __init(void)
|
||||
{
|
||||
_pei386_runtime_relocator();
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
initialized = 1;
|
||||
__do_global_ctors ();
|
||||
}
|
||||
}
|
||||
|
||||
static int exited = 0;
|
||||
|
||||
void __exit(void)
|
||||
{
|
||||
if (exited)
|
||||
return;
|
||||
exited = 1;
|
||||
|
||||
if (_atexitlist_cnt)
|
||||
{
|
||||
_PVFV* p;
|
||||
for (p = _atexitlist + _atexitlist_cnt - 1 ; p >= _atexitlist ; p--)
|
||||
{
|
||||
if (*p != NULL)
|
||||
(**p)();
|
||||
p--;
|
||||
}
|
||||
}
|
||||
}
|
7
kexcrt/gcc/init.h
Normal file
7
kexcrt/gcc/init.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef __INIT_H
|
||||
#define __INIT_H
|
||||
|
||||
void __init(void);
|
||||
void __exit(void);
|
||||
|
||||
#endif
|
3
kexcrt/gcc/pseudo-reloc-list.c
Normal file
3
kexcrt/gcc/pseudo-reloc-list.c
Normal file
@ -0,0 +1,3 @@
|
||||
/* Define here in .bss in case not defined by linker script. */
|
||||
char __RUNTIME_PSEUDO_RELOC_LIST_END__ = 0;
|
||||
char __RUNTIME_PSEUDO_RELOC_LIST__ = 0;
|
46
kexcrt/gcc/pseudo-reloc.c
Normal file
46
kexcrt/gcc/pseudo-reloc.c
Normal file
@ -0,0 +1,46 @@
|
||||
/* pseudo-reloc.c
|
||||
|
||||
Written by Egor Duda <deo@logos-m.ru>
|
||||
THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
|
||||
This source code is offered for use in the public domain. You may
|
||||
use, modify or distribute it freely.
|
||||
|
||||
This code is distributed in the hope that it will be useful but
|
||||
WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
DISCLAMED. This includes but is not limited to warrenties of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
extern char __RUNTIME_PSEUDO_RELOC_LIST__;
|
||||
extern char __RUNTIME_PSEUDO_RELOC_LIST_END__;
|
||||
extern char _image_base__;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD addend;
|
||||
DWORD target;
|
||||
}
|
||||
runtime_pseudo_reloc;
|
||||
|
||||
static void
|
||||
do_pseudo_reloc (void* start, void* end, void* base)
|
||||
{
|
||||
DWORD reloc_target;
|
||||
runtime_pseudo_reloc* r;
|
||||
for (r = (runtime_pseudo_reloc*) start; r < (runtime_pseudo_reloc*) end; r++)
|
||||
{
|
||||
reloc_target = (DWORD) base + r->target;
|
||||
*((DWORD*) reloc_target) += r->addend;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_pei386_runtime_relocator ()
|
||||
{
|
||||
do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,
|
||||
&__RUNTIME_PSEUDO_RELOC_LIST_END__,
|
||||
&_image_base__);
|
||||
}
|
16
kexcrt/kexcrt.dsp
Executable file → Normal file
16
kexcrt/kexcrt.dsp
Executable file → Normal file
@ -58,6 +58,10 @@ SOURCE=.\_vsnprintf.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\abort.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msvc\argcargv.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -86,6 +90,10 @@ SOURCE=.\msvc\dllcrt0.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\exit.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\msvc\init.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -262,6 +270,10 @@ SOURCE=.\strtok.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\strtok_r.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\strtol.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -312,6 +324,10 @@ SOURCE=.\vsscanf.c
|
||||
|
||||
SOURCE=.\msvc\wincrt0.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\write.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
|
6
kexcrt/makefile
Executable file → Normal file
6
kexcrt/makefile
Executable file → Normal file
@ -1,5 +1,6 @@
|
||||
OBJ = atoi.o atol.o atoll.o ctypes.o memccpy.o memchr.o memcmp.o memcpy.o memmem.o memmove.o memrchr.o memset.o memswap.o snprintf.o sprintf.o sscanf.o strcat.o strchr.o strcmp.o strcmpi.o strcpy.o strlen.o strncat.o strncmp.o strncpy.o strnicmp.o strnlen.o strntoimax.o strntoumax.o strpbrk.o strrchr.o strsep.o strstr.o strtok.o strtol.o strtoll.o strtoul.o strtoull.o strtoumax.o strupr.o strxspn.o vsnprintf.o vsprintf.o vsscanf.o _vsnprintf.o \
|
||||
ctype/isalnum.o ctype/isalpha.o ctype/isascii.o ctype/isblank.o ctype/iscntrl.o ctype/isdigit.o ctype/isgraph.o ctype/islower.o ctype/isprint.o ctype/ispunct.o ctype/isspace.o ctype/isupper.o ctype/isxdigit.o ctype/tolower.o ctype/toupper.o
|
||||
OBJ = abort.o atoi.o atol.o atoll.o ctypes.o memccpy.o memchr.o memcmp.o memcpy.o memmem.o memmove.o memrchr.o memset.o memswap.o snprintf.o sprintf.o sscanf.o strcat.o strchr.o strcmp.o strcmpi.o strcpy.o strlen.o strncat.o strncmp.o strncpy.o strnicmp.o strnlen.o strntoimax.o strntoumax.o strpbrk.o strrchr.o strsep.o strstr.o strtok.o strtok_r.o strtol.o strtoll.o strtoul.o strtoull.o strtoumax.o strupr.o strxspn.o vsnprintf.o vsprintf.o vsscanf.o _vsnprintf.o write.o exit.o \
|
||||
ctype/isalnum.o ctype/isalpha.o ctype/isascii.o ctype/isblank.o ctype/iscntrl.o ctype/isdigit.o ctype/isgraph.o ctype/islower.o ctype/isprint.o ctype/ispunct.o ctype/isspace.o ctype/isupper.o ctype/isxdigit.o ctype/tolower.o ctype/toupper.o \
|
||||
gcc/init.o gcc/dllcrt0.o gcc/pseudo-reloc.o gcc/pseudo-reloc-list.o
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -O2 -s -I. -D__NO_CTYPE_INLINES -D__NO_ISOCEXT
|
||||
@ -11,6 +12,7 @@ all : $(BIN)
|
||||
clean :
|
||||
@del *.o >NUL
|
||||
@del ctype\*.o >NUL
|
||||
@del gcc\*.o >NUL
|
||||
|
||||
$(BIN) : $(OBJ)
|
||||
ar qcs $@ $(OBJ)
|
||||
|
4
kexcrt/makefile.msv
Executable file → Normal file
4
kexcrt/makefile.msv
Executable file → Normal file
@ -1,6 +1,6 @@
|
||||
OBJ = atoi.obj atol.obj atoll.obj ctypes.obj memccpy.obj memchr.obj memcmp.obj memcpy.obj memmem.obj memmove.obj memrchr.obj memset.obj memswap.obj snprintf.obj sprintf.obj sscanf.obj strcat.obj strchr.obj strcmp.obj strcmpi.obj strcpy.obj strlen.obj strncat.obj strncmp.obj strncpy.obj strnicmp.obj strnlen.obj strntoimax.obj strntoumax.obj strpbrk.obj strrchr.obj strsep.obj strstr.obj strtok.obj strtol.obj strtoll.obj strtoul.obj strtoull.obj strtoumax.obj strupr.obj strxspn.obj vsnprintf.obj vsprintf.obj vsscanf.obj _vsnprintf.obj \
|
||||
OBJ = abort.obj atoi.obj atol.obj atoll.obj ctypes.obj memccpy.obj memchr.obj memcmp.obj memcpy.obj memmem.obj memmove.obj memrchr.obj memset.obj memswap.obj snprintf.obj sprintf.obj sscanf.obj strcat.obj strchr.obj strcmp.obj strcmpi.obj strcpy.obj strlen.obj strncat.obj strncmp.obj strncpy.obj strnicmp.obj strnlen.obj strntoimax.obj strntoumax.obj strpbrk.obj strrchr.obj strsep.obj strstr.obj strtok.obj strtok_r.obj strtol.obj strtoll.obj strtoul.obj strtoull.obj strtoumax.obj strupr.obj strxspn.obj vsnprintf.obj vsprintf.obj vsscanf.obj _vsnprintf.obj write.obj exit.obj \
|
||||
ctype/isalnum.obj ctype/isalpha.obj ctype/isascii.obj ctype/isblank.obj ctype/iscntrl.obj ctype/isdigit.obj ctype/isgraph.obj ctype/islower.obj ctype/isprint.obj ctype/ispunct.obj ctype/isspace.obj ctype/isupper.obj ctype/isxdigit.obj ctype/tolower.obj ctype/toupper.obj \
|
||||
msvc/init.obj msvc/dllcrt0.obj
|
||||
msvc/init.obj msvc/dllcrt0.obj msvc/argcargv.obj msvc/concrt0.obj msvc/wincrt0.obj
|
||||
|
||||
CFLAGS = /O2 /Oi- /I. /nologo /D_CTYPE_DISABLE_MACROS
|
||||
|
||||
|
0
kexcrt/memccpy.c
Executable file → Normal file
0
kexcrt/memccpy.c
Executable file → Normal file
0
kexcrt/memchr.c
Executable file → Normal file
0
kexcrt/memchr.c
Executable file → Normal file
0
kexcrt/memcmp.c
Executable file → Normal file
0
kexcrt/memcmp.c
Executable file → Normal file
0
kexcrt/memcpy.c
Executable file → Normal file
0
kexcrt/memcpy.c
Executable file → Normal file
0
kexcrt/memmem.c
Executable file → Normal file
0
kexcrt/memmem.c
Executable file → Normal file
0
kexcrt/memmove.c
Executable file → Normal file
0
kexcrt/memmove.c
Executable file → Normal file
0
kexcrt/memrchr.c
Executable file → Normal file
0
kexcrt/memrchr.c
Executable file → Normal file
0
kexcrt/memset.c
Executable file → Normal file
0
kexcrt/memset.c
Executable file → Normal file
0
kexcrt/memswap.c
Executable file → Normal file
0
kexcrt/memswap.c
Executable file → Normal file
0
kexcrt/msvc/STDINT.H
Executable file → Normal file
0
kexcrt/msvc/STDINT.H
Executable file → Normal file
0
kexcrt/msvc/argcargv.c
Executable file → Normal file
0
kexcrt/msvc/argcargv.c
Executable file → Normal file
0
kexcrt/msvc/argcargv.h
Executable file → Normal file
0
kexcrt/msvc/argcargv.h
Executable file → Normal file
0
kexcrt/msvc/concrt0.c
Executable file → Normal file
0
kexcrt/msvc/concrt0.c
Executable file → Normal file
0
kexcrt/msvc/dllcrt0.c
Executable file → Normal file
0
kexcrt/msvc/dllcrt0.c
Executable file → Normal file
7
kexcrt/msvc/init.c
Executable file → Normal file
7
kexcrt/msvc/init.c
Executable file → Normal file
@ -65,8 +65,15 @@ int atexit(_PVFV func)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int exit_done;
|
||||
|
||||
void __exit(void)
|
||||
{
|
||||
if (exit_done)
|
||||
return;
|
||||
|
||||
exit_done = 1;
|
||||
|
||||
// do pre-terminators
|
||||
_initterm(__xp_a, __xp_z);
|
||||
// do terminators
|
||||
|
0
kexcrt/msvc/init.h
Executable file → Normal file
0
kexcrt/msvc/init.h
Executable file → Normal file
0
kexcrt/msvc/wincrt0.c
Executable file → Normal file
0
kexcrt/msvc/wincrt0.c
Executable file → Normal file
0
kexcrt/snprintf.c
Executable file → Normal file
0
kexcrt/snprintf.c
Executable file → Normal file
0
kexcrt/sprintf.c
Executable file → Normal file
0
kexcrt/sprintf.c
Executable file → Normal file
0
kexcrt/sscanf.c
Executable file → Normal file
0
kexcrt/sscanf.c
Executable file → Normal file
0
kexcrt/strcat.c
Executable file → Normal file
0
kexcrt/strcat.c
Executable file → Normal file
0
kexcrt/strchr.c
Executable file → Normal file
0
kexcrt/strchr.c
Executable file → Normal file
0
kexcrt/strcmp.c
Executable file → Normal file
0
kexcrt/strcmp.c
Executable file → Normal file
0
kexcrt/strcmpi.c
Executable file → Normal file
0
kexcrt/strcmpi.c
Executable file → Normal file
0
kexcrt/strcpy.c
Executable file → Normal file
0
kexcrt/strcpy.c
Executable file → Normal file
0
kexcrt/strlen.c
Executable file → Normal file
0
kexcrt/strlen.c
Executable file → Normal file
0
kexcrt/strncat.c
Executable file → Normal file
0
kexcrt/strncat.c
Executable file → Normal file
0
kexcrt/strncmp.c
Executable file → Normal file
0
kexcrt/strncmp.c
Executable file → Normal file
0
kexcrt/strncpy.c
Executable file → Normal file
0
kexcrt/strncpy.c
Executable file → Normal file
0
kexcrt/strnicmp.c
Executable file → Normal file
0
kexcrt/strnicmp.c
Executable file → Normal file
0
kexcrt/strnlen.c
Executable file → Normal file
0
kexcrt/strnlen.c
Executable file → Normal file
0
kexcrt/strntoimax.c
Executable file → Normal file
0
kexcrt/strntoimax.c
Executable file → Normal file
0
kexcrt/strntoumax.c
Executable file → Normal file
0
kexcrt/strntoumax.c
Executable file → Normal file
0
kexcrt/strpbrk.c
Executable file → Normal file
0
kexcrt/strpbrk.c
Executable file → Normal file
0
kexcrt/strrchr.c
Executable file → Normal file
0
kexcrt/strrchr.c
Executable file → Normal file
0
kexcrt/strsep.c
Executable file → Normal file
0
kexcrt/strsep.c
Executable file → Normal file
0
kexcrt/strstr.c
Executable file → Normal file
0
kexcrt/strstr.c
Executable file → Normal file
0
kexcrt/strtok.c
Executable file → Normal file
0
kexcrt/strtok.c
Executable file → Normal file
17
kexcrt/strtok_r.c
Normal file
17
kexcrt/strtok_r.c
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* strtok_r.c
|
||||
*/
|
||||
|
||||
char *strsep(char **stringp, const char *delim);
|
||||
|
||||
char *strtok_r(char *s, const char *delim, char **holder)
|
||||
{
|
||||
if (s)
|
||||
*holder = s;
|
||||
|
||||
do {
|
||||
s = strsep(holder, delim);
|
||||
} while (s && !*s);
|
||||
|
||||
return s;
|
||||
}
|
0
kexcrt/strtol.c
Executable file → Normal file
0
kexcrt/strtol.c
Executable file → Normal file
0
kexcrt/strtoll.c
Executable file → Normal file
0
kexcrt/strtoll.c
Executable file → Normal file
0
kexcrt/strtoul.c
Executable file → Normal file
0
kexcrt/strtoul.c
Executable file → Normal file
0
kexcrt/strtoull.c
Executable file → Normal file
0
kexcrt/strtoull.c
Executable file → Normal file
0
kexcrt/strtoumax.c
Executable file → Normal file
0
kexcrt/strtoumax.c
Executable file → Normal file
0
kexcrt/strtox.c
Executable file → Normal file
0
kexcrt/strtox.c
Executable file → Normal file
0
kexcrt/strupr.c
Executable file → Normal file
0
kexcrt/strupr.c
Executable file → Normal file
0
kexcrt/strxspn.c
Executable file → Normal file
0
kexcrt/strxspn.c
Executable file → Normal file
0
kexcrt/strxspn.h
Executable file → Normal file
0
kexcrt/strxspn.h
Executable file → Normal file
0
kexcrt/vsnprintf.c
Executable file → Normal file
0
kexcrt/vsnprintf.c
Executable file → Normal file
0
kexcrt/vsprintf.c
Executable file → Normal file
0
kexcrt/vsprintf.c
Executable file → Normal file
0
kexcrt/vsscanf.c
Executable file → Normal file
0
kexcrt/vsscanf.c
Executable file → Normal file
36
kexcrt/write.c
Normal file
36
kexcrt/write.c
Normal file
@ -0,0 +1,36 @@
|
||||
#include <windows.h>
|
||||
|
||||
#define STDIN_FILENO 0
|
||||
#define STDOUT_FILENO 1
|
||||
#define STDERR_FILENO 2
|
||||
|
||||
int __cdecl write(int fd, const void* buf, unsigned int size)
|
||||
{
|
||||
DWORD written;
|
||||
HANDLE hFile;
|
||||
|
||||
switch (fd)
|
||||
{
|
||||
case STDIN_FILENO:
|
||||
hFile = GetStdHandle(STD_INPUT_HANDLE);
|
||||
break;
|
||||
case STDOUT_FILENO:
|
||||
hFile = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
break;
|
||||
case STDERR_FILENO:
|
||||
hFile = GetStdHandle(STD_ERROR_HANDLE);
|
||||
break;
|
||||
default:
|
||||
hFile = (HANDLE) fd;
|
||||
}
|
||||
|
||||
if (!WriteFile(hFile, buf, size, &written, NULL))
|
||||
return -1;
|
||||
return written;
|
||||
|
||||
}
|
||||
|
||||
int __cdecl _write(int fd, const void* buf, unsigned int size)
|
||||
{
|
||||
return write(fd, buf, size);
|
||||
}
|
Reference in New Issue
Block a user