2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
17 /* The global error value
21 /* Standard system handles for stdin, stdout, and stderr.
23 FILE_OBJECT
*hstdin
, *hstdout
, *hstderr
;
25 static int CreateStdHandles(void);
27 /*********************************************************************
28 * CloseHandle (KERNEL32.23)
30 BOOL
CloseHandle(HANDLE32 handle
)
34 if(ValidateKernelObject(handle
) != 0)
36 SetLastError(ERROR_INVALID_HANDLE
);
42 case KERNEL_OBJECT_UNUSED
:
43 SetLastError(ERROR_INVALID_HANDLE
);
46 case KERNEL_OBJECT_FILE
:
47 rc
= CloseFileHandle((FILE_OBJECT
*)handle
);
51 printf("CloseHandle: type %ld not implemented yet.\n",
56 ReleaseKernelObject(handle
);
60 /***********************************************************************
61 * GetModuleFileNameA (KERNEL32.235)
63 DWORD
GetModuleFileNameA(HMODULE hModule
, LPSTR lpFilename
, DWORD nSize
)
65 strcpy(lpFilename
, "c:\\dummy");
69 /***********************************************************************
70 * GetModuleHandle (KERNEL32.237)
72 HMODULE
WIN32_GetModuleHandle(char *module
)
77 return GetModuleHandle(module
);
80 /***********************************************************************
81 * GetStartupInfoA (KERNEL32.273)
83 VOID
GetStartupInfoA(LPSTARTUPINFO lpStartupInfo
)
85 lpStartupInfo
->cb
= sizeof(STARTUPINFO
);
86 lpStartupInfo
->lpReserved
= NULL
;
87 lpStartupInfo
->lpDesktop
= "Desktop";
88 lpStartupInfo
->lpTitle
= "Title";
90 lpStartupInfo
->lpReserved2
= NULL
; /* must be NULL for VC runtime */
91 lpStartupInfo
->hStdInput
= (HANDLE
)0;
92 lpStartupInfo
->hStdOutput
= (HANDLE
)1;
93 lpStartupInfo
->hStdError
= (HANDLE
)2;
96 /* Initialize whatever internal data structures we need.
98 * Returns 1 on success, 0 on failure.
100 int KERN32_Init(void)
102 /* Create the standard system handles
104 if(CreateStdHandles() != 0)
110 /* CreateStdHandles creates the standard input, output, and error handles.
111 * These handles aren't likely to be used since they're generally used for
112 * console output, but startup code still likes to mess with them. They're
113 * also useful for debugging since apps and runtime libraries might write
116 * Returns 0 on success, nonzero on failure.
118 static int CreateStdHandles(void)
120 /* Create the standard input handle.
122 hstdin
= (FILE_OBJECT
*)CreateKernelObject(sizeof(FILE_OBJECT
));
125 hstdin
->common
.magic
= KERNEL_OBJECT_FILE
;
127 hstdin
->type
= FILE_TYPE_CHAR
;
128 hstdin
->misc_flags
= 0;
130 /* Create the standard output handle
132 hstdout
= (FILE_OBJECT
*)CreateKernelObject(sizeof(FILE_OBJECT
));
135 hstdout
->common
.magic
= KERNEL_OBJECT_FILE
;
137 hstdout
->type
= FILE_TYPE_CHAR
;
138 hstdout
->misc_flags
= 0;
140 /* Create the standard error handle
142 hstderr
= (FILE_OBJECT
*)CreateKernelObject(sizeof(FILE_OBJECT
));
145 hstderr
->common
.magic
= KERNEL_OBJECT_FILE
;
147 hstderr
->type
= FILE_TYPE_CHAR
;
148 hstderr
->misc_flags
= 0;