2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
20 /* The global error value
24 /* Standard system handles for stdin, stdout, and stderr.
26 FILE_OBJECT
*hstdin
, *hstdout
, *hstderr
;
28 static int CreateStdHandles(void);
30 /*********************************************************************
31 * CloseHandle (KERNEL32.23)
33 BOOL
CloseHandle(KERNEL_OBJECT
*handle
)
37 if(ValidateKernelObject(handle
) != 0)
39 SetLastError(ERROR_INVALID_HANDLE
);
45 case KERNEL_OBJECT_UNUSED
:
46 SetLastError(ERROR_INVALID_HANDLE
);
49 case KERNEL_OBJECT_FILE
:
50 rc
= CloseFileHandle((FILE_OBJECT
*)handle
);
54 dprintf_win32(stddeb
, "CloseHandle: type %ld not implemented yet.\n",
59 ReleaseKernelObject(handle
);
63 /***********************************************************************
64 * GetModuleFileNameA (KERNEL32.235)
66 DWORD
GetModuleFileNameA(HMODULE hModule
, LPSTR lpFilename
, DWORD nSize
)
68 strcpy(lpFilename
, "c:\\dummy");
72 /***********************************************************************
73 * GetModuleHandle (KERNEL32.237)
75 HMODULE
WIN32_GetModuleHandle(char *module
)
79 dprintf_win32(stddeb
, "GetModuleHandle: %s\n", module
? module
: "NULL");
80 /* Freecell uses the result of GetModuleHandleA(0) as the hInstance in
81 all calls to e.g. CreateWindowEx. */
83 TDB
*pTask
= (TDB
*)GlobalLock16( GetCurrentTask() );
84 hModule
= pTask
->hInstance
;
86 hModule
= GetModuleHandle(module
);
87 dprintf_win32(stddeb
, "GetModuleHandle: returning %d\n", hModule
);
91 /***********************************************************************
92 * GetStartupInfoA (KERNEL32.273)
94 VOID
GetStartupInfoA(LPSTARTUPINFO lpStartupInfo
)
96 lpStartupInfo
->cb
= sizeof(STARTUPINFO
);
97 lpStartupInfo
->lpReserved
= NULL
;
98 lpStartupInfo
->lpDesktop
= "Desktop";
99 lpStartupInfo
->lpTitle
= "Title";
101 lpStartupInfo
->cbReserved2
= 0;
102 lpStartupInfo
->lpReserved2
= NULL
; /* must be NULL for VC runtime */
103 lpStartupInfo
->hStdInput
= (HANDLE
)0;
104 lpStartupInfo
->hStdOutput
= (HANDLE
)1;
105 lpStartupInfo
->hStdError
= (HANDLE
)2;
108 /* Initialize whatever internal data structures we need.
110 * Returns 1 on success, 0 on failure.
112 int KERN32_Init(void)
115 /* Initialize exception handling */
119 /* Create the standard system handles
121 if(CreateStdHandles() != 0)
127 /* CreateStdHandles creates the standard input, output, and error handles.
128 * These handles aren't likely to be used since they're generally used for
129 * console output, but startup code still likes to mess with them. They're
130 * also useful for debugging since apps and runtime libraries might write
133 * Returns 0 on success, nonzero on failure.
135 static int CreateStdHandles(void)
137 /* Create the standard input handle.
139 hstdin
= (FILE_OBJECT
*)CreateKernelObject(sizeof(FILE_OBJECT
));
142 hstdin
->common
.magic
= KERNEL_OBJECT_FILE
;
144 hstdin
->type
= FILE_TYPE_CHAR
;
145 hstdin
->misc_flags
= 0;
147 /* Create the standard output handle
149 hstdout
= (FILE_OBJECT
*)CreateKernelObject(sizeof(FILE_OBJECT
));
152 hstdout
->common
.magic
= KERNEL_OBJECT_FILE
;
154 hstdout
->type
= FILE_TYPE_CHAR
;
155 hstdout
->misc_flags
= 0;
157 /* Create the standard error handle
159 hstderr
= (FILE_OBJECT
*)CreateKernelObject(sizeof(FILE_OBJECT
));
162 hstderr
->common
.magic
= KERNEL_OBJECT_FILE
;
164 hstderr
->type
= FILE_TYPE_CHAR
;
165 hstderr
->misc_flags
= 0;