Example #1
0
int FAR PASCAL LibMain(HANDLE hInstance, WORD wDataSeg, WORD cbHeapSize,
                       LPSTR lpszCmdLine)
{
    HDC hScreenDC = GetDC(NULL);
    
    bProtectedLock = (GetWinFlags() & WF_PMODE) != FALSE;
    hWndKalView = NULL;
    klwLGBrush = GetStockObject(LTGRAY_BRUSH);
    klwDGBrush = GetStockObject(DKGRAY_BRUSH);
    klwBBrush = GetStockObject(BLACK_BRUSH);
    klwNBrush = GetStockObject(NULL_BRUSH);
    klwBPen = GetStockObject(BLACK_PEN);
    hInstKlwDll = hInstance;
    srclns.lines = 0;
    dbgstack = NULL;
    varstack = NULL;
    break_on_call = FALSE;

    sXPixels = GetDeviceCaps(hScreenDC, HORZRES);
    sYPixels = GetDeviceCaps(hScreenDC, VERTRES);
    ReleaseDC(NULL, hScreenDC);
    
    SaveOrigDataSeg(wDataSeg);
    
    if (cbHeapSize != 0)
    	UnlockData(0);

    return TRUE;
}
Example #2
0
void __chk8087( void )
/********************/
{
    if( _RWD_8087 != 0 )             /* if we already know we have an 80x87 */
        return;                      /* this prevents real87 from being set */
                                     /* when we have an emulator */
    if( GetWinFlags() & WF_80x87 ) { /* if a coprocessor is present then we */
  #if defined( __386__ )
        _FloatingPoint();
  #endif
        _RWD_real87 = __x87id();     /* initialize even when NO87 is defined */
        _RWD_8087 = _RWD_real87;     /* this handles the fpi87 and NO87 case */
        __init_8087();
    } else {
  #if defined( __386__ )
        // check to see if emulator is loaded
        union REGS regs;
        regs.w.ax = 0xfa00;
        int86( 0x2f, &regs, &regs );
        if( regs.w.ax == 0x0666 ) {  /* check for emulator present */
            _RWD_real87 = __x87id(); /* initialize even when NO87 is defined */
            _RWD_8087 = _RWD_real87; /* this handles the fpi87 and NO87 case */
            __init_8087();
        }
  #endif
    }
    if( _RWD_no87 != 0 ) {           /* if NO87 environment var is defined */
        _RWD_8087 = 0;               /* then we want to pretend that the */
        _RWD_real87 = 0;             /* coprocessor doesn't exist */
    }
}
void TSysInfoWindow::GetSysInformation( void )
{
	DWORD SysFlags;
	char tempstr[ 31 ];
	WORD ArgList[ 2 ];
	WORD Ver;
	DWORD Available;
	HINSTANCE hInstance = GetApplication()->hInstance;

	SysFlags = GetWinFlags();

	ArgList[ 0 ] = GetModuleUsage( hInstance );
	wvsprintf( (LPSTR) TransferRecord.InstanceNumber, (LPSTR) "%d", (LPSTR) ArgList );

	Ver = GetVersion();
	ArgList[0] = (WORD) LOBYTE(LOWORD( Ver ));
	ArgList[1] = (WORD) HIBYTE(LOWORD( Ver ));
	wvsprintf( (LPSTR) TransferRecord.WindowsVersion, (LPSTR) "%d.%d", (LPSTR) ArgList );

	if ( SysFlags & WF_ENHANCED )
		LoadString( hInstance, ID_ENHANCED, tempstr, sizeof( tempstr ) );
	else if ( SysFlags & WF_STANDARD )
		LoadString( hInstance, ID_STANDARD, tempstr, sizeof( tempstr ) );
	else if ( SysFlags & WF_PMODE )
		LoadString( hInstance, ID_REAL, tempstr, sizeof( tempstr ) );
	else
		LoadString( hInstance, ID_UNKNOWN, tempstr, sizeof( tempstr ) );
	strcpy( TransferRecord.OperationMode, tempstr );

	if ( SysFlags & WF_CPU086 )
		LoadString( hInstance, ID_CPU8086, tempstr, sizeof( tempstr ) );
	else if ( SysFlags & WF_CPU186 )
		LoadString( hInstance, ID_CPU80186, tempstr, sizeof( tempstr ) );
	else if ( SysFlags & WF_CPU286 )
		LoadString( hInstance, ID_CPU80286, tempstr, sizeof( tempstr ) );
	else if ( SysFlags & WF_CPU386 )
		LoadString( hInstance, ID_CPU80386, tempstr, sizeof( tempstr ) );
	else if ( SysFlags & WF_CPU486 )
		LoadString( hInstance, ID_CPU80486, tempstr, sizeof( tempstr ) );
	else
		LoadString( hInstance, ID_UNKNOWN, tempstr, sizeof( tempstr ) );
	strcpy( TransferRecord.CPUType, tempstr );

	if ( SysFlags & WF_80x87 )
		LoadString( hInstance, ID_YES, tempstr, sizeof( tempstr ) );
	else
		LoadString( hInstance, ID_NO, tempstr, sizeof( tempstr ) );
	strcpy( TransferRecord.CoProcessor, tempstr );

	Available = GetFreeSpace( 0 ) / 1024;
	ArgList[0] = LOWORD( Available );
	ArgList[1] = HIWORD( Available );
	wvsprintf( (LPSTR) TransferRecord.Global, (LPSTR) "%lu", (LPSTR) ArgList );

	ArgList[0] = _osmajor;
	ArgList[1] = _osminor;
	wvsprintf( (LPSTR) TransferRecord.VersionDos, (LPSTR) "%d.%d", (LPSTR) ArgList );

	TransferBuffer = (LPSTR) &TransferRecord;
}
Example #4
0
int WINAPI LibMain( HINSTANCE hmod, WORD dataseg, WORD heap, LPSTR cmdline )
{
    dataseg=dataseg;heap=heap;cmdline=cmdline;
    Instance=hmod;
    DesktopWindow = GetDesktopWindow();
    WindowsFlags = GetWinFlags();
    return( 1 );
}
Example #5
0
int FAR PASCAL LibMain(HINSTANCE hInstance,
                       WORD      wDataSeg,
                       WORD      cbHeapSize,
                       LPSTR     lpszCmdLine) 
{
    OFSTRUCT ofStruct ;
    int fh ;
    BOOL fLoadNetware = FALSE ;
    char IsInstalledString[16] ;

    UNREFERENCED(hInstance) ;
    UNREFERENCED(wDataSeg) ;
    UNREFERENCED(cbHeapSize) ;
    UNREFERENCED(lpszCmdLine) ;
 
    I_SetCapBits() ;

    if (GetProfileString("NWCS",
                         "NwcsInstalled",
                         "0", 
                         IsInstalledString,
                         sizeof(IsInstalledString)))
    {
        fLoadNetware = (lstrcmp("1",IsInstalledString)==0) ;
    }

    //
    // if enhanced mode, grab the interrupt for NWIPXSPX
    //
    if ((GetWinFlags() & WF_ENHANCED) && fLoadNetware) {
        GrabInterrupts();
    }

    //
    // if the file NETWARE.DRV exists, we load it. we dont really
    // use it, but some Netware aware apps require that it is loaded.
    //
    if (fLoadNetware &&
        ((fh = OpenFile(NETWARE_DLL, &ofStruct, OF_READ)) != -1))
    {
        _lclose(fh) ;

        (void)WriteProfileString("Windows",
                                 "NetWarn",
                                 "0") ;

        (void)LoadLibrary(NETWARE_DLL) ;
    }

    return 1 ;
}
Example #6
0
static int win_nt( void )
/***********************/
{
    #ifdef __NT__                               /* Win32 app */
        return( WIN32_IS_NT );
    #else                                       /* Win16 app */
        DWORD           flags;

        flags = GetWinFlags() & 0x4000;
        if( flags > 0 ) {
            return( 1 );
        } else {
            return( 0 );
        }
    #endif
}
Example #7
0
UINT FASTCALL AmDriveType( LPCSTR lpszDrive )
{
#ifdef WIN32
   char sz[ 4 ];

   wsprintf( sz, "%c:\\", *( lpszDrive+2 ) );
   return( GetDriveType( sz ) );
#else
   int iType;
   BOOL fCDROM = FALSE;
   BOOL fRAM = FALSE;
   int iDrive;

   iDrive = lpszDrive[ 2 ] - 'a';
   iType = GetDriveType( iDrive );
    /*
     * Under Windows NT, GetDriveType returns complete information
     * not provided under Windows 3.x which we now get through other
     * means.
     */
   if( GetWinFlags() & 0x4000 )
      return( iType );

    /* Check for CDROM on FIXED and REMOTE drives only */
    if (DRIVE_FIXED==iType || DRIVE_REMOTE==iType)
        {
        _asm
            {
            mov     ax,1500h        /* Check if MSCDEX exists */
            xor     bx,bx
            int     2fh

            or      bx,bx           /* BX unchanged if MSCDEX is not around */
            jz      CheckRAMDrive   /* No?  Go check for RAM drive. */

            mov     ax,150Bh        /* Check if drive is using CD driver */
            mov     cx,iDrive
            int     2fh

            mov     fCDROM,ax       /* AX if the CD-ROM flag */
            or      ax,ax
            jnz     Exit            /* Leave if we found a CD-ROM drive. */

            CheckRAMDrive:
            }
        }
Example #8
0
void __chk8087()
{
    unsigned char rc;
    unsigned char real87_rc;

    if( _RWD_8087 != 0 )return;     /* if we already know we have an 80x87 */
                                    /* this prevents real87 from being set */
                                    /* when we have an emulator */
    rc = 0;
    real87_rc = 0;
    _RWD_real87 = real87_rc;
#if defined(__WINDOWS_386__) || defined(__WINDOWS__)
    if( GetWinFlags() & WF_80x87 ) {/* if a coprocessor is present then we */
        #if defined( __WINDOWS_386__ )
            extern void pascal _FloatingPoint( void );
            _FloatingPoint();
        #endif
        rc = __init_8087();         /* initialize even when NO87 is defined */
                                    /* this handles the fpi87 and NO87 case */
        real87_rc = rc;
    } else {
        #if defined( __WINDOWS_386__ )
            // check to see if emulator is loaded
            union REGS regs;
            regs.w.ax = 0xfa00;
            int86( 0x2f, &regs, &regs );
            if( regs.w.ax==1638 ) { /* check for emulator present */
                rc = __init_8087(); /* initialize even when NO87 is defined */
                                    /* this handles the fpi87 and NO87 case */
            }
        #endif
    }
#else
    if( __test8087() == 3 ) {       /* if a coprocessor is present then we */
        rc = __init_8087();         /* initialize even when NO87 is defined */
                                    /* this handles the fpi87 and NO87 case */
        real87_rc = rc;
    }
#endif
    if( _RWD_no87 != 0 )return;     /* if NO87 environment var is defined */
                                    /* then we want to pretend that the */
    _RWD_8087 = rc;                 /* coprocessor doesn't exist */
    _RWD_real87 = real87_rc;
}
Example #9
0
int FAR PASCAL LibMain(HANDLE hInstance, WORD wDataSeg, WORD cbHeapSize,
                       LPSTR lpszCmdLine)
{
    hInstThisDll = hInstance;
    
    bProtectedLock = (GetWinFlags() & WF_PMODE) != FALSE;

    SaveOrigDataSeg(wDataSeg);

    if (cbHeapSize != 0)
        UnlockData(0);
    
#ifdef LOGMSG
    {
        OFSTRUCT of;
        hLogFile = OpenFile("msglog.txt", &of, OF_CREATE | OF_WRITE);
    }
#endif
    
    return TRUE;
}
Example #10
0
static BOOL IsWindowsNT(void)
{
   return (GetWinFlags() & 0x4000) != 0;           // WF_WINNT
}
Example #11
0
WORD KappaInitKernel(HANDLE hInstance, HANDLE hPrevInstance, 
                     LPSTR lpszCmdLine, WORD cmdShow, BOOL bMulti)
{
    HCURSOR hOldCursor;

/* 0: Load the cursors */
    arrowCursor = LoadCursor(NULL, IDC_ARROW);
    hHourGlass  = LoadCursor(NULL, IDC_WAIT);
    hKcross     = LoadCursor(hInstance, "KCross");

/* Set the busy cursor */
    hOldCursor = SetCursor(hHourGlass);

/* FIRST Initialize Some External Variables */
    hInstKappa = hInstance;
    hResThisDll = hInstance;

/* 1: Load some important words into strings */
    LoadString(hInstance, IDS_BROWSER, szBrowser, 20);
    LoadString(hInstance, IDS_SESSION, szSession, 20);
#ifndef RUNTIME
    LoadString(hInstance, IDS_INTERPRET, szInterpret, 20);
    LoadString(hInstance, IDS_TRACE, szTrace, 20);
    LoadString(hInstance, IDS_KTOOLS, szKTools, 20);
    LoadString(hInstance, IDS_TOOLS, sztools, 10);
    LoadString(hInstance, IDS_INFERENCE, szInference, 20);
    LoadString(hInstance, IDS_UNTITLED, szUntitled, 11);
    LoadString(hInstance, IDS_RULEREL, szRuleRel, 30);
    LoadString(hInstance, IDS_FINDER, szFinder, 30);
    LoadString(hInstance, IDS_KALVIEW, szKalView, 30);
#endif
    
/* 2: Set up some default brushes */
    hbrWhite = GetStockObject(WHITE_BRUSH);
    hbrBlack = GetStockObject(BLACK_BRUSH);
    hbrColor = KppGetBrush(FALSE);

/* 3: Load Accelerators table */
    hAccelTable = LoadAccelerators(hInstance, szAppName);

/* 4: Remember KAPPA's starting and system directories */
    { 
        char systemdir[FILENAME_MAX];
        
        GetModuleFileName(hInstKappa, systemdir, FILENAME_MAX - 1);
        KppSetSystemDirectory(systemdir);
        
        getcwd(systemdir, FILENAME_MAX);
        KppSetStartupDirectory(systemdir);
    }
    
#ifdef CTL3D
    /* 4 (ter) Setup 3D controls if enabled in kappa.ini */
    if (Kpp3dCtrls())
        Ctl3dRegister(hInstKappa);
#endif

    /* 5: Load icons */
#ifndef RUNTIME
    kappaIcon = LoadIcon(hInstance, szAppName);
    LoadString(hInstance, IDS_BROWSERICON, szBrowserIcon, 10);
    browserIcon = LoadIcon(hInstance, szBrowserIcon);
#endif

#ifndef RUNTIME
    LoadString(hInstance, IDS_INFERENCEICON, szInferenceIcon, 10);
    inferenceIcon = LoadIcon (hInstance, szInferenceIcon);
    LoadString(hInstance, IDS_FINDERICON, szFinderIcon, 10);
    finderIcon = LoadIcon (hInstance, szFinderIcon);
    LoadString(hInstance, IDS_KALVIEWICON, szKalViewIcon, 10);
    kalviewIcon = LoadIcon (hInstance, szKalViewIcon);
    LoadString(hInstance, IDS_TRACEICON, szTraceIcon, 10);
    traceIcon = LoadIcon (hInstance, szTraceIcon);
    LoadString(hInstance, IDS_SESSIONICON, szSessionIcon, 10);
    sessionIcon = LoadIcon (hInstance, szSessionIcon);
    LoadString(hInstance, IDS_TOOLSICON, szToolsIcon, 10);
    toolsIcon = LoadIcon (hInstance, szToolsIcon);
    LoadString (hInstance, IDS_KALICON, szKALIcon, 10);
    kalIcon = LoadIcon (hInstance, szKALIcon);
    LoadString (hInstance, IDS_RULERELICON, szRuleRelIcon, 10);
    rulerelIcon = LoadIcon (hInstance, szRuleRelIcon);
#endif /* not RUNTIME */

/* 7: define screen attributes and post initial message */

/* define global system variables */
    InitSystemParams();

#ifndef RUNTIME
   if (!(hWndKappa = CreateMainWindow(hInstance)))
       return FALSE;

   SetFocus(hWndKappa);
   CreateKappaAbout(hWndKappa);
#endif

/* 8: Load the library */
    KppInitKappaKernel(hInstance, hPrevKappa, bMulti);

#ifndef RUNTIME
   /* Create a child window of the kappa window for comments. */
   hWndComment = CreateWindow("EDIT", NULL,
                              WS_CHILD | WS_BORDER | WS_HSCROLL | WS_VSCROLL |
                              ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
                              0, 0, 0, 0,
                              hWndKappa, ID_COMMENT, hInstance, NULL);

   ShowWindow(hWndComment, SW_SHOWNORMAL);
   BringWindowToTop(hWndComment);

   /* init the protected mode variable, for Global allocation */
   if (GetWinFlags() & WF_PMODE)
       bProtectedLock = TRUE;
   
#endif /* not RUNTIME */

/* Initialize alerts (do it immediately after setting up hWndKappa */
    KppInitAlert();

/* 9: intialize others */

    /* define some atoms that are often used inside KAPPA */
    InitCommonSymbols();
    
    /* Finally, initialize KAPPA functions and top level knowledge items */
    InitKappaFunctions();
    
    /* Define callback functions for the DLL's */
    InitDLLCallbackFunctions();

    /* Initialize Menu */
    KppInitMenus();
    
    /* Initialize DDE Objects */
    KppInitDDEObjectsCB();

    /* Initialize KAPPA-PC tools */
    if (!InitKappaTools(hInstance, bMulti))
        return FALSE;

    /* Reset the cursor */
    SetCursor(hOldCursor);
    
    /* Reset the clock */
    ResetClockCB();

#ifndef RUNTIME
    DestroyKappaAbout();
    SetFocus(hWndKappa);
#endif

#ifdef RUNTIME
    hWndKappa = KpsGetMainSessionWindow();

    browserIcon = NULL;
    kappaIcon = NULL;
    if (HIBYTE(LOWORD(GetVersion())) >= 10)
    {
        char stIniFileName[_MAX_PATH];

        KppGetKappaIniFile(stIniFileName, _MAX_PATH);
        if (stIniFileName[0])
        {
            char stSessIconFileName[_MAX_PATH], stBrowIconFileName[_MAX_PATH];

            GetPrivateProfileString("ICONS", "SESSION", "", 
                                    stSessIconFileName,
                                    _MAX_PATH, stIniFileName);
            GetPrivateProfileString("ICONS", "BROWSER", "", 
                                    stBrowIconFileName,
                                    _MAX_PATH, stIniFileName);
            
            if (stSessIconFileName[0] || stBrowIconFileName[0])
            {
                HANDLE hShell = GetModuleHandle("SHELL");
                BOOL bLoaded = FALSE;
                
                if (!hShell)
                {
                    GetSystemDirectory(return_buffer, RET_BUFFER_LEN);
                    strcat(return_buffer, "\\shell.dll");
                    hShell = LoadLibrary(return_buffer);
                    bLoaded = TRUE;
                }
                
                if (hShell > 32)
                {
                    HANDLE (EXPORT *ExtractIcon_fn)(HANDLE, LPSTR, WORD);

                    ExtractIcon_fn =
                        (HANDLE (EXPORT *)(HANDLE, LPSTR, WORD)) 
                            GetProcAddress(hShell, "ExtractIcon");
                    
                    if (ExtractIcon_fn)
                    {
                        if (stSessIconFileName[0])
                        {
                            kappaIcon =
                                (*ExtractIcon_fn)(hInstance,
                                                  stSessIconFileName, 0);
                            /* check for valid icon handle */
                            if (kappaIcon == 1)
                                kappaIcon = NULL;
                        }
            
                        if (stBrowIconFileName[0])
                        {
                            browserIcon =
                                (*ExtractIcon_fn)(hInstance,
                                                  stBrowIconFileName, 0);
                            /* check for valid icon handle */
                            if (browserIcon == 1)
                                browserIcon = NULL;
                        }
                    }

                    if (bLoaded)
                        FreeLibrary(hShell);
                }
            }
        }
    }
     
    if (!kappaIcon)
        kappaIcon = LoadIcon(hInstance, szAppName);
    if (!browserIcon)
    {  
        LoadString(hInstance, IDS_BROWSERICON, szBrowserIcon, 10);
        browserIcon = LoadIcon(hInstance, szBrowserIcon);
    }
    
    SetClassWord(hWndKappa, GCW_HICON, kappaIcon);
    SetClassWord(hWndBrowser, GCW_HICON, browserIcon);
#else
    PositionMainWindows();

    ShowWindow(hWndKappa, cmdShow);
    KappaBrowserMode(FALSE, cmdShow);
    ShowWindow(hWndKTools, cmdShow);
    SetFocus(hWndKappa);
#endif

    InitPopupCounts();
    MarkAppAsUnmodifiedCB();

    return TRUE;
}
void BuildsWindow::Draw(IDirect3DDevice9* pDevice) {
	if (visible) {
		ImGui::SetNextWindowPosCenter(ImGuiSetCond_FirstUseEver);
		ImGui::SetNextWindowSize(ImVec2(300, 250), ImGuiSetCond_FirstUseEver);
		if (ImGui::Begin(Name(), GetVisiblePtr(), GetWinFlags())) {
			for (TeamBuild& tbuild : teambuilds) {
				ImGui::PushID(tbuild.ui_id);
				if (ImGui::Button(tbuild.name, ImVec2(ImGui::GetWindowContentRegionWidth()
					-ImGui::GetStyle().ItemInnerSpacing.x - 60.0f, 0))) {
					Send(tbuild);
				}
				if (ImGui::IsItemHovered()) {
					ImGui::SetTooltip("Click to send teambuild to chat");
				}
				ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x);
				if (ImGui::Button("Edit", ImVec2(60.0f, 0))) {
					tbuild.edit_open = true;
				}
				ImGui::PopID();
			}
			if (ImGui::Button("Add Teambuild", ImVec2(ImGui::GetWindowContentRegionWidth(), 0))) {
				teambuilds.push_back(TeamBuild());
				teambuilds.back().edit_open = true; // open by default
				teambuilds.back().builds.resize(4, Build());
				builds_changed = true;
			}
		}
		ImGui::End();
	}

	for (unsigned int i = 0; i < teambuilds.size(); ++i) {
		if (!teambuilds[i].edit_open) continue;
		TeamBuild& tbuild = teambuilds[i];
		char winname[128];
		_snprintf_s(winname, 128, "%s###build%d", tbuild.name, tbuild.ui_id);
		ImGui::SetNextWindowPosCenter(ImGuiSetCond_FirstUseEver);
		ImGui::SetNextWindowSize(ImVec2(500, 0), ImGuiSetCond_FirstUseEver);
		if (ImGui::Begin(winname, &tbuild.edit_open)) {
			ImGui::PushItemWidth(-120.0f);
			if (ImGui::InputText("Build Name", tbuild.name, 128)) builds_changed = true;
			ImGui::PopItemWidth();
			for (unsigned int j = 0; j < tbuild.builds.size(); ++j) {
				Build& build = tbuild.builds[j];
				ImGui::PushID(j);
				ImGui::Text("#%d", j + 1);
				ImGui::SameLine(30.0f);
				ImGui::PushItemWidth((ImGui::GetWindowContentRegionWidth() - 24.0f - 50.0f - 50.0f - 30.0f
					- ImGui::GetStyle().ItemInnerSpacing.x * 4) / 2);
				if (ImGui::InputText("###name", build.name, 128)) builds_changed = true;
				ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x);
				if (ImGui::InputText("###code", build.code, 128)) builds_changed = true;
				ImGui::PopItemWidth();
				ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x);
				if (ImGui::Button("Send", ImVec2(50.0f, 0))) {
					Send(tbuild, j);
				}
				if (ImGui::IsItemHovered()) ImGui::SetTooltip("Send to team chat");
				ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x);
				if (ImGui::Button("Load", ImVec2(50.0f, 0))) {
					GW::SkillbarMgr::LoadSkillTemplate(build.code);
				}
				if (ImGui::IsItemHovered()) ImGui::SetTooltip("Load build on your character");
				ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x);
				if (ImGui::Button("x", ImVec2(24.0f, 0))) {
					tbuild.builds.erase(tbuild.builds.begin() + j);
					builds_changed = true;
				}
				if (ImGui::IsItemHovered()) ImGui::SetTooltip("Delete build");
				ImGui::PopID();
			}
			if (ImGui::Checkbox("Show numbers", &tbuild.show_numbers)) builds_changed = true;
			ImGui::SameLine(ImGui::GetWindowContentRegionWidth() * 0.6f);
			if (ImGui::Button("Add Build", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.4f, 0))) {
				tbuild.builds.push_back(Build());
				builds_changed = true;
			}
			if (ImGui::IsItemHovered()) ImGui::SetTooltip("Add another player build row");
			ImGui::Spacing();
			// issue: moving a teambuild up or down will change the teambuild window id
			// which will make the window change size, which is pretty annoying
			if (ImGui::SmallButton("Up") && i > 0) {
				std::swap(teambuilds[i - 1], teambuilds[i]);
				builds_changed = true;
			}
			if (ImGui::IsItemHovered()) ImGui::SetTooltip("Move the teambuild up in the list");
			ImGui::SameLine();
			if (ImGui::SmallButton("Down") && i + 1 < teambuilds.size()) {
				std::swap(teambuilds[i], teambuilds[i + 1]);
				builds_changed = true;
			}
			if (ImGui::IsItemHovered()) ImGui::SetTooltip("Move the teambuild down in the list");
			ImGui::SameLine();
			if (ImGui::SmallButton("Delete")) {
				ImGui::OpenPopup("Delete Teambuild?");
			}
			if (ImGui::IsItemHovered()) ImGui::SetTooltip("Delete the teambuild");
			ImGui::SameLine(ImGui::GetWindowContentRegionWidth() * 0.6f);
			if (ImGui::Button("Close", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.4f, 0))) {
				tbuild.edit_open = false;
			}
			if (ImGui::IsItemHovered()) ImGui::SetTooltip("Close this window");

			if (ImGui::BeginPopupModal("Delete Teambuild?", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
				ImGui::Text("Are you sure?\nThis operation cannot be undone.\n\n");
				if (ImGui::Button("OK", ImVec2(120, 0))) {
					teambuilds.erase(teambuilds.begin() + i);
					builds_changed = true;
					ImGui::CloseCurrentPopup();
				}
				ImGui::SameLine();
				if (ImGui::Button("Cancel", ImVec2(120, 0))) {
					ImGui::CloseCurrentPopup();
				}
				ImGui::EndPopup();
			}
		}
		ImGui::End();
	}
}
Example #13
0
/*
 * AboutProc - callback routine for settings dialog
 */
