Ignore:
Timestamp:
Oct 18, 2000, 7:09:34 PM (25 years ago)
Author:
sandervl
Message:

LoadLibraryExA + memory map close fix, added new registry keys for installation, don't log guard page violation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/misc.cpp

    r4431 r4496  
    1 /* $Id: misc.cpp,v 1.26 2000-10-05 13:48:09 sandervl Exp $ */
     1/* $Id: misc.cpp,v 1.27 2000-10-18 17:09:33 sandervl Exp $ */
    22
    33/*
     
    2929#include "initterm.h"
    3030#include "logging.h"
     31#include "exceptutil.h"
    3132#include <wprocess.h>
    3233#include <versionos2.h>
     
    251252#if defined(DEBUG) && defined(CHECK_ODINHEAP)
    252253int checkOdinHeap = 1;
    253 #define ODIN_HEAPCHECK()        if(checkOdinHeap)       _heap_check();
     254#define ODIN_HEAPCHECK()    if(checkOdinHeap)   _heap_check();
    254255#else
    255256#define ODIN_HEAPCHECK()
     
    272273    if(!getenv("NOWIN32LOG")) {
    273274#endif
    274         char logname[CCHMAXPATH];
    275 
    276         sprintf(logname, "odin32_%d.log", loadNr);
    277         flog = fopen(logname, "w");
    278         if(flog == NULL) {//probably running exe on readonly device
    279                 sprintf(logname, "%sodin32_%d.log", kernel32Path, loadNr);
    280                 flog = fopen(logname, "w");
    281         }
     275        char logname[CCHMAXPATH];
     276
     277        sprintf(logname, "odin32_%d.log", loadNr);
     278        flog = fopen(logname, "w");
     279        if(flog == NULL) {//probably running exe on readonly device
     280            sprintf(logname, "%sodin32_%d.log", kernel32Path, loadNr);
     281            flog = fopen(logname, "w");
     282        }
    282283        oldcrtmsghandle = _set_crt_msg_handle(fileno(flog));
    283284    }
     
    291292
    292293    va_start(argptr, tekst);
    293     if(thdb) { 
    294         thdb->logfile = (DWORD)flog;
     294    if(thdb) {
     295    thdb->logfile = (DWORD)flog;
    295296        if(sel == 0x150b && !fIsOS2Image) {
    296                 fprintf(flog, "t%d: (FS=150B) ", thdb->threadId);
    297         }
    298         else    fprintf(flog, "t%d: ", thdb->threadId);
     297        fprintf(flog, "t%d: (FS=150B) ", thdb->threadId);
     298    }
     299    else    fprintf(flog, "t%d: ", thdb->threadId);
    299300    }
    300301    vfprintf(flog, tekst, argptr);
     
    326327    if(!getenv("NOWIN32LOG")) {
    327328#endif
    328         char logname[CCHMAXPATH];
    329 
    330         sprintf(logname, "odin32_%d.log", loadNr);
    331         flog = fopen(logname, "w");
    332         if(flog == NULL) {//probably running exe on readonly device
    333                 sprintf(logname, "%sodin32_%d.log", kernel32Path, loadNr);
    334                 flog = fopen(logname, "w");
    335         }
     329        char logname[CCHMAXPATH];
     330
     331        sprintf(logname, "odin32_%d.log", loadNr);
     332        flog = fopen(logname, "w");
     333        if(flog == NULL) {//probably running exe on readonly device
     334            sprintf(logname, "%sodin32_%d.log", kernel32Path, loadNr);
     335            flog = fopen(logname, "w");
     336        }
    336337    }
    337338    else
     
    344345
    345346    va_start(argptr, tekst);
    346     if(thdb) { 
    347         thdb->logfile = (DWORD)flog;
     347    if(thdb) {
     348        thdb->logfile = (DWORD)flog;
    348349    }
    349350    vfprintf(flog, tekst, argptr);
     
    378379
    379380    va_start(argptr, tekst);
     381    if(thdb) {
     382        thdb->logfile = (DWORD)flog;
     383    }
    380384    vfprintf((FILE *)logfile, tekst, argptr);
    381385    if(thdb) thdb->logfile = 0;
     
    390394}
    391395//******************************************************************************
    392 //Check if the exception occurred inside a fprintf (logging THDB member set)
    393 //If true, decrease the lock count for that file stream
    394 //NOTE: HACK: DEPENDS ON COMPILER VERSION!!!!
    395 //******************************************************************************
    396 void CheckLogException()
     396//WriteLog has to take special care to handle dprintfs inside our os/2 exception
     397//handler; if an exception occurs inside a dprintf, using dprintf in the exception
     398//handler will hang the process
     399//******************************************************************************
     400void LogException(int state)
    397401{
    398402  THDB *thdb = GetThreadTHDB();
     
    402406
    403407  if(thdb->logfile) {
    404         //oops, exception in vfprintf; let's clear the lock count
     408    if(state == ENTER_EXCEPTION) {
    405409#if (__IBMCPP__ == 300) || (__IBMC__ == 300)
    406         lock = (USHORT *)(thdb->logfile+0x1C);
     410        lock = (USHORT *)(thdb->logfile+0x1C);
    407411#else
    408412#error Check the offset of the lock count word in the file stream structure for this compiler revision!!!!!
    409413#endif
    410         (*lock)--;
     414        (*lock)--;
     415    }
     416    else { //LEAVE_EXCEPTION
     417#if (__IBMCPP__ == 300) || (__IBMC__ == 300)
     418        lock = (USHORT *)(thdb->logfile+0x1C);
     419#else
     420#error Check the offset of the lock count word in the file stream structure for this compiler revision!!!!!
     421#endif
     422        (*lock)++;
     423    }
     424  }
     425}
     426//******************************************************************************
     427//Check if the exception occurred inside a fprintf (logging THDB member set)
     428//If true, decrease the lock count for that file stream
     429//NOTE: HACK: DEPENDS ON COMPILER VERSION!!!!
     430//******************************************************************************
     431void CheckLogException()
     432{
     433  THDB *thdb = GetThreadTHDB();
     434  USHORT *lock;
     435
     436  if(!thdb) return;
     437
     438  if(thdb->logfile) {
     439    //oops, exception in vfprintf; let's clear the lock count
     440#if (__IBMCPP__ == 300) || (__IBMC__ == 300)
     441    lock = (USHORT *)(thdb->logfile+0x1C);
     442#else
     443#error Check the offset of the lock count word in the file stream structure for this compiler revision!!!!!
     444#endif
     445    (*lock)--;
    411446  }
    412447}
     
    418453{
    419454  if(oldcrtmsghandle)
    420         _set_crt_msg_handle(oldcrtmsghandle);
     455    _set_crt_msg_handle(oldcrtmsghandle);
    421456
    422457  fclose(flog);
     
    433468    if(!getenv("NOWIN32LOG")) {
    434469#endif
    435         OpenPrivateLogFilePE();
     470    OpenPrivateLogFilePE();
    436471    }
    437472}
     
    446481    if(!getenv("NOWIN32LOG")) {
    447482#endif
    448         ClosePrivateLogFilePE();
     483        ClosePrivateLogFilePE();
    449484    }
    450485}
Note: See TracChangeset for help on using the changeset viewer.