Mail Archives: djgpp-workers/2000/12/15/10:55:39
Hello.
I saw this on comp.os.msdos.programmer. It's source code to get
WINDOZE version, apparantly making it possible to discern between NT
and 2000.
Can we use this?
Right,
MartinS
Path: antares.lu.erisoft.se!canaio.lu.erisoft.se!erinews.ericsson.se!uab.ericsson.se!newsfeed1.telenordia.se!algonet!isdnet!209.249.123.233.MISMATCH!xfer10.netnews.com!netnews.com!newsfeed.skycache.com!Cidera!news.chorus.net!not-for-mail
From: "Joe Hagen" <jdhagen AT chorus DOT net>
Newsgroups: comp.os.msdos.programmer
Subject: Re: Getting the Windows NT version from DOS
Date: Tue, 12 Dec 2000 15:38:33 -0600
Organization: Chorus Netwoks
Lines: 246
Message-ID: <9165sr$9aa$1 AT news DOT chorus DOT net>
References: <90ljfg$8m8$1 AT nnrp1 DOT deja DOT com> <90om42$ees$1 AT news DOT chorus DOT net> <915j8b$jf4$1 AT nnrp1 DOT deja DOT com>
NNTP-Posting-Host: mail.fullcompass.com
X-Trace: news.chorus.net 976657115 9546 216.165.169.50 (12 Dec 2000 21:38:35 GMT)
X-Complaints-To: abuse AT chorus DOT net
NNTP-Posting-Date: 12 Dec 2000 21:38:35 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Xref: antares.lu.erisoft.se comp.os.msdos.programmer:33362
Here is some sample code.
The 16-bit app is vdd16.c.
It was compiled with VC++ 1.52.
It loads the VDD "on demand", which is used
to call GetVersionEx.
The 16-bit program passes a buffer to
the VDD, which is filled in with the
version info.
The _emit lines contain the BOP codes.
VDDX.C was built with VC++ 6.0, and
is the 32-bit side. It creates VDDX.DLL.
The output of vdd16.exe on my system is:
4 0 Service Pack 6
===============================
vdd16.c
===============================
#include <stdio.h>
#include <dos.h>
typedef struct _OSVERSIONINFO{
unsigned long dwOSVersionInfoSize;
unsigned long dwMajorVersion;
unsigned long dwMinorVersion;
unsigned long dwBuildNumber;
unsigned long dwPlatformId;
char szCSDVersion[ 128 ];
} OSVERSIONINFO;
int docall(OSVERSIONINFO *pOSV)
{
unsigned short handle;
unsigned short osvsize;
int errcode=0;
char *pfilename="VDDX.DLL";
char *pinitfunc="VDDInit";
char *pdispfunc="VDDDispatch";
osvsize=sizeof(*pOSV);
__asm {
push es
push ds
push si
push di
push bx
mov ax,ss
mov es,ax
mov ds,ax
mov si,word ptr[pfilename]
mov di,word ptr[pinitfunc]
mov bx,word ptr[pdispfunc]
; Invoke "RegisterModule"
_emit 0c4h
_emit 0c4h
_emit 58h
_emit 00h
jnc a_1
mov word ptr[errcode],ax
jmp done
a_1:
mov word ptr[handle],ax
mov cx,osvsize
mov si,word ptr[pOSV]
; Invoke "DispatchCall"
_emit 0c4h
_emit 0c4h
_emit 58h
_emit 02h
; Invoke "UnregisterModule"
mov ax,word ptr[handle]
_emit 0c4h
_emit 0c4h
_emit 58h
_emit 01h
}
done:
__asm {
pop bx
pop di
pop si
pop ds
pop es
}
return errcode;
}
int main(void)
{
int result;
OSVERSIONINFO osv;
osv.dwOSVersionInfoSize=sizeof(osv);
result=docall(&osv);
if (result==0)
{
printf("%lu %lu
%s\n",osv.dwMajorVersion,osv.dwMinorVersion,osv.szCSDVersion);
}
else
{
printf("ERROR: code=%d\n",result);
}
return 0;
}
===============================
vddx.c (32-bit code)
===============================
#include <windows.h>
#include <vddsvc.h>
/*
*
* VDDInitialize
*
* Arguments:
* DllHandle - Identifies this VDD
* Reason - Attach or Detach
* Context - Not Used
*
* Return Value:
* TRUE: SUCCESS
* FALSE: FAILURE
*
*/
BOOL VDDInitialize(
IN PVOID DllHandle,
IN ULONG Reason,
IN PCONTEXT Context OPTIONAL
)
{
switch(Reason)
{
case DLL_PROCESS_ATTACH:
OutputDebugString("ATTACH\n");
break;
case DLL_PROCESS_DETACH:
OutputDebugString("DETACH\n");
break;
default:
break;
}
return TRUE;
}
/*
*
* VDDTerminateVDM
*
*/
VOID VDDTerminateVDM( VOID )
{
OutputDebugString("VDDTERMINATE\n");
return;
}
/*
*
* VDDInit
*
*/
VOID VDDInit( VOID )
{
OutputDebugString("VDDINIT\n");
setCF( 0 );
}
/*
*
* VDDDispatch
*
* Arguments:
* CX=size of buffer
* DS:SI pointer to buffer
* Return Value:
* clears carry flag
* buffer filled with results of GetVersionEx
*
*/
VOID VDDDispatch( VOID )
{
USHORT PassCX;
PCHAR Buffer;
setCF(0);
PassCX = getCX();
Buffer = (PCHAR)
GetVDMPointer((ULONG)(getDS()<<16|getSI()),PassCX,FALSE);
GetVersionEx((OSVERSIONINFO *) Buffer);
}
Joe Hagen
jdhagen AT chorus DOT net
<martin_payne AT my-deja DOT com> wrote in message
news:915j8b$jf4$1 AT nnrp1 DOT deja DOT com...
> Sounds good. What VDD do you access? Could you provide some sample code?
>
- Raw text -