WINEXPORT INT_PTR CALLBACK AboutProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    char        buff[256];
    LPABOUTINFO pai;

    lparam = lparam;

    switch( msg ) {
    case WM_INITDIALOG:
        pai = (LPABOUTINFO)lparam;
        if( pai->title != NULL ) {
            SetWindowText( hwnd, pai->title );
        }
        if( pai->name != NULL ) {
            sprintf( buff, banner1p1( "%s" ), pai->name );
            SetDlgItemText( hwnd, ABOUT_NAME, buff );
        }
        if( pai->version != NULL ) {
            SetDlgItemText( hwnd, ABOUT_VERSION, pai->version );
        }
        if( pai->first_cr_year != NULL ) {
#if defined( __WATCOMC__) && !defined( __ALPHA__ )
            if( _fstrcmp( pai->first_cr_year, CURR_YEAR ) ) {
#else
            if( strcmp( pai->first_cr_year, CURR_YEAR ) ) {
#endif
                sprintf( buff, banner2a( "%s" ), pai->first_cr_year );
            } else {
                strcpy( buff, banner2a( "1984" ) );
            }
            SetDlgItemText( hwnd, ABOUT_COPYRIGHT, buff );
        }
#if defined( __WINDOWS__ ) || defined( __WINDOWS_386__ )
        {
            DWORD       flags;
            DWORD       kfree;
            WORD        pcfree;
            SYSHEAPINFO shi;
            char        work[16];
            char        info[50];

            flags = GetWinFlags();
            if( flags & WF_ENHANCED ) {
                CopyRCString( ABT_386_ENH, info, sizeof( info ) );
            } else {
                CopyRCString( ABT_STD_MODE, info, sizeof( info ) );
            }
            SetDlgItemText( hwnd, ABOUT_INFO1, info );
            kfree = GetFreeSpace( 0 ) / 1024L;
            ltoa( kfree, work, 10 );
            RCsprintf( buff, ABT_MEM_X_KB_FREE, (LPSTR)work );
            SetDlgItemText( hwnd, ABOUT_INFO2, buff );

            shi.dwSize = sizeof( shi );
            if( SystemHeapInfo( &shi ) ) {
                pcfree = shi.wGDIFreePercent;
                if( pcfree > shi.wUserFreePercent )
                    pcfree = shi.wUserFreePercent;
                RCsprintf( buff, ABT_SYS_RESOURCES_FREE, pcfree );
            } else {
                CopyRCString( ABT_SYS_RESOURCES_N_A, buff, sizeof( buff ) );
            }
            SetDlgItemText( hwnd, ABOUT_INFO3, buff );
        }
#else
        {
            SYSTEM_INFO         si;
            MEMORYSTATUS        ms;

            GetSystemInfo( &si );
            switch( si.dwProcessorType ) {
            case PROCESSOR_INTEL_386:
                CopyRCString( ABT_RUNNING_ON_386, buff, sizeof( buff ) );
                break;
            case PROCESSOR_INTEL_486:
                CopyRCString( ABT_RUNNING_ON_486, buff, sizeof( buff ) );
                break;
            case PROCESSOR_INTEL_PENTIUM:
                CopyRCString( ABT_RUNNING_ON_586, buff, sizeof( buff ) );
                break;
            case PROCESSOR_MIPS_R4000:
            case PROCESSOR_ALPHA_21064:
            default:
                buff[0] = '\0';
                break;
            }
            SetDlgItemText( hwnd, ABOUT_INFO1, buff );

            ms.dwLength = sizeof( ms );
            GlobalMemoryStatus( &ms );
            RCsprintf( buff, ABT_VIRT_MEM,
                       (ms.dwAvailPhys + ms.dwAvailPageFile) / 1024L );
            SetDlgItemText( hwnd, ABOUT_INFO2, buff );
            RCsprintf( buff, ABT_MEM_LOAD, ms.dwMemoryLoad );
            SetDlgItemText( hwnd, ABOUT_INFO3, buff );

        }
#endif
        return( TRUE );
#ifndef NOUSE3D
    case WM_SYSCOLORCHANGE:
        CvrCtl3dColorChange();
        break;
#endif
    case WM_CLOSE:
        EndDialog( hwnd, 0 );
        break;
    case WM_COMMAND:
        switch( LOWORD( wparam ) ) {
        case IDOK:
        case IDCANCEL:
            EndDialog( hwnd, 0 );
            break;
        }
    }
    return( FALSE );

} /* AboutProc */

