Changeset 157 for trunk/src/kernel32/message.cpp
- Timestamp:
- Jun 22, 1999, 7:25:28 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/message.cpp
r100 r157 1 /* $Id: message.cpp,v 1. 4 1999-06-10 20:48:00phaller Exp $ */1 /* $Id: message.cpp,v 1.5 1999-06-22 17:25:28 phaller Exp $ */ 2 2 3 3 /* … … 125 125 DWORD nolinefeed = 0; 126 126 127 dprintf(("FormatMessageA\n")); 127 dprintf(("KERNEL32: FormatMessageA (%08xh,%s,%08xh,%08xh,%08xh,%08xh,%08xh)\n", 128 dwFlags, 129 lpSource, 130 dwMessageId, 131 dwLanguageId, 132 lpBuffer, 133 nSize, 134 args)); 128 135 129 136 from = NULL; 130 if (dwFlags & FORMAT_MESSAGE_FROM_STRING) { 131 from = (char *)HeapAlloc(GetProcessHeap(),0, strlen((char *)lpSource)+1); 132 UnicodeToAscii((LPWSTR)lpSource, from); 133 } 134 if (dwFlags & FORMAT_MESSAGE_FROM_SYSTEM) { 135 from = (char *)HeapAlloc(GetProcessHeap(),0,200 ); 136 sprintf(from,"Systemmessage, messageid = 0x%08lx\n",dwMessageId); 137 } 138 if (dwFlags & FORMAT_MESSAGE_FROM_HMODULE) { 139 int bufsize; 140 141 dwMessageId &= 0xFFFF; 142 bufsize=LoadMessageA(0,dwMessageId,dwLanguageId,NULL,100); 143 if (bufsize) { 144 from = (char *)HeapAlloc(GetProcessHeap(), 0, bufsize + 1 ); 145 LoadMessageA(0,dwMessageId,dwLanguageId,from,bufsize+1); 146 } 147 } 148 target = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 100); 149 t = target; 150 talloced= 100; 137 138 if (dwFlags & FORMAT_MESSAGE_FROM_STRING) 139 { 140 from = (char *)HeapAlloc(GetProcessHeap(), 141 0, 142 strlen((char*)lpSource) + 1); 143 strcpy (from, 144 (char*)lpSource); 145 } 146 else 147 if (dwFlags & FORMAT_MESSAGE_FROM_SYSTEM) 148 { 149 from = (char *)HeapAlloc(GetProcessHeap(), 0, 200 ); 150 sprintf(from,"Systemmessage, messageid = 0x%08lx\n",dwMessageId); 151 } 152 else 153 if (dwFlags & FORMAT_MESSAGE_FROM_HMODULE) 154 { 155 int bufsize; 156 157 dwMessageId &= 0xFFFF; 158 bufsize=LoadMessageA(0,dwMessageId,dwLanguageId,NULL,100); 159 if (bufsize) 160 { 161 from = (char *)HeapAlloc(GetProcessHeap(), 0, bufsize + 1 ); 162 LoadMessageA(0,dwMessageId,dwLanguageId,from,bufsize+1); 163 } 164 } 165 166 target = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 100); 167 t = target; 168 talloced= 100; 151 169 152 170 #define ADD_TO_T(c) \ … … 250 268 *t='\0'; 251 269 } 252 if (!nolinefeed && t[-1]!='\n') 253 ADD_TO_T('\n'); 254 talloced = strlen(target)+1; 255 if (nSize && talloced<nSize) { 256 target = (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,nSize); 257 } 258 if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) { 259 /* nSize is the MINIMUM size */ 260 *((LPVOID*)lpBuffer) = (LPVOID)LocalAlloc(GMEM_ZEROINIT,talloced); 261 memcpy(*(LPSTR*)lpBuffer,target,talloced); 262 } else 263 strncpy(lpBuffer,target,nSize); 264 HeapFree(GetProcessHeap(),0,target); 265 if (from) HeapFree(GetProcessHeap(),0,from); 266 dprintf(("FormatMessageA returned %s\n", 267 (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) ? 268 *(LPSTR*)lpBuffer: 269 lpBuffer)); 270 return (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) ? 271 strlen(*(LPSTR*)lpBuffer): 272 strlen(lpBuffer); 270 271 if (!nolinefeed && t[-1]!='\n') 272 ADD_TO_T('\n'); 273 274 talloced = strlen(target)+1; 275 if (nSize && talloced<nSize) 276 { 277 target = (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,nSize); 278 } 279 280 if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) 281 { 282 /* nSize is the MINIMUM size */ 283 *((LPVOID*)lpBuffer) = (LPVOID)LocalAlloc(GMEM_ZEROINIT,talloced); 284 memcpy(*(LPSTR*)lpBuffer,target,talloced); 285 } 286 else 287 strncpy(lpBuffer,target,nSize); 288 289 HeapFree(GetProcessHeap(),0,target); 290 291 if (from) HeapFree(GetProcessHeap(),0,from); 292 293 dprintf(("KERNEL32: FormatMessageA returned %s\n", 294 (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) ? 295 *(LPSTR*)lpBuffer: 296 lpBuffer)); 297 298 return (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) ? 299 strlen(*(LPSTR*)lpBuffer): 300 strlen(lpBuffer); 273 301 } 274 302 #undef ADD_TO_T … … 292 320 DWORD nolinefeed = 0; 293 321 294 dprintf((" FormatMessageW\n"));322 dprintf(("KERNEL32: FormatMessageW\n")); 295 323 296 324 from = NULL; … … 299 327 UnicodeToAscii((LPWSTR)lpSource, from); 300 328 } 329 else 301 330 if (dwFlags & FORMAT_MESSAGE_FROM_SYSTEM) { 302 331 /* gather information from system message tables ... */ … … 304 333 sprintf(from,"Systemmessage, messageid = 0x%08lx\n",dwMessageId); 305 334 } 335 else 306 336 if (dwFlags & FORMAT_MESSAGE_FROM_HMODULE) { 307 337 int bufsize; … … 315 345 } 316 346 } 347 317 348 target = (char *)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 100 ); 318 349 t = target; … … 432 463 else AsciiToUnicode(target, lpBuffer); 433 464 434 dprintf((" FormatMessageW returned %s\n", target));465 dprintf(("KERNEL32: FormatMessageW returned %s\n", target)); 435 466 436 467 HeapFree(GetProcessHeap(),0,target); … … 456 487 char *msgBuffer; 457 488 458 dprintf((" FormatMessageA Not Implemented\n"));489 dprintf(("KERNEL32: FormatMessageA Not Implemented\n")); 459 490 460 491 if(dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) { … … 479 510 WCHAR *msgBuffer; 480 511 481 dprintf((" FormatMessageW Not Implemented\n"));512 dprintf(("KERNEL32: FormatMessageW Not Implemented\n")); 482 513 483 514 if(dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) {
Note:
See TracChangeset
for help on using the changeset viewer.