Changeset 21916 for trunk/src/kernel32/_ras.cpp
- Timestamp:
- Dec 18, 2011, 10:28:22 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 bin 2 Makefile.inc 1 env.cmd 2 LocalConfig.kmk
-
-
Property svn:mergeinfo
set to
/branches/gcc-kmk merged eligible
- Property svn:ignore
-
trunk/src/kernel32/_ras.cpp
r21342 r21916 7 7 #include <_ras.h> 8 8 #include <umalloc.h> 9 #include <process.h> 9 10 10 11 #include <custombuild.h> 11 12 #include <odincrt.h> 13 #ifdef __GNUC__ 14 #include <float.h> 15 #else 12 16 #include <libc/float.h> 17 #endif 13 18 14 19 #include "initterm.h" … … 18 23 19 24 /* RAS functions to isolate all RAS related services: 20 * 25 * 21 26 * - Common statistic functions to track objects allocations/deallocations. 22 27 * … … 29 34 * Note: RAS subsystem does not use any other Odin subsystem, and IMO must not. 30 35 * That is RAS has its own heap, serialization, logging. 31 * External stuff that is used: 36 * External stuff that is used: 32 37 * - from Odin: asm helpers from interlock.asm 33 38 * - from libc: uheap functions 34 * 39 * 35 40 * The following has been borrowed from other Odin parts and adapted: 36 41 * - critical section … … 48 53 typedef struct _RAS_TRACK RAS_TRACK; 49 54 50 typedef struct _RAS_OBJECT_INFO 55 typedef struct _RAS_OBJECT_INFO 51 56 { 52 57 struct _RAS_OBJECT_INFO *next; 53 58 struct _RAS_OBJECT_INFO *prev; 54 59 55 60 RAS_TRACK_HANDLE h; 56 61 57 62 ULONG objident; 58 63 ULONG usecount; 59 64 60 65 ULONG objhandle; 61 66 62 67 void *objdata; 63 68 ULONG cbobjdata; 64 69 65 70 char userdata[1]; 66 71 } RAS_OBJECT_INFO; … … 73 78 RAS_OBJECT_INFO *objfirst; 74 79 RAS_OBJECT_INFO *objlast; 75 80 76 81 char objname[80]; 77 82 78 83 ULONG cbuserdata; 79 84 80 85 ULONG fLogObjectContent: 1; 81 86 ULONG fMemory: 1; 82 87 ULONG fLogAtExit: 1; 83 88 ULONG fLogObjectsAtExit: 1; 84 89 85 90 FNLOC *pfnLogObjectContent; 86 91 FNCOC *pfnCompareObjectContent; 87 92 88 93 /* Used when fMemory = 1 for RasTrackAlloc, Realloc and Free calls */ 89 94 ULONG cAllocs; 90 95 ULONG cFrees; 91 96 ULONG cbTotalAllocated; 92 97 93 98 }; 94 99 … … 119 124 120 125 ULONG hlogfile; // filehandle if default logging functions are used 121 126 122 127 HMODULE hmod; 123 128 } RasLogChannel; … … 126 131 { 127 132 HMODULE hmod; // handle of this dll 128 133 129 134 RasLogChannel rlc; 130 135 131 136 Heap_t rasheap; 132 137 void *pHeapMem; 133 138 ULONG ulRefCount; 134 139 ULONG flAllocMem; 135 140 136 141 HMODULE hmodPlugin; 137 142 138 143 RasEntryTable ret; 139 144 RasPluginEntryTable pet; … … 163 168 } RASCONTEXT_I; 164 169 170 extern "C" { 171 165 172 void rasSaveContext(RASCONTEXT_I *pcontext) 166 173 { … … 181 188 182 189 DosGetInfoBlocks(&ptib, &ppib); 183 190 184 191 return ppib->pib_ulpid << 16 | ptib->tib_ptib2->tib2_ultid; 185 192 } … … 188 195 { 189 196 int rc = NO_ERROR; 190 197 191 198 rc = DosCreateEventSem (NULL, &crit->hevLock, DC_SEM_SHARED, 0); 192 199 193 200 if (rc != NO_ERROR) 194 201 { 195 202 crit->hevLock = 0; 196 203 } 197 204 198 205 return rc; 199 206 } … … 207 214 { 208 215 APIRET rc = NO_ERROR; 209 216 210 217 ULONG threadid = rasGetCurrentThreadId (); 211 218 212 219 // We want to acquire the section, count the entering 213 220 DosInterlockedIncrement (&crit->LockCount); 214 221 215 222 if (crit->OwningThread == threadid) 216 223 { … … 228 235 break; 229 236 } 230 237 231 238 rc = DosWaitEventSem (crit->hevLock, ulTimeout); 232 233 if (rc != NO_ERROR) 239 240 if (rc != NO_ERROR) 234 241 { 235 242 // We fail, deregister itself … … 238 245 } 239 246 } 240 247 241 248 // the section was successfully aquired 242 249 crit->RecursionCount = 1; 243 250 244 251 return NO_ERROR; 245 252 } … … 256 263 { 257 264 DosInterlockedDecrement (&crit->LockCount); 258 265 259 266 return NO_ERROR; 260 267 } 261 268 262 269 crit->OwningThread = 0; 263 270 … … 270 277 DosResetEventSem (crit->hevLock, &ulnrposts); 271 278 } 272 279 273 280 return NO_ERROR; 274 281 } … … 287 294 void ulong2string (unsigned long number, char *string, int n, int base) 288 295 { 289 static c har *digits = "0123456789ABCDEF";290 296 static const char *digits = "0123456789ABCDEF"; 297 291 298 unsigned long tmp = number; 292 299 char *s = string; … … 294 301 int l = 0; 295 302 int i; 296 303 297 304 if (n <= 0) 298 305 { 299 306 return; 300 307 } 301 308 302 309 if (tmp == 0) 303 310 { 304 311 s[l++] = digits[0]; 305 312 } 306 313 307 314 while (tmp != 0) 308 315 { … … 319 326 s[l++] = '\0'; 320 327 } 321 328 322 329 s = string; 323 330 324 331 for (i = 0; i < len/2; i++) 325 332 { … … 338 345 return; 339 346 } 340 347 341 348 if (number < 0) 342 349 { … … 345 352 n--; 346 353 } 347 354 348 355 ulong2string (number, string, n, base); 349 356 } 350 357 351 358 int string2ulong (const char *string, char **pstring2, unsigned long *pvalue, int base) 352 359 { 353 360 unsigned long value = 0; 354 361 int sign = 1; 355 362 356 363 const char *p = string; 357 364 358 365 if (p[0] == '-') 359 366 { … … 361 368 p++; 362 369 } 363 370 364 371 if (base == 0) 365 372 { … … 379 386 } 380 387 } 381 388 382 389 while (*p) 383 390 { 384 391 int digit = 0; 385 392 386 393 if ('0' <= *p && *p <= '9') 387 394 { … … 400 407 break; 401 408 } 402 409 403 410 if (digit >= base) 404 411 { 405 412 break; 406 413 } 407 414 408 415 value = value*base + digit; 409 416 410 417 p++; 411 418 } 412 419 413 420 if (pstring2) 414 421 { 415 422 *pstring2 = (char *)p; 416 423 } 417 424 418 425 *pvalue = sign*value; 419 426 420 427 return 1; 421 428 } 429 430 #ifndef __GNUC__ 422 431 423 432 int vsnprintf (char *buf, int n, const char *fmt, va_list args) … … 426 435 char *s = (char *)fmt; 427 436 char *d = buf; 428 437 429 438 if (n <= 0) 430 439 { 431 440 return 0; 432 441 } 433 442 434 443 n--; 435 444 436 445 while (*s && count < n) 437 446 { 438 447 char tmpstr[16]; 439 448 440 449 char *str = NULL; 441 450 442 451 int width = 0; 443 452 int precision = 0; 444 453 445 454 if (*s == '%') 446 455 { 447 456 s++; 448 457 449 458 if ('0' <= *s && *s <= '9' || *s == '-') 450 459 { … … 462 471 string2ulong (s, &s, (unsigned long *)&precision, 10); 463 472 } 464 473 465 474 if (*s == 's') 466 475 { … … 480 489 { 481 490 int num = va_arg(args, int); 482 491 483 492 ulong2string (num, tmpstr, sizeof (tmpstr), 16); 484 493 485 494 str = &tmpstr[0]; 486 495 s++; … … 494 503 s++; 495 504 } 496 505 497 506 if (*s == 'd' || *s == 'i') 498 507 { 499 508 int num = va_arg(args, int); 500 509 501 510 long2string (num, tmpstr, sizeof (tmpstr), 10); 502 511 503 512 str = &tmpstr[0]; 504 513 s++; … … 507 516 { 508 517 int num = va_arg(args, int); 509 518 510 519 ulong2string (num, tmpstr, sizeof (tmpstr), 10); 511 520 512 521 str = &tmpstr[0]; 513 522 s++; … … 516 525 { 517 526 int num = va_arg(args, int); 518 527 519 528 ulong2string (num, tmpstr, sizeof (tmpstr), 16); 520 529 521 530 str = &tmpstr[0]; 522 531 s++; … … 524 533 } 525 534 } 526 535 527 536 if (str != NULL) 528 537 { … … 531 540 int len = strlen (str); 532 541 int leftalign = 0; 533 542 534 543 if (width < 0) 535 544 { … … 537 546 leftalign = 1; 538 547 } 539 548 540 549 if (precision) 541 550 { … … 546 555 precision--; 547 556 } 548 557 549 558 memcpy (&numstr[i], str, len); 550 559 551 560 str = &numstr[0]; 552 561 len += i; 553 562 } 554 563 555 564 if (len < width && !leftalign) 556 565 { … … 561 570 count++; 562 571 } 563 572 564 573 if (count >= n) 565 574 { … … 567 576 } 568 577 } 569 578 570 579 i = 0; 571 580 while (i < len && count < n) … … 574 583 count++; 575 584 } 576 585 577 586 if (count >= n) 578 587 { 579 588 break; 580 589 } 581 590 582 591 if (len < width && leftalign) 583 592 { … … 588 597 count++; 589 598 } 590 599 591 600 if (count >= n) 592 601 { … … 601 610 } 602 611 } 603 612 604 613 *d = '\0'; 605 614 606 615 return count + 1; 607 616 } 608 617 618 #endif // ifndef __GNUC__ 619 620 #ifdef __GNUC__ 621 int WIN32API_VA ras_snprintf (char *buf, int n, const char *fmt, ...) 622 #else 609 623 int WIN32API snprintf (char *buf, int n, const char *fmt, ...) 624 #endif 610 625 { 611 626 va_list args; 612 627 613 628 int rc = 0; 614 629 615 630 va_start (args, fmt); 616 631 617 632 rc = vsnprintf (buf, n, fmt, args); 618 633 619 634 va_end (args); 620 635 621 636 return rc; 622 637 } … … 625 640 { 626 641 ULONG ulAction = 0; 627 642 628 643 int rc = DosOpen (logfilename, ph, &ulAction, 0L, FILE_ARCHIVED, 629 644 OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS, 630 645 OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | 631 646 OPEN_ACCESS_READWRITE, 0L); 632 647 633 648 if (rc == ERROR_TOO_MANY_OPEN_FILES) 634 649 { 635 650 LONG lReqCount = 10l; 636 651 ULONG ulCurMaxFH = 0ul; 637 652 638 653 DosSetRelMaxFH (&lReqCount, &ulCurMaxFH); 639 654 640 655 rc = DosOpen (logfilename, ph, &ulAction, 0L, FILE_ARCHIVED, 641 656 OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS, … … 643 658 OPEN_ACCESS_READWRITE, 0L); 644 659 } 645 660 646 661 if (rc != NO_ERROR) 647 662 { 648 663 *ph = -1; 649 664 } 650 665 651 666 return rc; 652 667 } … … 660 675 { 661 676 ULONG ulActual = 0; 662 677 663 678 DosWrite ((HFILE)h, msg, len, &ulActual); 664 679 } … … 671 686 prlc->hlogfile = -1; 672 687 } 673 688 674 689 if (prlc->hmod) 675 690 { … … 677 692 prlc->hmod = NULLHANDLE; 678 693 } 679 694 680 695 prlc->pfnWriteLog = NULL; 681 696 prlc->pfnOpenLogFile = NULL; … … 687 702 { 688 703 int rc = NO_ERROR; 689 704 690 705 const char *env = NULL; 691 706 692 707 DosScanEnv (env_loghandler, &env); 693 708 694 709 HMODULE hmod = NULLHANDLE; 695 710 696 711 PFN popenlogfile = NULL; 697 712 PFN pcloselogfile = NULL; 698 713 PFN pwritelog = NULL; 699 714 700 715 if (env) 701 716 { 702 717 rc = DosLoadModule (NULL, 0, env, &hmod); 703 718 704 719 if (rc == NO_ERROR) 705 720 { 706 721 rc = DosQueryProcAddr (hmod, 0, "WIN32RAS_OPENLOGFILE", &popenlogfile); 707 722 } 708 723 709 724 if (rc == NO_ERROR) 710 725 { 711 726 rc = DosQueryProcAddr (hmod, 0, "WIN32RAS_CLOSELOGFILE", &pcloselogfile); 712 727 } 713 728 714 729 if (rc == NO_ERROR) 715 730 { 716 731 rc = DosQueryProcAddr (hmod, 0, "WIN32RAS_WRITELOG", &pwritelog); 717 732 } 718 733 719 734 if (rc != NO_ERROR && hmod) 720 735 { … … 723 738 } 724 739 } 725 740 726 741 if (rc == NO_ERROR && hmod && popenlogfile && pcloselogfile && pwritelog) 727 742 { … … 739 754 prlc->hlogfile = -1; 740 755 prlc->hmod = NULLHANDLE; 741 756 742 757 rc = NO_ERROR; 743 758 } 744 759 745 760 rc = prlc->pfnOpenLogFile (&prlc->hlogfile, filename); 746 761 747 762 if (rc != NO_ERROR) 748 763 { … … 750 765 rasCloseLogChannel (prlc); 751 766 } 752 767 753 768 return rc; 754 769 } … … 757 772 { 758 773 int rc = NO_ERROR; 759 774 760 775 const char *filename = "win32ras.log"; 761 776 762 777 const char *env = NULL; 763 778 764 779 DosScanEnv ("WIN32RAS_LOG_FILENAME", &env); 765 780 766 781 if (env) 767 782 { 768 783 filename = env; 769 784 } 770 785 771 786 char uniqueLogFileName[260]; 772 787 773 788 snprintf (uniqueLogFileName, sizeof(uniqueLogFileName), 774 "%s.%d", filename, loadNr);775 789 "%s.%d", filename, getpid()); 790 776 791 if (rasdata.rlc.hlogfile == -1) 777 792 { 778 793 rc = rasOpenLogChannel ("WIN32RAS_LOGHANDLER", &rasdata.rlc, uniqueLogFileName); 779 794 } 780 795 781 796 return rc; 782 797 } … … 787 802 } 788 803 789 void rasLogInternalV (RAS_LOG_CHANNEL_H hchannel, c har *fmt, va_list args)804 void rasLogInternalV (RAS_LOG_CHANNEL_H hchannel, const char *fmt, va_list args) 790 805 { 791 806 static char szOutMsg[4096]; 792 807 793 808 ULONG ulHdrLen = snprintf (szOutMsg, sizeof (szOutMsg), "%s", ""); 794 809 795 810 ulHdrLen -= 1; 796 811 797 812 ULONG ulMsgLen = vsnprintf (&szOutMsg[ulHdrLen], sizeof (szOutMsg) - ulHdrLen, fmt, args); 798 813 799 814 ulMsgLen -= 1; 800 815 801 816 if (ulMsgLen > 0) 802 817 { … … 810 825 } 811 826 } 812 827 813 828 RasLogChannel *prlc = hchannel? (RasLogChannel *)hchannel: &rasdata.rlc; 814 829 815 830 prlc->pfnWriteLog (prlc->hlogfile, szOutMsg, ulMsgLen + ulHdrLen); 816 831 } 817 832 } 818 833 819 void rasLog (c har *fmt, ...)834 void rasLog (const char *fmt, ...) 820 835 { 821 836 va_list args; 822 837 823 838 va_start (args, fmt); 824 839 825 840 rasLogInternalV (NULL, fmt, args); 826 841 827 842 va_end (args); 828 843 } 829 844 830 void rasLogInternal (c har *fmt, ...)845 void rasLogInternal (const char *fmt, ...) 831 846 { 832 847 va_list args; 833 848 834 849 va_start (args, fmt); 835 850 836 851 rasLogInternalV (NULL, fmt, args); 837 852 838 853 va_end (args); 839 854 } 840 855 841 void WIN32API rasLogExternal (char *fmt, ...)856 void WIN32API_VA rasLogExternal (const char *fmt, ...) 842 857 { 843 858 va_list args; … … 846 861 847 862 va_start (args, fmt); 848 863 849 864 rasLogInternalV (NULL, fmt, args); 850 865 851 866 va_end (args); 852 867 853 868 SetFS (sel); 854 869 } … … 876 891 877 892 *clean = _BLOCK_CLEAN; 878 893 879 894 rc = DosAllocSharedMem (&p, NULL, *size, rasdata.flAllocMem | OBJ_GETTABLE); 880 895 881 896 if (rc != NO_ERROR) 882 897 { 883 898 rasLog ("RAS heap: getmore_fn: DosAllocSharedMem failed, rc = %d\n", rc); 884 899 } 885 900 886 901 return p; 887 902 } … … 906 921 { 907 922 rasdata.flAllocMem = PAG_READ | PAG_WRITE | PAG_COMMIT; 908 923 909 924 if (rascfg.fUseHighMem) 910 925 { 911 926 ULONG ulSysinfo = 0; 912 927 913 928 rc = DosQuerySysInfo (QSV_VIRTUALADDRESSLIMIT, QSV_VIRTUALADDRESSLIMIT, &ulSysinfo, sizeof (ulSysinfo)); 914 929 915 930 if (rc == NO_ERROR && ulSysinfo > 512) // VirtualAddresslimit is in MB 916 931 { 917 932 rasdata.flAllocMem |= PAG_ANY; 918 933 919 934 rasLog ("RAS heap initialization: will use high memory\n"); 920 935 } 921 936 } 922 937 923 rc = DosAllocSharedMem (&rasdata.pHeapMem, NULL, rascfg.ulInitHeapSize, 938 rc = DosAllocSharedMem (&rasdata.pHeapMem, NULL, rascfg.ulInitHeapSize, 924 939 rasdata.flAllocMem | OBJ_GETTABLE); 925 940 if (rc != NO_ERROR) … … 928 943 return NO_ERROR; 929 944 } 930 931 rasdata.rasheap = _ucreate (rasdata.pHeapMem, rascfg.ulInitHeapSize, 945 946 rasdata.rasheap = _ucreate (rasdata.pHeapMem, rascfg.ulInitHeapSize, 932 947 _BLOCK_CLEAN, _HEAP_REGULAR | _HEAP_SHARED, 933 948 getmore_fn, release_fn); … … 936 951 { 937 952 rasLog ("RAS heap initialization: _ucreate failed\n"); 938 953 939 954 DosFreeMem (rasdata.pHeapMem); 940 955 rasdata.pHeapMem = NULL; 941 956 942 957 return ERROR_NOT_ENOUGH_MEMORY; 943 958 } … … 949 964 */ 950 965 rc = DosGetSharedMem (rasdata.pHeapMem, rasdata.flAllocMem); 951 966 952 967 if (rc != NO_ERROR) 953 968 { 954 969 rasLog ("RAS heap initialization: DosGetSharedMem failed %d\n", rc); 955 970 956 971 return rc; 957 972 } … … 960 975 { 961 976 rasLog ("RAS heap initialization: _uopen failed\n"); 962 977 963 978 DosFreeMem (rasdata.pHeapMem); 964 979 965 980 return ERROR_NOT_ENOUGH_MEMORY; 966 981 } 967 982 } 968 983 969 984 rasdata.ulRefCount++; 970 985 971 986 return NO_ERROR; 972 987 } … … 980 995 return 1; 981 996 } 982 983 if (useflag == _USEDENTRY) 997 998 if (useflag == _USEDENTRY) 984 999 { 985 1000 if (filename) … … 1001 1016 { 1002 1017 rasLog ("RAS heap uninitialization: privateRefCount = %d\n", privateRefCount); 1003 1018 1004 1019 return; 1005 1020 } … … 1017 1032 1018 1033 _uclose (rasdata.rasheap); 1019 1034 1020 1035 _udestroy (rasdata.rasheap, _FORCE); 1021 1036 rasdata.rasheap = NULL; 1022 1037 } 1023 1038 1024 1039 if (rasdata.pHeapMem) 1025 1040 { … … 1028 1043 } 1029 1044 } 1030 else 1045 else 1031 1046 { 1032 1047 _uclose (rasdata.rasheap); … … 1037 1052 { 1038 1053 void *p = _umalloc(rasdata.rasheap, size); 1039 1054 1040 1055 if (p) 1041 1056 { … … 1046 1061 rasLog ("RAS heap: allocation failed, %d bytes\n", size); 1047 1062 } 1048 1063 1049 1064 return p; 1050 1065 } … … 1060 1075 { 1061 1076 RAS_TRACK_HANDLE iter = rasdata.firsttrack; 1062 1077 1063 1078 while (iter) 1064 1079 { … … 1067 1082 break; 1068 1083 } 1069 1084 1070 1085 iter = iter->next; 1071 1086 } 1072 1087 1073 1088 return iter; 1074 1089 } … … 1076 1091 ULONG rasGenObjIdent (void) 1077 1092 { 1078 static objident = 0;1079 1093 static ULONG objident = 0; 1094 1080 1095 objident++; 1081 1096 1082 1097 if (objident == 0) 1083 1098 { 1084 1099 objident++; 1085 1100 } 1086 1101 1087 1102 return objident; 1088 1103 } … … 1100 1115 h->objlast = h->objfirst = pinfo; 1101 1116 } 1102 1117 1103 1118 return NO_ERROR; 1104 1119 } 1105 1120 1106 1121 void rasRemoveObjectInfo (RAS_OBJECT_INFO *pinfo) 1107 1122 { … … 1115 1130 pinfo->h->objlast = pinfo->prev; 1116 1131 } 1117 1132 1118 1133 if (pinfo->prev) 1119 1134 { … … 1131 1146 { 1132 1147 pinfo->objhandle = objhandle; 1133 1148 1134 1149 pinfo->h = h; 1135 1150 1136 1151 pinfo->usecount = 1; 1137 1152 1138 1153 pinfo->objident = rasGenObjIdent (); 1139 1154 … … 1146 1161 } 1147 1162 } 1148 1163 1149 1164 pinfo->cbobjdata = cbobjdata; 1150 1165 } … … 1152 1167 struct _RAS_OBJECT_INFO *rasSearchObject2 (RAS_TRACK_HANDLE h, ULONG objident) 1153 1168 { 1154 if (!h) 1169 if (!h) 1155 1170 { 1156 1171 return NULL; … … 1158 1173 1159 1174 RAS_OBJECT_INFO *iter = h->objfirst; 1160 1175 1161 1176 while (iter) 1162 1177 { … … 1167 1182 iter = iter->next; 1168 1183 } 1169 1184 1170 1185 return iter; 1171 1186 } … … 1181 1196 struct _RAS_OBJECT_INFO *rasSearchObject (RAS_TRACK_HANDLE h, ULONG objhandle, RAS_OBJECT_INFO **ppinfo_next) 1182 1197 { 1183 if (!h) 1198 if (!h) 1184 1199 { 1185 1200 return NULL; … … 1187 1202 1188 1203 RAS_OBJECT_INFO *iter = h->objfirst; 1189 1204 1190 1205 while (iter) 1191 1206 { … … 1194 1209 break; 1195 1210 } 1196 1211 1197 1212 iter = iter->next; 1198 1213 } 1199 1214 1200 1215 if (iter && ppinfo_next) 1201 1216 { 1202 1217 *ppinfo_next = iter->next; 1203 1218 } 1204 1219 1205 1220 return iter; 1206 1221 } … … 1214 1229 { 1215 1230 pinfo->usecount--; 1216 1231 1217 1232 return pinfo->usecount; 1218 1233 } … … 1223 1238 char buf[128]; 1224 1239 char *p = &buf[0]; 1225 1240 1226 1241 if (!objdata) 1227 1242 { 1228 1243 return NO_ERROR; 1229 1244 } 1230 1245 1231 1246 for (i = 0; i < cbobjdata; i++) 1232 1247 { … … 1238 1253 p = &buf[0]; 1239 1254 } 1240 1255 1241 1256 snprintf (p, sizeof(buf) - (p - &buf[0]), "%8.8x:", i / 16); 1242 1257 p += strlen (p); 1243 1258 } 1244 1259 1245 1260 snprintf (p, sizeof(buf) - (p - &buf[0]), " %2.2x", ((char *)objdata)[i]); 1246 1261 p += strlen (p); 1247 1262 } 1248 1263 1249 1264 pRasLog ("%s\n", buf); 1250 1265 1251 1266 return NO_ERROR; 1252 1267 } … … 1258 1273 return 1; 1259 1274 } 1260 1275 1261 1276 if (objdata1 == NULL || objdata2 == NULL) 1262 1277 { … … 1264 1279 return 1; 1265 1280 } 1266 1281 1267 1282 return memcmp (objdata1, objdata2, cbobjdata1); 1268 1283 } 1269 1284 1270 ULONG rasCallLogObjectContent (RAS_TRACK_HANDLE h, RASCONTEXT_I *pctx, 1271 ULONG objident, ULONG objhandle, 1285 ULONG rasCallLogObjectContent (RAS_TRACK_HANDLE h, RASCONTEXT_I *pctx, 1286 ULONG objident, ULONG objhandle, 1272 1287 void *objdata, ULONG cbobjdata, FNRASLOG_EXTERNAL *rasLogExternal) 1273 1288 { 1274 1289 rasRestoreContext (pctx); 1275 1290 1276 1291 ULONG rc = h->pfnLogObjectContent (objident, objhandle, objdata, cbobjdata, rasLogExternal); 1277 1292 1278 1293 rasSaveContext (pctx); 1279 1294 1280 1295 return rc; 1281 1296 } 1282 1297 1283 ULONG WIN32API rasCallCompareObjectContent (RAS_TRACK_HANDLE h, RASCONTEXT_I *pctx, 1298 ULONG WIN32API rasCallCompareObjectContent (RAS_TRACK_HANDLE h, RASCONTEXT_I *pctx, 1284 1299 ULONG objhandle, void *objdata1, ULONG cbobjdata1, void *objdata2, ULONG cbobjdata2) 1285 1300 { 1286 1301 rasRestoreContext (pctx); 1287 1302 1288 1303 ULONG rc = h->pfnCompareObjectContent (objhandle, objdata1, cbobjdata1, objdata2, cbobjdata2); 1289 1304 1290 1305 rasSaveContext (pctx); 1291 1306 1292 1307 return rc; 1293 1308 } … … 1301 1316 { 1302 1317 const char *env = NULL; 1303 1318 1304 1319 DosScanEnv (name, &env); 1305 1320 1306 1321 if (env) 1307 1322 { 1308 1323 ULONG ul = 0; 1309 1324 char *e = NULL; 1310 1325 1311 1326 string2ulong (env, &e, &ul, 10); 1312 1327 1313 1328 if (e && *e == '\0') 1314 1329 { … … 1324 1339 { 1325 1340 int rc = NO_ERROR; 1326 1341 1327 1342 if (!rasdata.hmodPlugin) 1328 1343 { 1329 1344 rasdata.ret.cb = sizeof (RasEntryTable); 1330 1345 1331 1346 rasdata.ret.RasRegisterObjectTracking = RasRegisterObjectTracking; 1332 1347 rasdata.ret.RasDeregisterObjectTracking = RasDeregisterObjectTracking; … … 1343 1358 rasdata.ret.RasLogNoEOL = RasLogNoEOL2; 1344 1359 rasdata.ret.RasLogMsg = RasLogMsg2; 1360 #ifdef __GNUC__ 1361 rasdata.ret.snprintf = ras_snprintf; 1362 #else 1345 1363 rasdata.ret.snprintf = snprintf; 1364 #endif 1346 1365 rasdata.ret.RasSaveContext = RasSaveContext; 1347 1366 rasdata.ret.RasRestoreContext = RasRestoreContext; … … 1353 1372 rasdata.ret.RasTrackMemFree = RasTrackMemFree; 1354 1373 rasdata.ret.RasGetTrackHandle = RasGetTrackHandle; 1355 1374 1356 1375 rasdata.pet.cb = sizeof (RasPluginEntryTable); 1357 1376 1358 1377 rasdata.pet.RasEntry = _RasEntry; 1359 1378 1360 1379 const char *env = NULL; 1361 1380 1362 1381 DosScanEnv ("WIN32RAS_PLUGIN", &env); 1363 1382 1364 1383 if (env) 1365 1384 { 1366 1385 HMODULE hmod = NULLHANDLE; 1367 1386 FNPI *pfnPluginInit = NULL; 1368 1387 1369 1388 rc = DosLoadModule (NULL, 0, env, &hmod); 1370 1389 1371 1390 if (rc == NO_ERROR) 1372 1391 { 1373 1392 rc = DosQueryProcAddr (hmod, 0, "WIN32RAS_PLUGIN_INIT", (PFN *)&pfnPluginInit); 1374 1393 } 1375 1394 1376 1395 if (rc != NO_ERROR) 1377 1396 { 1378 1397 rasLogInternal ("Could not load RAS plugin %s rc = %d", env, rc); 1379 1398 } 1380 1399 1381 1400 if (rc != NO_ERROR && hmod) 1382 1401 { … … 1386 1405 { 1387 1406 rasdata.hmodPlugin = hmod; 1388 1407 1389 1408 pfnPluginInit (rasdata.hmod, &rasdata.ret, &rasdata.pet); 1390 1409 } 1391 1410 } 1392 1411 } 1393 1412 1394 1413 return rc; 1395 1414 } … … 1398 1417 { 1399 1418 int rc = NO_ERROR; 1400 1419 1401 1420 if (rasdata.hmodPlugin) 1402 1421 { 1403 1422 HMODULE hmod = rasdata.hmodPlugin; 1404 1423 FNPE *pfnPluginExit = NULL; 1405 1424 1406 1425 rc = DosQueryProcAddr (hmod, 0, "WIN32RAS_PLUGIN_EXIT", (PFN *)&pfnPluginExit); 1407 1426 1408 1427 if (rc == NO_ERROR) 1409 1428 { 1410 1429 pfnPluginExit (rasdata.hmod); 1411 1430 } 1412 1431 1413 1432 DosFreeModule (hmod); 1414 1433 } 1415 1434 1416 1435 return rc; 1417 1436 } … … 1463 1482 { 1464 1483 int rc = NO_ERROR; 1465 1484 1466 1485 if (!rasInitialized) 1467 1486 { 1468 1487 rasInitialized = 1; 1469 1488 1470 1489 memset (&rascfg, 0, sizeof (rascfg)); 1471 1490 1472 1491 rascfg.ulTimeout = 60000; // default 1 minute 1473 1492 rasQueryEnvUlong ("WIN32RAS_TIMEOUT", &rascfg.ulTimeout, 1, 3600, 1000); 1474 1493 1475 1494 rascfg.ulInitHeapSize = 128*1024; 1476 1495 rasQueryEnvUlong ("WIN32RAS_INITHEAPSIZE", &rascfg.ulInitHeapSize, 64, 16*1024, 1024); 1477 1496 1478 1497 ULONG ul = 0; 1479 1498 rasQueryEnvUlong ("WIN32RAS_DUMPHEAPOBJECTS", &ul, 0, 1, 1); 1480 1499 rascfg.fDumpHeapObjects = ul; 1481 1500 1482 1501 ul = 1; 1483 1502 rasQueryEnvUlong ("WIN32RAS_USEHIGHMEM", &ul, 0, 1, 1); 1484 1503 rascfg.fUseHighMem = ul; 1485 1504 1486 1505 ul = 0; 1487 1506 rasQueryEnvUlong ("WIN32RAS_ENABLE", &ul, 0, 1, 1); 1488 1507 rascfg.fRasEnable = ul; 1489 1508 1490 1509 ul = 0; 1491 1510 rasQueryEnvUlong ("WIN32RAS_BREAKPOINT", &ul, 0, 1, 1); 1492 1511 rascfg.fRasBreakPoint = ul; 1493 1512 1494 1513 memset (&rasdata, 0, sizeof (rasdata)); 1495 1514 rasdata.rlc.hlogfile = -1; 1496 1515 rasdata.hmod = hmod; 1497 1516 1498 1517 rc = NO_ERROR; 1499 1518 } 1500 1519 1501 1520 if (!rascfg.fRasEnable) 1502 1521 { … … 1510 1529 1511 1530 rc = rasInitializeLog (); 1512 1531 1513 1532 if (rc == NO_ERROR) 1514 1533 { 1515 1534 rc = rasInitializeCriticalSection (&csras); 1516 1535 } 1517 1536 1518 1537 if (rc == NO_ERROR) 1519 1538 { 1520 1539 rc = rasInitializeHeap (); 1521 1540 } 1522 1541 1523 1542 if (rc == NO_ERROR) 1524 1543 { 1525 1544 rc = rasInitializePlugin (); 1526 1545 } 1527 1546 1528 1547 return rc; 1529 1548 } … … 1532 1551 { 1533 1552 ENTER_RAS(NO_HANDLE); 1534 1553 1535 1554 /* Deregister all objects */ 1536 1555 while (rasdata.firsttrack) 1537 1556 { 1538 1557 RAS_TRACK_HANDLE iter = rasdata.firsttrack; 1539 1558 1540 1559 if (iter->fLogAtExit) 1541 1560 { 1542 1561 RasLogObjects (iter, iter->fLogObjectsAtExit? RAS_FLAG_LOG_OBJECTS: 0); 1543 1562 } 1544 1563 1545 1564 RasDeregisterObjectTracking (iter); 1546 1565 1547 1566 rasFree (iter); 1548 1567 } 1549 1568 1550 1569 rasUninitializePlugin (); 1551 1570 1552 1571 rasUninitializeHeap (); 1553 1572 1554 1573 EXIT_RAS(); 1555 1574 1556 1575 rasUninitializeCriticalSection (&csras); 1557 1558 rasUninitializeLog (); 1576 1577 rasUninitializeLog (); 1559 1578 } 1560 1579 … … 1562 1581 { 1563 1582 ENTER_RAS_RET(NO_HANDLE, NULL); 1564 1583 1565 1584 RAS_TRACK_HANDLE iter = rasdata.firsttrack; 1566 1585 1567 1586 while (iter) 1568 1587 { … … 1571 1590 break; 1572 1591 } 1573 1592 1574 1593 iter = iter->next; 1575 1594 } 1576 1595 1577 1596 EXIT_RAS(); 1578 1597 1579 1598 return iter; 1580 1599 } 1581 1600 1582 void WIN32API RasRegisterObjectTracking (RAS_TRACK_HANDLE *ph, c har *objname,1601 void WIN32API RasRegisterObjectTracking (RAS_TRACK_HANDLE *ph, const char *objname, 1583 1602 ULONG cbuserdata, 1584 1603 ULONG flags, … … 1587 1606 { 1588 1607 ENTER_RAS(NO_HANDLE); 1589 1608 1590 1609 RAS_TRACK *prt = (RAS_TRACK *)rasAlloc (sizeof (RAS_TRACK)); 1591 1610 1592 1611 if (prt) 1593 1612 { 1594 1613 strcpy (prt->objname, objname); 1595 1614 1596 1615 prt->cbuserdata = cbuserdata; 1597 1616 1598 1617 if (flags & RAS_TRACK_FLAG_LOGOBJECTCONTENT) 1599 1618 { 1600 1619 prt->fLogObjectContent = 1; 1601 1620 } 1602 1621 1603 1622 if (flags & RAS_TRACK_FLAG_MEMORY) 1604 1623 { 1605 1624 prt->fMemory = 1; 1606 1625 } 1607 1626 1608 1627 if (flags & RAS_TRACK_FLAG_LOG_AT_EXIT) 1609 1628 { 1610 1629 prt->fLogAtExit = 1; 1611 1630 } 1612 1631 1613 1632 if (flags & RAS_TRACK_FLAG_LOG_OBJECTS_AT_EXIT) 1614 1633 { 1615 1634 prt->fLogObjectsAtExit = 1; 1616 1635 } 1617 1636 1618 1637 if (pfnLogObjectContent) 1619 1638 { … … 1624 1643 prt->pfnLogObjectContent = rasLogObjectContent; 1625 1644 } 1626 1645 1627 1646 if (pfnCompareObjectContent) 1628 1647 { … … 1633 1652 prt->pfnCompareObjectContent = pfnCompareObjectContent; 1634 1653 } 1635 1654 1636 1655 /* Insert the new tracking record in the list */ 1637 1656 if (rasdata.firsttrack) … … 1645 1664 rasdata.lasttrack = rasdata.firsttrack = prt; 1646 1665 } 1647 1666 1648 1667 *ph = prt; 1649 1668 } … … 1657 1676 1658 1677 h = rasVerifyTrackHandle (h); 1659 1678 1660 1679 if (h) 1661 1680 { … … 1664 1683 { 1665 1684 RAS_OBJECT_INFO *iter = h->objfirst; 1666 1685 1667 1686 rasRemoveObjectInfo (iter); 1668 1687 1669 1688 rasFree (iter); 1670 1689 } 1671 1690 1672 1691 /* Remove the track record */ 1673 1692 if (h->next) … … 1680 1699 rasdata.lasttrack = h->prev; 1681 1700 } 1682 1701 1683 1702 if (h->prev) 1684 1703 { … … 1691 1710 } 1692 1711 } 1693 1712 1694 1713 EXIT_RAS (); 1695 1714 } … … 1700 1719 { 1701 1720 ENTER_RAS_RET (h, 0); 1702 1721 1703 1722 struct _RAS_OBJECT_INFO *pinfo_next = NULL; 1704 1723 1705 1724 struct _RAS_OBJECT_INFO *pinfo = rasSearchObject (h, objhandle, &pinfo_next); 1706 1725 1707 1726 // rasLog ("Object added: handle = %8.8X\n", objhandle); 1708 1727 1709 1728 if (pinfo != NULL) 1710 1729 { … … 1715 1734 */ 1716 1735 rasIncUseCount (pinfo); 1717 1736 1718 1737 /* log this event */ 1719 1738 rasLog ("Dublicate object added: handle = %8.8X\n", objhandle); … … 1722 1741 rasLogInternal ("Added object content:\n"); 1723 1742 rasCallLogObjectContent (h, &ctx, pinfo->objident, objhandle, objdata, cbobjdata, rasLogExternal); 1724 1743 1725 1744 rasLogInternal ("Existing object content:\n"); 1726 1745 rasCallLogObjectContent (h, &ctx, pinfo->objident, objhandle, pinfo->objdata, pinfo->cbobjdata, rasLogExternal); 1727 1746 1728 1747 if (rasCallCompareObjectContent (h, &ctx, objhandle, objdata, cbobjdata, pinfo->objdata, pinfo->cbobjdata) != 0) 1729 1748 { … … 1734 1753 else 1735 1754 { 1736 pinfo = (RAS_OBJECT_INFO *)rasAlloc (sizeof (RAS_OBJECT_INFO) - sizeof (RAS_OBJECT_INFO::userdata) 1737 + h->cbuserdata 1755 pinfo = (RAS_OBJECT_INFO *)rasAlloc (sizeof (RAS_OBJECT_INFO) - sizeof (RAS_OBJECT_INFO::userdata) 1756 + h->cbuserdata 1738 1757 + (objdata? cbobjdata: 0)); 1739 1758 if (pinfo) 1740 1759 { 1741 1760 rasInitObjectInfo (pinfo, h, objhandle, objdata, cbobjdata); 1742 1761 1743 1762 int rc = rasAddObjectInfo (pinfo, h, pinfo_next); 1744 1763 1745 1764 if (rc != NO_ERROR) 1746 1765 { 1747 rasFree (pinfo); 1766 rasFree (pinfo); 1748 1767 pinfo = NULL; 1749 1768 } … … 1752 1771 1753 1772 EXIT_RAS (); 1754 1773 1755 1774 if (pinfo) 1756 1775 { 1757 1776 return pinfo->objident; 1758 1777 } 1759 1778 1760 1779 return 0; 1761 1780 } … … 1764 1783 { 1765 1784 ENTER_RAS (h); 1766 1785 1767 1786 // rasLog ("Object to remove: handle = %8.8X\n", objhandle); 1768 1787 1769 1788 struct _RAS_OBJECT_INFO *pinfo = rasSearchObject (h, objhandle, NULL); 1770 1789 1771 1790 // rasLog ("Objects pinfo = %8.8X\n", pinfo); 1772 1791 1773 1792 if (pinfo != NULL) 1774 1793 { … … 1776 1795 { 1777 1796 rasRemoveObjectInfo (pinfo); 1778 1797 1779 1798 rasFree (pinfo); 1780 1799 } 1781 1800 } 1782 1801 1783 1802 EXIT_RAS (); 1784 1803 } 1785 1804 1786 1805 1787 1806 void WIN32API RasQueryObjectUserData (RAS_TRACK_HANDLE h, ULONG objident, void *pdata, ULONG cbdata, ULONG *pcbdataret) 1788 1807 { 1789 1808 ENTER_RAS (h); 1790 1809 1791 1810 struct _RAS_OBJECT_INFO *pinfo = rasSearchObject2 (h, objident); 1792 1811 1793 1812 if (pinfo) 1794 1813 { … … 1797 1816 cbdata = pinfo->h->cbuserdata; 1798 1817 } 1799 1818 1800 1819 memcpy (pdata, &pinfo->userdata, cbdata); 1801 1820 } … … 1804 1823 cbdata = 0; 1805 1824 } 1806 1825 1807 1826 EXIT_RAS (); 1808 1827 1809 1828 if (pcbdataret) 1810 1829 { 1811 1830 *pcbdataret = cbdata; 1812 1831 } 1813 1832 1814 1833 return; 1815 1834 } … … 1818 1837 { 1819 1838 ENTER_RAS (h); 1820 1839 1821 1840 struct _RAS_OBJECT_INFO *pinfo = rasSearchObject2 (h, objident); 1822 1841 1823 1842 if (pinfo) 1824 1843 { … … 1827 1846 cbdata = pinfo->h->cbuserdata; 1828 1847 } 1829 1848 1830 1849 memcpy (&pinfo->userdata, pdata, cbdata); 1831 1850 } … … 1834 1853 cbdata = 0; 1835 1854 } 1836 1855 1837 1856 EXIT_RAS (); 1838 1857 1839 1858 if (pcbdataret) 1840 1859 { 1841 1860 *pcbdataret = cbdata; 1842 1861 } 1843 1862 1844 1863 return; 1845 1864 } 1846 1865 1847 1866 1848 void WIN32API RasLog (char *fmt, ...)1867 void WIN32API_VA RasLog (const char *fmt, ...) 1849 1868 { 1850 1869 ENTER_RAS (NO_HANDLE); 1851 1870 1852 1871 va_list args; 1853 1872 1854 1873 va_start (args, fmt); 1855 1874 1856 1875 rasLogInternalV (NULL, fmt, args); 1857 1876 1858 1877 va_end (args); 1859 1878 1860 1879 EXIT_RAS (); 1861 1880 } 1862 1881 1863 void WIN32API RasLogNoEOL (char *fmt, ...)1882 void WIN32API_VA RasLogNoEOL (const char *fmt, ...) 1864 1883 { 1865 1884 va_list args; 1866 1885 1867 1886 ENTER_RAS (NO_HANDLE); 1868 1887 1869 1888 va_start (args, fmt); 1870 1889 1871 1890 ULONG noeolstate = rasdata.fNoEOL; 1872 1891 1873 1892 rasdata.fNoEOL = 1; 1874 1893 1875 1894 rasLogInternalV (NULL, fmt, args); 1876 1895 1877 1896 rasdata.fNoEOL = noeolstate; 1878 1897 1879 1898 va_end (args); 1880 1899 1881 1900 EXIT_RAS (); 1882 1901 } … … 1885 1904 { 1886 1905 ENTER_RAS (NO_HANDLE); 1887 1906 1888 1907 EXIT_RAS (); 1889 1908 } 1890 1909 1891 1910 void WIN32API RasLogObjects (RAS_TRACK_HANDLE h, ULONG flags) 1892 1911 { 1893 1912 ENTER_RAS (h); 1894 1913 1895 1914 rasLogInternal ("[%s] objects", h->objname); 1896 1915 1897 1916 if (h->fMemory) 1898 1917 { … … 1904 1923 } 1905 1924 } 1906 1925 1907 1926 RAS_OBJECT_INFO *iter = h->objfirst; 1908 1927 1909 1928 int count = 0; 1910 1929 ULONG cb = 0; // count total memory allocated if fMemory is set 1911 1930 1912 1931 while (iter) 1913 1932 { … … 1916 1935 cb += iter->cbobjdata; 1917 1936 } 1918 1937 1919 1938 if (flags & RAS_FLAG_LOG_OBJECTS) 1920 1939 { … … 1926 1945 { 1927 1946 rasLogInternal (" handle = %8.8X\n", iter->objhandle); 1928 1947 1929 1948 if (h->fLogObjectContent) 1930 1949 { … … 1933 1952 } 1934 1953 } 1935 1954 1936 1955 count++; 1937 1956 1938 1957 iter = iter->next; 1939 1958 } 1940 1959 1941 1960 rasLogInternal ("%d [%s] objects", count, h->objname); 1942 1961 1943 1962 if (h->fMemory && count > 0) 1944 1963 { 1945 1964 rasLogInternal ("%d bytes allocated", cb); 1946 1965 } 1947 1966 1948 1967 EXIT_RAS (); 1949 1968 1950 1969 return; 1951 1970 } … … 1954 1973 { 1955 1974 ENTER_RAS (h); 1956 1975 1957 1976 RAS_OBJECT_INFO *iter = h->objfirst; 1958 1977 1959 1978 int count = 0; 1960 1979 ULONG cb = 0; // count total memory allocated if fMemory is set 1961 1980 1962 1981 while (iter) 1963 1982 { … … 1966 1985 cb += iter->cbobjdata; 1967 1986 } 1968 1987 1969 1988 count++; 1970 1989 1971 1990 iter = iter->next; 1972 1991 } 1973 1992 1974 1993 if (h->fMemory) 1975 1994 { … … 1979 1998 } 1980 1999 } 1981 2000 1982 2001 if (pcount) 1983 2002 { 1984 2003 *pcount = count; 1985 2004 } 1986 2005 1987 2006 EXIT_RAS (); 1988 2007 1989 2008 return; 1990 2009 } 1991 2010 1992 void WIN32API RasLog2 (RAS_LOG_CHANNEL_H hchannel, char *fmt, ...)2011 void WIN32API_VA RasLog2 (RAS_LOG_CHANNEL_H hchannel, char *fmt, ...) 1993 2012 { 1994 2013 ENTER_RAS (NO_HANDLE); 1995 2014 1996 2015 va_list args; 1997 2016 1998 2017 va_start (args, fmt); 1999 2018 2000 2019 rasLogInternalV (hchannel, fmt, args); 2001 2020 2002 2021 va_end (args); 2003 2022 2004 2023 EXIT_RAS (); 2005 2024 } 2006 2025 2007 void WIN32API RasLogNoEOL2 (RAS_LOG_CHANNEL_H hchannel, char *fmt, ...)2026 void WIN32API_VA RasLogNoEOL2 (RAS_LOG_CHANNEL_H hchannel, char *fmt, ...) 2008 2027 { 2009 2028 va_list args; 2010 2029 2011 2030 ENTER_RAS (NO_HANDLE); 2012 2031 2013 2032 va_start (args, fmt); 2014 2033 2015 2034 ULONG noeolstate = rasdata.fNoEOL; 2016 2035 2017 2036 rasdata.fNoEOL = 1; 2018 2037 2019 2038 rasLogInternalV (hchannel, fmt, args); 2020 2039 2021 2040 rasdata.fNoEOL = noeolstate; 2022 2041 2023 2042 va_end (args); 2024 2043 2025 2044 EXIT_RAS (); 2026 2045 } … … 2029 2048 { 2030 2049 ENTER_RAS (NO_HANDLE); 2031 2050 2032 2051 EXIT_RAS (); 2033 2052 } … … 2047 2066 { 2048 2067 ENTER_RAS_RET (NO_HANDLE, ERROR_GEN_FAILURE); 2049 2068 2050 2069 int rc = NO_ERROR; 2051 2070 2052 2071 RasLogChannel *prlc = (RasLogChannel *)rasAlloc (sizeof (RasLogChannel)); 2053 2072 2054 2073 if (!prlc) 2055 2074 { … … 2059 2078 { 2060 2079 rc = rasOpenLogChannel (env_loghandler, prlc, filename); 2061 2080 2062 2081 if (rc != NO_ERROR) 2063 2082 { … … 2069 2088 } 2070 2089 } 2071 2090 2072 2091 EXIT_RAS (); 2073 2092 2074 2093 return rc; 2075 2094 } 2076 2095 2077 2096 void WIN32API RasWriteLogChannel (RAS_LOG_CHANNEL_H hchannel, const char *msg, ULONG length) 2078 2097 { 2079 2098 ENTER_RAS (NO_HANDLE); 2080 2099 2081 2100 if (length > 0) 2082 2101 { 2083 2102 RasLogChannel *prlc = (RasLogChannel *)hchannel; 2084 2103 2085 2104 prlc->pfnWriteLog (prlc->hlogfile, (char *)msg, length); 2086 2105 } 2087 2106 2088 2107 EXIT_RAS (); 2089 2108 } 2090 2109 2091 2110 void WIN32API RasCloseLogChannel (RAS_LOG_CHANNEL_H hchannel) 2092 2111 { 2093 2112 ENTER_RAS (NO_HANDLE); 2094 2113 2095 2114 RasLogChannel *prlc = (RasLogChannel *)hchannel; 2096 2115 2097 2116 rasCloseLogChannel (prlc); 2098 2117 2099 2118 rasFree (prlc); 2100 2119 2101 2120 EXIT_RAS (); 2102 2121 } 2103 2122 2104 2123 2105 2124 void WIN32API RasEntry (ULONG ulEvent, void *p, ULONG cb) 2106 2125 { 2107 2126 ENTER_RAS (NO_HANDLE); 2108 2127 2109 2128 if (rasdata.pet.RasEntry) 2110 2129 { 2111 2130 rasdata.pet.RasEntry (ulEvent, p, cb); 2112 2131 } 2113 2132 2114 2133 EXIT_RAS (); 2115 2134 } … … 2140 2159 { 2141 2160 ENTER_RAS (h); 2142 2161 2143 2162 if (h->fMemory && size > 0) 2144 2163 { … … 2146 2165 h->cbTotalAllocated += size; 2147 2166 } 2148 2167 2149 2168 EXIT_RAS (); 2150 2169 } 2151 2170 2152 2171 void WIN32API RasTrackMemRealloc (RAS_TRACK_HANDLE h, ULONG oldsize, ULONG newsize) 2153 2172 { 2154 2173 ENTER_RAS (h); 2155 2174 2156 2175 if (h->fMemory) 2157 2176 { … … 2162 2181 } 2163 2182 } 2164 2183 2165 2184 EXIT_RAS (); 2166 2185 } 2167 2186 2168 2187 void WIN32API RasTrackMemFree (RAS_TRACK_HANDLE h, ULONG size) 2169 2188 { 2170 2189 ENTER_RAS (h); 2171 2190 2172 2191 if (h->fMemory && size > 0) 2173 2192 { … … 2175 2194 h->cbTotalAllocated -= size; 2176 2195 } 2177 2196 2178 2197 EXIT_RAS (); 2179 2198 } 2180 2199 2200 } // extern "C" 2201
Note:
See TracChangeset
for help on using the changeset viewer.