/*
 * DoAbout - show the startup dialog
 */
void DoAbout( LPABOUTINFO ai )
{
    FARPROC     proc;

    proc = MakeDlgProcInstance( AboutProc, ai->inst );
    DialogBoxParam( ai->inst, "About", ai->owner, (DLGPROC)proc, (LPARAM)ai );
    FreeProcInstance( proc );

} /* DoAbout */
Example #14
0
/*
 * Init32BitTask - load and initialize the 32-bit application
 */
int Init32BitTask( HINSTANCE thishandle, HINSTANCE prevhandle, LPSTR cmdline,
                    int cmdshow )
{
    WORD                i,amount,bytes_read,j;
    WORD                sel;
    int                 handle;
    tiny_ret_t          rc;
    DWORD               size,currsize,curroff,minmem,maxmem;
    DWORD               relsize,exelen;
    struct wstart_vars  __far *dataptr;
    void                __far *aliasptr;
    DWORD               __far *relptr;
    struct fpu_area     __far *fpuptr;
    rex_exe             exe;
    exe_data            exedat;
    char                file[128];
    DWORD               flags;
    version_info        vi;
    DWORD               file_header_size;
    BOOL                tried_global_compact;
    DWORD               save_maxmem;
    DWORD               adata[2];

    flags = GetWinFlags();
    /*
     * verify that we are running on a 32-bit DPMI
     */
    _fDPMIGetVersion( &vi );
    if( !(vi.flags & VERSION_80386) ) {
        MessageBox( NULL, "Not running on a 386 DPMI implementation",MsgTitle,
                        MB_OK | MB_ICONHAND | MB_TASKMODAL );
        return( FALSE );
    }

    /*
     * get exe to load
     */
    GetModuleFileName( thishandle, file, 128 );
    rc = _fTinyOpen( file, TIO_READ );
    if( TINY_ERROR( rc ) ) {
        return( Fini( 2, (char _FAR *)"Error opening file",
                    (char _FAR *)file) );
    }
    handle = TINY_INFO( rc );

    _TinySeek( handle, 0x38, TIO_SEEK_START );
    _fTinyRead( handle, &exelen, sizeof( DWORD ) );
    _TinySeek( handle, exelen, TIO_SEEK_START );

    /*
     * check if we are being run by the debugger.  When the debugger
     * sees the 'DEADBEEF' bytes at the start of the code segment
     * (see begin.asm), it swaps them to be BEEFDEAD.  The debugger
     * then tells us to go, and if we see that we have BEEFDEAD,
     * we execute a breakpoint just before we call our 32-bit code.
     * Then the debugger traces a single instruction and it looks to
     * the user like the start of his/her code is the start of
     * the application.
     */
    if( deadbeef == 0xBEEFDEAD ) {
        InDebugger = 0;
    } else {
        InDebugger = 1;
    }
    DPL = (CS() & 0x03) << 5;   /* our privilege level */

    /*
     * validate header signature
     */
    _fTinyRead( handle, &exe, sizeof( rex_exe ) );
//    BreakPoint();
    if( !(exe.sig[0] == 'M' && exe.sig[1] == 'Q') ) {
        return( Fini( 1,(char _FAR *)"Invalid EXE" ) );
    }
    file_header_size = (DWORD) exe.file_header * 16L;
    /*
     * exe.one is supposed to always contain a 1 for a .REX file.
     * However, to allow relocation tables bigger than 64K, the
     * we extended the linker to have the .one field contain the
     * number of full 64K chunks of relocations, minus 1.
     */
    file_header_size += (exe.one-1)*0x10000L*16L;

    /*
     * get exe data - data start and stack start
     */
    _TinySeek( handle, exelen + file_header_size + (long)exe.initial_eip, TIO_SEEK_START );
    _fTinyRead( handle, &exedat, sizeof( exe_data ) );
    /*
     * get file size
     */
    size = (long) exe.file_size2 * 512L;
    if( exe.file_size1 > 0 ) {
        size += (long) exe.file_size1 - 512L;
    }

    /*
     * get stack size
     */
    StackSize = Align4K( exe.initial_esp - ((exedat.stackstart+15) & ~15ul) );
    if( StackSize < 0x1000 ) {
        StackSize = 0x1000;
    }

    /*
     * get minimum/maximum amounts of heap, then add in exe size
     * to get total area
     */
//    BreakPoint();
    minmem = (DWORD) exe.min_data *(DWORD) 4096L;
    if( exe.max_data == (WORD)-1 ) {
        maxmem = 4096L;
    } else {
        maxmem = (DWORD) exe.max_data*4096L;
    }
    minmem = Align4K( minmem + size + 0x10000ul );
    maxmem = Align4K( maxmem + size + 0x10000ul );
    if( minmem > maxmem ) {
        maxmem = minmem;
    }

    /*
     * get memory to load file
     */
    tried_global_compact = FALSE;
    save_maxmem = maxmem;
    for(;;) {
        i = DPMIGet32( adata, maxmem );
        if( i != 5 )  break;
        if( maxmem == minmem ) {
            if( tried_global_compact ) {
                return( Fini( 3,
                  (char _FAR *)"Not enough memory for application\n(minimum ",
                  dwordToStr( minmem ),(char _FAR *)" required)" ));
            }
            /*
             * GlobalCompact(-1) causes Windows to unfragment its
             * memory.  This might give us a chance to get a linear
             * chunk big enough
             */
            GlobalCompact( GlobalCompact( 0 ) );
            maxmem = save_maxmem;
            tried_global_compact = TRUE;
        } else if( maxmem < 64L * 1024L ) {
            maxmem = minmem;
        } else {
            maxmem -= 64L * 1024L;
            if( maxmem < minmem ) {                     /* 09-aug-93 */
                maxmem = minmem;
            }
        }
    }
    DataHandle = adata[1];
    BaseAddr   = adata[0] + 0x10000ul;
#if FLAT
    i = InitFlatAddrSpace( BaseAddr, 0L );
#else
    i = InitFlatAddrSpace( BaseAddr, maxmem );
#endif
    BaseAddr = 0L;
    if( i ) {
        DPMIFreeMemoryBlock( DataHandle );
        return( Fini( 2,(char _FAR *)"Allocation error ", dwordToStr( i ) ) );
    }
    SaveSP = BaseAddr + StackSize;
    CodeLoadAddr = SaveSP;
    MyDataSelector = DataSelector;
    GetDataSelectorInfo();
    CodeEntry.off = exe.initial_eip + CodeLoadAddr + sizeof( exe_data );

    /*
     * this builds a collection of LDT selectors that are ready for
     * allocation
     */
    if( InitSelectorCache() != 0 ) {
        return( Fini( 1,(char _FAR *)outOfSelectors) );
    }

    /*
     * read the exe into memory
     */
    currsize = size - file_header_size;
    _TinySeek( handle, exelen + file_header_size, TIO_SEEK_START );
    i = DPMIGetAliases( CodeLoadAddr, (LPDWORD) &aliasptr, 0 );
    if( i ) {
        return( Fini( 3,(char _FAR *)"Error ",
                dwordToStr( i ),
                (char _FAR *)" getting alias for read" ) );
    }
    dataptr = aliasptr;
    sel = ((DWORD) dataptr) >> 16;
    curroff = CodeLoadAddr;
    while( currsize != 0 ) {

        if( currsize >= (DWORD) READSIZE ) {
            amount = READSIZE;
        } else {
            amount = (WORD) currsize;
        }
        rc = _fTinyRead( handle, dataptr, amount );
        bytes_read = TINY_INFO( rc );
        if( bytes_read != amount ) {
            return( Fini( 1,(char _FAR *)"Read error" ) );
        }
        currsize -= (DWORD) amount;
        curroff += (DWORD) amount;
        DPMISetSegmentBaseAddress( sel, DataSelectorBase + curroff );
    }
    EDataAddr = curroff;                        // 03-jan-95

    DPMISetSegmentBaseAddress( sel, DataSelectorBase );
    relptr = (DWORD __far *)aliasptr;             // point to 32-bit stack area
    /*
     * get and apply relocation table
     */
    relsize = sizeof( DWORD ) * (DWORD) exe.reloc_cnt;
    {
        DWORD   realsize;
        WORD    kcnt;

        realsize = file_header_size - (DWORD) exe.first_reloc;
        kcnt = realsize / (0x10000L*sizeof(DWORD));
        relsize += kcnt * (0x10000L*sizeof(DWORD));
    }
    if( relsize != 0 ) {
        _TinySeek( handle, exelen + (DWORD)exe.first_reloc, TIO_SEEK_START );
        if( StackSize >= (DWORD) READSIZE ) {
            amount = READSIZE;
        } else {
            amount = (WORD) StackSize;
        }
        while( relsize != 0L ) {
            if( relsize < (DWORD)amount ) {
                amount = (WORD) relsize;
            }
            rc = _fTinyRead( handle, relptr, amount );
            bytes_read = TINY_INFO( rc );
            if( bytes_read != amount ) {
                return( Fini( 1,(char _FAR *)"Relocation read error" ) );
            }
            CodeRelocate( relptr, amount/sizeof(DWORD) );
            relsize -= (DWORD) amount;
        }
    }

    _TinyClose( handle );

    /* initialize emulator 8087 save area 20-oct-94 */

    fpuptr = (struct fpu_area __far *)((char __far *)aliasptr + FPU_AREA);
    _fmemset( fpuptr, 0, sizeof(struct fpu_area) );
    fpuptr->control_word = 0x033F;
    fpuptr->tag_word = 0xFFFF;

    /*
     * set dataptr to special area in data segment of 32-bit app
     */
    curroff = exedat.datastart;
    if( exe.reloc_cnt != 0 )  curroff += CodeLoadAddr;
    DPMISetSegmentBaseAddress( sel, DataSelectorBase + curroff );

    /*
     * insert command line parms
     */
    dataptr->thishandle = (WORD)thishandle;
    dataptr->prevhandle = (WORD)prevhandle;
    dataptr->cmdline    = (DWORD) cmdline;
    dataptr->cmdshow    = cmdshow;
    dataptr->_no87      = _no87;

    /*
     * set hardware selectors for screen memory
     */
    dataptr->_A000H     = (WORD) &_A000H;
    dataptr->_B000H     = (WORD) &_B000H;
    dataptr->_B800H     = (WORD) &_B800H;
    dataptr->_C000H     = (WORD) &_C000H;
    dataptr->_D000H     = (WORD) &_D000H;
    dataptr->_E000H     = (WORD) &_E000H;
    dataptr->_F000H     = (WORD) &_F000H;

    /*
     * ptrs to some data areas
     */
    dataptr->CodeSelectorBase.seg =  (WORD) FP_SEG( &CodeSelectorBase );
    dataptr->CodeSelectorBase.off = (DWORD) FP_OFF( &CodeSelectorBase );
    dataptr->DataSelectorBase.seg =  (WORD) FP_SEG( &DataSelectorBase );
    dataptr->DataSelectorBase.off = (DWORD) FP_OFF( &DataSelectorBase );
    dataptr->_32BitCallBackAddr.seg =  (WORD) FP_SEG( &_32BitCallBackAddr );
    dataptr->_32BitCallBackAddr.off = (DWORD) FP_OFF( &_32BitCallBackAddr );
    dataptr->_DLLEntryAddr.seg =  (WORD) FP_SEG( &_DLLEntryAddr );
    dataptr->_DLLEntryAddr.off = (DWORD) FP_OFF( &_DLLEntryAddr );
    dataptr->_WEPAddr.seg =  (WORD) FP_SEG( &_WEPAddr );
    dataptr->_WEPAddr.off = (DWORD) FP_OFF( &_WEPAddr );
    dataptr->_16BitCallBackAddr = &__CallBack;

    /*
     * insert glue routines into data area of caller
     */
    for( j = 0; j < MaxGlueRoutines; j++ ) {
        dataptr->gluertns[j].seg =  (WORD) FP_SEG( Glue[j].rtn );
        dataptr->gluertns[j].off = (DWORD) FP_OFF( Glue[j].rtn );
    }
    DPMIFreeAlias( sel );

    /*
     * check for FPU and WGod
     */
    if( flags & WF_80x87 ) {
        Has87 = TRUE;
    } else {
        Has87 = FALSE;
    }
    if( CheckWin386Debug() == WGOD_VERSION ) {
//    BreakPoint();
        HasWGod = TRUE;
        if( !Has87 ) {
            EMUInit();
            EMURegister( CodeEntry.seg, SaveSP - StackSize + FPU_AREA );
        }
    } else {
        HasWGod = FALSE;
    }
    return( TRUE );

} /* Init32BitTask */
Example #15
0
/*

  @doc MISC

  @func DWORD | WhichOS | This function will attempt to
  determine which Operating System and subsystem is being used by the
  application. It should function under Win16, Windows NT amd Windows
  95 at least.  It does call WSAStartup() and WSACleanup(). This
  function does have side effects on some global variables.  See the
  comments below.

  @parm DWORD *| check | a pointer to a DWORD, a value indicating
  which operating system and/or subsystem is being used will be stored
  in this parameter upon return.

  @rdesc a NULL will indicate that we could not determine what OS is
  being used. The high word contains:


  @flag MS_OS_WIN     (1) | The application is running under Windows or WFWG
  @flag	MS_OS_95      (2) | The application is running under Windows 95
  @flag	MS_OS_NT      (3) | The application is running under Windows NT
  @flag	MS_OS_2000    (4) | The application is running under Windows 2000
  @flag	MS_OS_XP      (5) | The application is running under Windows XP
  @flag	MS_OS_2003    (6) | The application is running under Windows 2003
  @flag	MS_OS_NT_UNKNOWN (7) | The application is running under Windows NT family beyond 2003
  @flag	MS_OS_UNKNOWN (0) | It looks like Windows but not any version that
                            we know of.

  <nl>these are defined in mitwhich.h<nl>

The low word contains one of the following, which is derived from the winsock implementation: <nl>

  @flag MS_NT_32 (1) | The MS 32 bit Winsock stack for NT is being used
  @flag MS_NT_16 (2) | The MS 16 bit Winsock stack under NT is being used
  @flag	MS_95_32 (3) | The MS 32 bit Winsock stack under 95 is being used
  @flag	MS_95_16 (4) | The MS 16 bit Winsock stack under 95 is being used
  @flag	NOVELL_LWP_16       (5)  | The Novell 16 Winsock stack is being used
  @flag UNKNOWN_16_UNDER_32 (-2) | We don't know the stack.
  @flag UNKNOWN_16_UNDER_16 (-3) | We don't know the stack.
  @flag UNKNOWN_32_UNDER_32 (-4) | We don't know the stack.
  @flag UNKNOWN_32_UNDER_16 (-5) | We don't know the stack.

*/
DWORD
WhichOS(
    DWORD *check
    )
{
    WORD wVersionRequested;
    WSADATA wsaData; // should be a global?
    int err;

    int checkStack = 0;
    int checkOS = 0;
    static DWORD dwCheck = 0xFFFFFFFF;

    if ( dwCheck != 0xFFFFFFFF ) {
        if ( check )
            *check = dwCheck;
        return dwCheck;
    }

    // first get the information from WSAStartup because it may give
    // more consistent information than Microsoft APIs.

    wVersionRequested = 0x0101;

    err = WSAStartup( wVersionRequested, &wsaData );

    if( err != 0 ){
        MessageBox( NULL,
                    "It looks like a useable winsock.dll\n"
                    "could not be located by the wshelp*.dll\n"
                    "Please check your system configuration.",
                    "Problem in wshelper.dll", MB_OK );
        check = 0;
        return(0);
    }

    WSACleanup();

    if( _res.options & RES_DEBUG ){
        wsprintf( debstr, wsaData.szDescription );
        OutputDebugString( debstr );
    }

    if( (0 == checkStack) && (0 == stricmp( wsaData.szDescription, NT_32 ))){
        // OK we appear to be running under NT in the 32 bit subsystem
        // so we must be a 32 bit application.
        // This also implies that we can get the TCPIP parameters out
        // of the NT registry.
        checkStack = MS_NT_32;
    }

    if( (0 == checkStack) && (0 == stricmp( wsaData.szDescription, NT_16 ))){
        // this implies we're running under NT in the 16 bit subsystem
        // so we must be a 16 bit application
        // This means we have to go through some strange gyrations to read the
        // TCPIP parameters out of the NT 32 bit registry.
        checkStack = MS_NT_16;
        checkOS = MS_OS_NT;
    }

    if( (0 == checkStack) && (0 == stricmp( wsaData.szDescription, W95_32 ))){
	// get the TCPIP parameters out of the Win95 registry
        checkStack = MS_95_32;
        checkOS = MS_OS_95; // ??
    }

    if( (0 == checkStack) && (0 == stricmp( wsaData.szDescription, W95_16 ))){
        // go through the pain of getting the TCPIP parameters out of the Win95
        // 32 bit registry
        checkStack = MS_95_16;
        checkOS = MS_OS_95;
    }

    if( (0 == checkStack) && (0 == stricmp( wsaData.szDescription, LWP_16 ))){
        // get the information out of the %NDIR%\TCP\RESOLV.CFG file
        checkStack = NOVELL_LWP_16;
        checkOS = MS_OS_WIN;
    }

    if( 0 == checkStack ){
        // at this time we don't easily know how to support this stack
        checkStack = STACK_UNKNOWN;
    }

#if !defined(_WIN32)
    // Note, if this is the 32 bit DLL we can't use the following
    // functions to determine the OS because they are
    // obsolete. However, we should be able to use them in the 16 bit
    // DLL.
    {
        DWORD dwVersion = 0;
        DWORD dwFlags = 0;

        dwFlags = GetWinFlags();
        if( _res.options & RES_DEBUG ){
            wsprintf( debstr, "dwFlags = %x ", dwFlags );
            OutputDebugString( debstr );
        }

        dwVersion = GetVersion();

        if( _res.options & RES_DEBUG ){
            wsprintf( debstr, "dwVersion = %8lx ", dwVersion );
            OutputDebugString( debstr );
        }

        if( 95 == (DWORD)(HIBYTE(LOWORD(dwVersion))) ){
            // OK, we're a 16 bit app running on 95?
            checkOS = MS_OS_95;
        }

        if( dwFlags & 0x4000 ){
            // This means that this is a 16 bit application running
            // under WOW layer on NT.

            // So, we're going to get the TCPIP parameters out of the
            // 32 bit registry, but we don't know which set of
            // registry entries yet.

            // Since we see these version numbers and we're under WOW
            // we must be under NT 4.0 but we don't necessarily know
            // the stack
            checkOS = MS_OS_NT;
        }


        if( checkOS == 0 ){
            // We are a 16 bit application running on a 16 bit operating system
            checkOS = MS_OS_WIN; // assumption, but we're not under 95 and not under NT, it looks like
            if( checkStack == STACK_UNKNOWN ){
                checkStack = UNKNOWN_16_UNDER_16;
            }
        }
    }
#endif // !_WIN32

#if defined(_WIN32)
    // This must be a 32 bit application so we are either under NT,
    // Win95, or WIN32s
    {
        OSVERSIONINFO osvi;

        memset( &osvi, 0, sizeof(OSVERSIONINFO));
        osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
        GetVersionEx( &osvi );

        if( osvi.dwPlatformId == VER_PLATFORM_WIN32s ){
            if( checkStack == STACK_UNKNOWN ){
                checkStack = UNKNOWN_16_UNDER_16;
            }
            checkOS = MS_OS_WIN;
            wsprintf( debstr, "Microsoft Win32s %d.%d (Build %d)\n",
                      osvi.dwMajorVersion,
                      osvi.dwMinorVersion,
                      osvi.dwBuildNumber & 0xFFFF );
        }

        if( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ){
            if( checkStack == STACK_UNKNOWN ){
                checkStack = UNKNOWN_32_UNDER_32;
            }
            checkOS = MS_OS_95;
            wsprintf( debstr, "Microsoft Windows 95 %d.%d (Build %d)\n",
                      osvi.dwMajorVersion,
                      osvi.dwMinorVersion,
                      osvi.dwBuildNumber & 0xFFFF );
        }

        if( osvi.dwPlatformId == VER_PLATFORM_WIN32_NT ){
            if( checkStack == STACK_UNKNOWN ){
                checkStack = UNKNOWN_32_UNDER_32;
            }
            if ( osvi.dwMajorVersion <= 4 )
                checkOS = MS_OS_NT;
            else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
                checkOS = MS_OS_2000;
            else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
                checkOS = MS_OS_XP;
            else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
                checkOS = MS_OS_2003;
            else
                checkOS = MS_OS_NT_UNKNOWN;
            wsprintf( debstr, "Microsoft Windows NT family %d.%d (Build %d)\n",
                      osvi.dwMajorVersion,
                      osvi.dwMinorVersion,
                      osvi.dwBuildNumber & 0xFFFF );
        }

        if( _res.options & RES_DEBUG ){
            OutputDebugString( debstr );
        }
    }

#endif // _WIN32

    // At this point we should know the OS.
    // We should also know the subsystem but not always the stack.

    dwCheck = MAKELONG(checkOS, checkStack);
    if ( check )
        *check = dwCheck;
    return( dwCheck );
}