1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
|
/*
* Log internal errors
*
* Copyright 1997 Andrew Taylor
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "windef.h"
#include "wine/winbase16.h"
#include "wine/debug.h"
/* LogParamError and LogError values */
/* Error modifier bits */
#define ERR_WARNING 0x8000
#define ERR_PARAM 0x4000
#define ERR_SIZE_MASK 0x3000
#define ERR_BYTE 0x1000
#define ERR_WORD 0x2000
#define ERR_DWORD 0x3000
/* LogParamError() values */
/* Generic parameter values */
#define ERR_BAD_VALUE 0x6001
#define ERR_BAD_FLAGS 0x6002
#define ERR_BAD_INDEX 0x6003
#define ERR_BAD_DVALUE 0x7004
#define ERR_BAD_DFLAGS 0x7005
#define ERR_BAD_DINDEX 0x7006
#define ERR_BAD_PTR 0x7007
#define ERR_BAD_FUNC_PTR 0x7008
#define ERR_BAD_SELECTOR 0x6009
#define ERR_BAD_STRING_PTR 0x700a
#define ERR_BAD_HANDLE 0x600b
/* KERNEL parameter errors */
#define ERR_BAD_HINSTANCE 0x6020
#define ERR_BAD_HMODULE 0x6021
#define ERR_BAD_GLOBAL_HANDLE 0x6022
#define ERR_BAD_LOCAL_HANDLE 0x6023
#define ERR_BAD_ATOM 0x6024
#define ERR_BAD_HFILE 0x6025
/* USER parameter errors */
#define ERR_BAD_HWND 0x6040
#define ERR_BAD_HMENU 0x6041
#define ERR_BAD_HCURSOR 0x6042
#define ERR_BAD_HICON 0x6043
#define ERR_BAD_HDWP 0x6044
#define ERR_BAD_CID 0x6045
#define ERR_BAD_HDRVR 0x6046
/* GDI parameter errors */
#define ERR_BAD_COORDS 0x7060
#define ERR_BAD_GDI_OBJECT 0x6061
#define ERR_BAD_HDC 0x6062
#define ERR_BAD_HPEN 0x6063
#define ERR_BAD_HFONT 0x6064
#define ERR_BAD_HBRUSH 0x6065
#define ERR_BAD_HBITMAP 0x6066
#define ERR_BAD_HRGN 0x6067
#define ERR_BAD_HPALETTE 0x6068
#define ERR_BAD_HMETAFILE 0x6069
/* LogError() values */
/* KERNEL errors */
#define ERR_GALLOC 0x0001
#define ERR_GREALLOC 0x0002
#define ERR_GLOCK 0x0003
#define ERR_LALLOC 0x0004
#define ERR_LREALLOC 0x0005
#define ERR_LLOCK 0x0006
#define ERR_ALLOCRES 0x0007
#define ERR_LOCKRES 0x0008
#define ERR_LOADMODULE 0x0009
/* USER errors */
#define ERR_CREATEDLG 0x0040
#define ERR_CREATEDLG2 0x0041
#define ERR_REGISTERCLASS 0x0042
#define ERR_DCBUSY 0x0043
#define ERR_CREATEWND 0x0044
#define ERR_STRUCEXTRA 0x0045
#define ERR_LOADSTR 0x0046
#define ERR_LOADMENU 0x0047
#define ERR_NESTEDBEGINPAINT 0x0048
#define ERR_BADINDEX 0x0049
#define ERR_CREATEMENU 0x004a
/* GDI errors */
#define ERR_CREATEDC 0x0080
#define ERR_CREATEMETA 0x0081
#define ERR_DELOBJSELECTED 0x0082
#define ERR_SELBITMAP 0x0083
#define ErrorString(manifest) { manifest, # manifest }
static const struct {
int constant;
const char *name;
} ErrorStrings[] = {
ErrorString(ERR_GALLOC),
ErrorString(ERR_GREALLOC),
ErrorString(ERR_GLOCK),
ErrorString(ERR_LALLOC),
ErrorString(ERR_LREALLOC),
ErrorString(ERR_LLOCK),
ErrorString(ERR_ALLOCRES),
ErrorString(ERR_LOCKRES),
ErrorString(ERR_LOADMODULE),
ErrorString(ERR_CREATEDLG),
ErrorString(ERR_CREATEDLG2),
ErrorString(ERR_REGISTERCLASS),
ErrorString(ERR_DCBUSY),
ErrorString(ERR_CREATEWND),
ErrorString(ERR_STRUCEXTRA),
ErrorString(ERR_LOADSTR),
ErrorString(ERR_LOADMENU),
ErrorString(ERR_NESTEDBEGINPAINT),
ErrorString(ERR_BADINDEX),
ErrorString(ERR_CREATEMENU),
ErrorString(ERR_CREATEDC),
ErrorString(ERR_CREATEMETA),
ErrorString(ERR_DELOBJSELECTED),
ErrorString(ERR_SELBITMAP)
};
static const struct {
int constant;
const char *name;
} ParamErrorStrings[] = {
ErrorString(ERR_BAD_VALUE),
ErrorString(ERR_BAD_FLAGS),
ErrorString(ERR_BAD_INDEX),
ErrorString(ERR_BAD_DVALUE),
ErrorString(ERR_BAD_DFLAGS),
ErrorString(ERR_BAD_DINDEX),
ErrorString(ERR_BAD_PTR),
ErrorString(ERR_BAD_FUNC_PTR),
ErrorString(ERR_BAD_SELECTOR),
ErrorString(ERR_BAD_STRING_PTR),
ErrorString(ERR_BAD_HANDLE),
ErrorString(ERR_BAD_HINSTANCE),
ErrorString(ERR_BAD_HMODULE),
ErrorString(ERR_BAD_GLOBAL_HANDLE),
ErrorString(ERR_BAD_LOCAL_HANDLE),
ErrorString(ERR_BAD_ATOM),
ErrorString(ERR_BAD_HFILE),
ErrorString(ERR_BAD_HWND),
ErrorString(ERR_BAD_HMENU),
ErrorString(ERR_BAD_HCURSOR),
ErrorString(ERR_BAD_HICON),
ErrorString(ERR_BAD_HDWP),
ErrorString(ERR_BAD_CID),
ErrorString(ERR_BAD_HDRVR),
ErrorString(ERR_BAD_COORDS),
ErrorString(ERR_BAD_GDI_OBJECT),
ErrorString(ERR_BAD_HDC),
ErrorString(ERR_BAD_HPEN),
ErrorString(ERR_BAD_HFONT),
ErrorString(ERR_BAD_HBRUSH),
ErrorString(ERR_BAD_HBITMAP),
ErrorString(ERR_BAD_HRGN),
ErrorString(ERR_BAD_HPALETTE),
ErrorString(ERR_BAD_HMETAFILE)
};
#undef ErrorString
#define ErrorStringCount (sizeof(ErrorStrings) / sizeof(ErrorStrings[0]))
#define ParamErrorStringCount (sizeof(ParamErrorStrings) / sizeof(ParamErrorStrings[0]))
/***********************************************************************
* GetErrorString (internal)
*/
static const char *GetErrorString(UINT16 uErr)
{
static char buffer[80];
unsigned int n;
for (n = 0; n < ErrorStringCount; n++) {
if (uErr == ErrorStrings[n].constant)
return ErrorStrings[n].name;
}
sprintf(buffer, "%x", uErr);
return buffer;
}
/***********************************************************************
* GetParamErrorString (internal)
*/
static const char *GetParamErrorString(UINT16 uErr) {
static char buffer[80];
if (uErr & ERR_WARNING) {
strcpy(buffer, "ERR_WARNING | ");
uErr &= ~ERR_WARNING;
} else
buffer[0] = '\0';
{
unsigned int n;
for (n = 0; n < ParamErrorStringCount; n++) {
if (uErr == ParamErrorStrings[n].constant) {
strcat(buffer, ParamErrorStrings[n].name);
return buffer;
}
}
}
sprintf(buffer + strlen(buffer), "%x", uErr);
return buffer;
}
/***********************************************************************
* LogError (KERNEL.324)
*/
VOID WINAPI LogError16(UINT16 uErr, LPVOID lpvInfo)
{
MESSAGE("(%s, %p)\n", GetErrorString(uErr), lpvInfo);
}
/***********************************************************************
* LogParamError (KERNEL.325)
*/
void WINAPI LogParamError16(UINT16 uErr, FARPROC16 lpfn, LPVOID lpvParam)
{
/* FIXME: is it possible to get the module name/function
* from the lpfn param?
*/
MESSAGE("(%s, %p, %p)\n", GetParamErrorString(uErr), lpfn, lpvParam);
}
/***********************************************************************
* K327 (KERNEL.327)
*/
void WINAPI HandleParamError( CONTEXT86 *context )
{
UINT16 uErr = LOWORD(context->Ebx);
FARPROC16 lpfn = (FARPROC16)MAKESEGPTR( context->SegCs, context->Eip );
LPVOID lpvParam = (LPVOID)MAKELONG( LOWORD(context->Eax), LOWORD(context->Ecx) );
LogParamError16( uErr, lpfn, lpvParam );
if (!(uErr & ERR_WARNING))
{
/* Abort current procedure: Unwind stack frame and jump
to error handler (location at [bp-2]) */
WORD *stack = MapSL( MAKESEGPTR( context->SegSs, LOWORD(context->Ebp) ));
context->Esp = LOWORD(context->Ebp) - 2;
context->Ebp = stack[0] & 0xfffe;
context->Eip = stack[-1];
context->Eax = context->Ecx = context->Edx = 0;
context->SegEs = 0;
}
}
|