mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
In search of meaningful error messages and some housekeeping on the stubs file.
svn path=/trunk/; revision=3825
This commit is contained in:
parent
0853d8cf3d
commit
accbf7c896
7 changed files with 955 additions and 925 deletions
|
@ -1,6 +1,7 @@
|
|||
kernel32.a
|
||||
kernel32.dll
|
||||
kernel32.nostrip.dll
|
||||
kernel32.sym
|
||||
kernel32.lib
|
||||
kernel32.coff
|
||||
base.tmp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile,v 1.53 2002/09/08 10:22:41 chorns Exp $
|
||||
# $Id: makefile,v 1.54 2002/12/06 13:14:13 robd Exp $
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
|
@ -31,9 +31,10 @@ SYNCH_OBJECTS = synch/critical.o synch/event.o synch/intrlck.o synch/mutex.o \
|
|||
synch/sem.o synch/timer.o synch/wait.o
|
||||
|
||||
MISC_OBJECTS = misc/error.o misc/atom.o misc/handle.o misc/env.o \
|
||||
misc/dllmain.o misc/comm.o \
|
||||
misc/dllmain.o misc/comm.o misc/errormsg.o \
|
||||
misc/console.o misc/time.o misc/stubs.o misc/ldr.o misc/res.o \
|
||||
misc/debug.o misc/sysinfo.o misc/profile.o
|
||||
misc/debug.o misc/sysinfo.o misc/profile.o \
|
||||
misc/mbchars.o misc/muldiv.o misc/getname.o
|
||||
|
||||
FILE_OBJECTS = file/file.o file/curdir.o file/lfile.o file/dir.o \
|
||||
file/iocompl.o file/volume.o file/deviceio.o file/dosdev.o \
|
||||
|
|
88
reactos/lib/kernel32/misc/errormsg.c
Normal file
88
reactos/lib/kernel32/misc/errormsg.c
Normal file
|
@ -0,0 +1,88 @@
|
|||
/* $Id: errormsg.c,v 1.1 2002/12/06 13:14:14 robd Exp $
|
||||
*
|
||||
* reactos/lib/kernel32/misc/errormsg.c
|
||||
*
|
||||
*/
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
// #define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
#include <kernel32/error.h>
|
||||
|
||||
|
||||
/* INTERNAL */
|
||||
|
||||
|
||||
/* EXPORTED */
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
FormatMessageW(
|
||||
DWORD dwFlags,
|
||||
LPCVOID lpSource,
|
||||
DWORD dwMessageId,
|
||||
DWORD dwLanguageId,
|
||||
LPWSTR lpBuffer,
|
||||
DWORD nSize,
|
||||
va_list* Arguments)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
FormatMessageA(
|
||||
DWORD dwFlags,
|
||||
LPCVOID lpSource,
|
||||
DWORD dwMessageId,
|
||||
DWORD dwLanguageId,
|
||||
LPSTR lpBuffer,
|
||||
DWORD nSize,
|
||||
va_list* Arguments)
|
||||
{
|
||||
HLOCAL pBuf = NULL;
|
||||
//LPSTR pBuf = NULL;
|
||||
|
||||
#define MAX_MSG_STR_LEN 200
|
||||
|
||||
if (lpBuffer != NULL) {
|
||||
|
||||
if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) {
|
||||
pBuf = LocalAlloc(LPTR, max(nSize, MAX_MSG_STR_LEN));
|
||||
if (pBuf == NULL) {
|
||||
return 0;
|
||||
}
|
||||
*(LPSTR*)lpBuffer = pBuf;
|
||||
} else {
|
||||
pBuf = *(LPSTR*)lpBuffer;
|
||||
}
|
||||
|
||||
if (dwFlags & FORMAT_MESSAGE_FROM_STRING) {
|
||||
} else {
|
||||
}
|
||||
|
||||
//FORMAT_MESSAGE_IGNORE_INSERTS
|
||||
//FORMAT_MESSAGE_FROM_STRING
|
||||
//FORMAT_MESSAGE_FROM_HMODULE
|
||||
//FORMAT_MESSAGE_FROM_SYSTEM
|
||||
//FORMAT_MESSAGE_ARGUMENT_ARRAY
|
||||
|
||||
}
|
||||
/*
|
||||
if (FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
0,
|
||||
error,
|
||||
MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
|
||||
(PTSTR)&msg,
|
||||
0,
|
||||
NULL)
|
||||
)
|
||||
*/
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
49
reactos/lib/kernel32/misc/getname.c
Normal file
49
reactos/lib/kernel32/misc/getname.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* $Id: getname.c,v 1.1 2002/12/06 13:14:14 robd Exp $
|
||||
*
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
GetComputerNameW(LPWSTR lpBuffer, LPDWORD nSize)
|
||||
{
|
||||
WCHAR Name[MAX_COMPUTERNAME_LENGTH + 1];
|
||||
DWORD Size = 0;
|
||||
|
||||
/*
|
||||
* FIXME: get the computer's name from the registry.
|
||||
*/
|
||||
lstrcpyW(Name, L"ROSHost"); /* <-- FIXME -- */
|
||||
Size = lstrlenW(Name) + 1;
|
||||
if (Size > *nSize) {
|
||||
*nSize = Size;
|
||||
SetLastError(ERROR_BUFFER_OVERFLOW);
|
||||
return FALSE;
|
||||
}
|
||||
lstrcpyW(lpBuffer, Name);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize)
|
||||
{
|
||||
WCHAR Name[MAX_COMPUTERNAME_LENGTH + 1];
|
||||
int i;
|
||||
|
||||
if (FALSE == GetComputerNameW(Name, nSize)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* FIXME --> */
|
||||
/* Use UNICODE to ANSI */
|
||||
for (i = 0; Name[i]; ++i) {
|
||||
lpBuffer[i] = (CHAR)Name[i];
|
||||
}
|
||||
lpBuffer[i] = '\0';
|
||||
/* FIXME <-- */
|
||||
|
||||
return TRUE;
|
||||
}
|
297
reactos/lib/kernel32/misc/mbchars.c
Normal file
297
reactos/lib/kernel32/misc/mbchars.c
Normal file
|
@ -0,0 +1,297 @@
|
|||
/* $Id: mbchars.c,v 1.1 2002/12/06 13:14:14 robd Exp $
|
||||
*
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* NAME PRIVATE
|
||||
* IsInstalledCP@4
|
||||
*
|
||||
* RETURN VALUE
|
||||
* TRUE if CodePage is installed in the system.
|
||||
*/
|
||||
static
|
||||
BOOL
|
||||
STDCALL
|
||||
IsInstalledCP(UINT CodePage)
|
||||
{
|
||||
/* FIXME */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* NAME EXPORTED
|
||||
* MultiByteToWideChar@24
|
||||
*
|
||||
* ARGUMENTS
|
||||
* CodePage
|
||||
* CP_ACP ANSI code page
|
||||
* CP_MACCP Macintosh code page
|
||||
* CP_OEMCP OEM code page
|
||||
* (UINT) Any installed code page
|
||||
*
|
||||
* dwFlags
|
||||
* MB_PRECOMPOSED
|
||||
* MB_COMPOSITE
|
||||
* MB_ERR_INVALID_CHARS
|
||||
* MB_USEGLYPHCHARS
|
||||
*
|
||||
* lpMultiByteStr
|
||||
* Input buffer;
|
||||
*
|
||||
* cchMultiByte
|
||||
* Size of MultiByteStr, or -1 if MultiByteStr is
|
||||
* NULL terminated;
|
||||
*
|
||||
* lpWideCharStr
|
||||
* Output buffer;
|
||||
*
|
||||
* cchWideChar
|
||||
* Size (in WCHAR unit) of WideCharStr, or 0
|
||||
* if the caller just wants to know how large
|
||||
* WideCharStr should be for a successful
|
||||
* conversion.
|
||||
*
|
||||
* RETURN VALUE
|
||||
* 0 on error; otherwise the number of WCHAR written
|
||||
* in the WideCharStr buffer.
|
||||
*
|
||||
* NOTE
|
||||
* A raw converter for now. It assumes lpMultiByteStr is
|
||||
* NEVER multi-byte (that is each input character is
|
||||
* 8-bit ASCII) and is ALWAYS NULL terminated.
|
||||
* FIXME-FIXME-FIXME-FIXME
|
||||
*/
|
||||
INT
|
||||
STDCALL
|
||||
MultiByteToWideChar(
|
||||
UINT CodePage,
|
||||
DWORD dwFlags,
|
||||
LPCSTR lpMultiByteStr,
|
||||
int cchMultiByte,
|
||||
LPWSTR lpWideCharStr,
|
||||
int cchWideChar)
|
||||
{
|
||||
int InStringLength = 0;
|
||||
PCHAR r;
|
||||
PWCHAR w;
|
||||
int cchConverted;
|
||||
|
||||
/*
|
||||
* Check the parameters.
|
||||
*/
|
||||
if (/* --- CODE PAGE --- */
|
||||
( (CP_ACP != CodePage)
|
||||
&& (CP_MACCP != CodePage)
|
||||
&& (CP_OEMCP != CodePage)
|
||||
&& (FALSE == IsInstalledCP(CodePage)) )
|
||||
/* --- FLAGS --- */
|
||||
|| (dwFlags & ~(MB_PRECOMPOSED | MB_COMPOSITE |
|
||||
MB_ERR_INVALID_CHARS | MB_USEGLYPHCHARS))
|
||||
/* --- INPUT BUFFER --- */
|
||||
|| (NULL == lpMultiByteStr) )
|
||||
{
|
||||
SetLastError (ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Compute the input buffer length.
|
||||
*/
|
||||
if (-1 == cchMultiByte)
|
||||
{
|
||||
InStringLength = lstrlen(lpMultiByteStr) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
InStringLength = cchMultiByte;
|
||||
}
|
||||
/*
|
||||
* Does caller query for output
|
||||
* buffer size?
|
||||
*/
|
||||
if (0 == cchWideChar)
|
||||
{
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
return InStringLength;
|
||||
}
|
||||
/*
|
||||
* Is space provided for the translated
|
||||
* string enough?
|
||||
*/
|
||||
if (cchWideChar < InStringLength)
|
||||
{
|
||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Raw 8- to 16-bit conversion.
|
||||
*/
|
||||
for (cchConverted = 0,
|
||||
r = (PCHAR)lpMultiByteStr,
|
||||
w = (PWCHAR)lpWideCharStr;
|
||||
|
||||
cchConverted < InStringLength;
|
||||
|
||||
r++,
|
||||
w++,
|
||||
cchConverted++)
|
||||
{
|
||||
*w = (WCHAR)*r;
|
||||
}
|
||||
/*
|
||||
* Return how many characters we
|
||||
* wrote in the output buffer.
|
||||
*/
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
return cchConverted;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* NAME EXPORTED
|
||||
* WideCharToMultiByte@32
|
||||
*
|
||||
* Not yet implemented complete (without NLS so far)
|
||||
*
|
||||
* ARGUMENTS
|
||||
* CodePage
|
||||
* CP_ACP ANSI code page
|
||||
* CP_MACCP Macintosh code page
|
||||
* CP_OEMCP OEM code page
|
||||
* CP_SYMBOL Symbol code page (42)
|
||||
* CP_THREAD_ACP Current thread's ANSI code page
|
||||
* CP_UTF7 Translate using UTF-7
|
||||
* CP_UTF8 Translate using UTF-8
|
||||
* (UINT) Any installed code page
|
||||
*
|
||||
* dwFlags
|
||||
* WC_NO_BEST_FIT_CHARS
|
||||
* WC_COMPOSITECHECK Convert composite characters to precomposed characters.
|
||||
* WC_DISCARDNS Discard nonspacing characters during conversion.
|
||||
* WC_SEPCHARS Generate separate characters during conversion. This is the default conversion behavior.
|
||||
* WC_DEFAULTCHAR Replace exceptions with the default character during conversion.
|
||||
*
|
||||
* lpWideCharStr
|
||||
* Points to the wide-character string to be converted.
|
||||
*
|
||||
* cchWideChar
|
||||
* Size (in WCHAR unit) of WideCharStr, or 0
|
||||
* if the caller just wants to know how large
|
||||
* WideCharStr should be for a successful
|
||||
* conversion.
|
||||
* lpMultiByteStr
|
||||
* Points to the buffer to receive the translated string.
|
||||
* cchMultiByte
|
||||
* Specifies the size in bytes of the buffer pointed to by the
|
||||
* lpMultiByteStr parameter. If this value is zero, the function
|
||||
* returns the number of bytes required for the buffer.
|
||||
* lpDefaultChar
|
||||
* Points to the character used if a wide character cannot be
|
||||
* represented in the specified code page. If this parameter is
|
||||
* NULL, a system default value is used.
|
||||
FIXME: ignored
|
||||
* lpUsedDefaultChar
|
||||
* Points to a flag that indicates whether a default character was used.
|
||||
* This parameter may be NULL.
|
||||
FIXME: allways set to FALSE.
|
||||
*
|
||||
*
|
||||
*
|
||||
* RETURN VALUE
|
||||
* 0 on error; otherwise the number of bytes written
|
||||
* in the lpMultiByteStr buffer. Or the number of
|
||||
* bytes needed for the lpMultiByteStr buffer if cchMultiByte is zero.
|
||||
*
|
||||
* NOTE
|
||||
* A raw converter for now. It just cuts off the upper 9 Bit.
|
||||
* So the MBCS-string does not contain any LeadCharacters
|
||||
* FIXME - FIXME - FIXME - FIXME
|
||||
*/
|
||||
|
||||
int
|
||||
STDCALL
|
||||
WideCharToMultiByte(
|
||||
UINT CodePage,
|
||||
DWORD dwFlags,
|
||||
LPCWSTR lpWideCharStr,
|
||||
int cchWideChar,
|
||||
LPSTR lpMultiByteStr,
|
||||
int cchMultiByte,
|
||||
LPCSTR lpDefaultChar,
|
||||
LPBOOL lpUsedDefaultChar
|
||||
)
|
||||
{
|
||||
int wi, di; // wide counter, dbcs byte count
|
||||
|
||||
/*
|
||||
* Check the parameters.
|
||||
*/
|
||||
if ( /* --- CODE PAGE --- */
|
||||
( (CP_ACP != CodePage)
|
||||
&& (CP_MACCP != CodePage)
|
||||
&& (CP_OEMCP != CodePage)
|
||||
&& (CP_SYMBOL != CodePage)
|
||||
&& (CP_THREAD_ACP != CodePage)
|
||||
&& (CP_UTF7 != CodePage)
|
||||
&& (CP_UTF8 != CodePage)
|
||||
&& (FALSE == IsInstalledCP (CodePage))
|
||||
)
|
||||
/* --- FLAGS --- */
|
||||
|| (dwFlags & ~(/*WC_NO_BEST_FIT_CHARS
|
||||
|*/ WC_COMPOSITECHECK
|
||||
| WC_DISCARDNS
|
||||
| WC_SEPCHARS
|
||||
| WC_DEFAULTCHAR
|
||||
)
|
||||
)
|
||||
/* --- INPUT BUFFER --- */
|
||||
|| (NULL == lpWideCharStr)
|
||||
)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// for now, make no difference but only convert cut the characters to 7Bit
|
||||
if (cchWideChar == -1) // assume its a 0-terminated str
|
||||
{ // and determine its length
|
||||
for (cchWideChar=0; lpWideCharStr[cchWideChar]!=0; cchWideChar++)
|
||||
cchWideChar++;
|
||||
}
|
||||
|
||||
// user wants to determine needed space
|
||||
if (cchMultiByte == 0)
|
||||
{
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
return cchWideChar; // FIXME: determine correct.
|
||||
}
|
||||
// the lpWideCharStr is cchWideChar characters long.
|
||||
for (wi=0, di=0; wi<cchWideChar && di<cchMultiByte; ++wi, ++di)
|
||||
{
|
||||
// Flag and a not displayable char FIXME
|
||||
/*if( (dwFlags&WC_NO_BEST_FIT_CHARS) && (lpWideCharStr[wi] >127) )
|
||||
{
|
||||
lpMultiByteStr[di]=
|
||||
*lpUsedDefaultChar = TRUE;
|
||||
|
||||
}*/
|
||||
// FIXME
|
||||
// just cut off the upper 9 Bit, since vals>=128 mean LeadByte.
|
||||
lpMultiByteStr[di] = lpWideCharStr[wi] & 0x007F;
|
||||
}
|
||||
// has MultiByte exceeded but Wide is still in the string?
|
||||
if (wi < cchWideChar && di >= cchMultiByte)
|
||||
{
|
||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||
return 0;
|
||||
}
|
||||
// else return # of bytes wirtten to MBCSbuffer (di)
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
// FIXME: move that elsewhere
|
||||
if (lpUsedDefaultChar != NULL) *lpUsedDefaultChar = FALSE;
|
||||
return di;
|
||||
}
|
||||
|
||||
/* EOF */
|
61
reactos/lib/kernel32/misc/muldiv.c
Normal file
61
reactos/lib/kernel32/misc/muldiv.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* $Id: muldiv.c,v 1.1 2002/12/06 13:14:14 robd Exp $
|
||||
*
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* MulDiv (KERNEL32.@)
|
||||
* RETURNS
|
||||
* Result of multiplication and division
|
||||
* -1: Overflow occurred or Divisor was 0
|
||||
*/
|
||||
|
||||
//FIXME! move to correct file
|
||||
INT STDCALL MulDiv(
|
||||
INT nMultiplicand,
|
||||
INT nMultiplier,
|
||||
INT nDivisor)
|
||||
{
|
||||
#if SIZEOF_LONG_LONG >= 8
|
||||
long long ret;
|
||||
|
||||
if (!nDivisor) return -1;
|
||||
|
||||
/* We want to deal with a positive divisor to simplify the logic. */
|
||||
if (nDivisor < 0)
|
||||
{
|
||||
nMultiplicand = - nMultiplicand;
|
||||
nDivisor = -nDivisor;
|
||||
}
|
||||
|
||||
/* If the result is positive, we "add" to round. else, we subtract to round. */
|
||||
if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
|
||||
( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
|
||||
ret = (((long long)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
|
||||
else
|
||||
ret = (((long long)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
|
||||
|
||||
if ((ret > 2147483647) || (ret < -2147483647)) return -1;
|
||||
return ret;
|
||||
#else
|
||||
if (!nDivisor) return -1;
|
||||
|
||||
/* We want to deal with a positive divisor to simplify the logic. */
|
||||
if (nDivisor < 0)
|
||||
{
|
||||
nMultiplicand = - nMultiplicand;
|
||||
nDivisor = -nDivisor;
|
||||
}
|
||||
|
||||
/* If the result is positive, we "add" to round. else, we subtract to round. */
|
||||
if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
|
||||
( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
|
||||
return ((nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
|
||||
|
||||
return ((nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue