Posted: . At: 5:45 PM. This was 4 years ago. Post ID: 14321
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


NT 3.50 Build 782 (RC2) source code has been leaked.


The source code for the NT 3.50 Build 782 (RC2) source code has been leaked. This is a complete archive of source code for the operating system, a very old version of Windows NT.

Here is some sample source code from the CMD utility, this is CMD.C.

\PRIVATE\WINDOWS\CMD\CMD.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#define MNGRP   0x0001                  // Main command loop code group
#define MNLVL   0x0001                  // Main function level
#define DPLVL   0x0002                  // Dispatch function level
#define RDLVL   0x0004                  // Redirection function level
#if DBG
void AlwaysDeb(ULONG MsgGroup, ULONG MsgLevel, CHAR *msg, ...);
#define ALWAYS(a) Deb a
#else
#define ALWAYS
#endif
 
//
// Used in rebuilding command lines for display
//
#define NSPC    0                                                               // Don't use space
#define YSPC    1                                                               // Do use space
 
#if defined( JAPAN )  // v-junm - 06/03/93
// Sets the Language Id in the TEB to Japanese if console output CP is 
// Japanese.  This is done in order for FormatMessage to display Japanese
// when cmd is running in Japanese code page.  All messages displayed in
// non-JP console output code page will be displayed in English.
 
#define SetTEBLangID() \
	if ( CurrentCP == 932 )  					\
	    SetThreadLocale(  						\
		MAKELCID(						\
		    MAKELANGID( LANG_JAPANESE, SUBLANG_ENGLISH_US ),	\
		    SORT_DEFAULT					\
		    )							\
		);							\
	else								\
	    SetThreadLocale( 						\
		MAKELCID(						\
		    MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ),	\
		    SORT_DEFAULT					\
		    )							\
		);
 
#else  // not JAPAN
#define SetTEBLangID()
#endif  // JAPAN

Some sample source code from TREE.C, this is the DOS tree utility used to show a tree view of the filesystem.

\PRIVATE\WINDOWS\CMD\TREE.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
extern   TCHAR CurDrvDir[] ;
extern   TCHAR *SaveDir ;
extern   DWORD DosErr ;
extern   BOOLEAN CtrlCSeen;
 
PTCHAR   SetWildCards( PTCHAR, BOOLEAN );
BOOLEAN  IsFATDrive( PTCHAR );
VOID     FreeStr( PTCHAR );
STATUS   GetFS( PFS, ULONG, ULONG, ULONG, ULONG, PSCREEN, BOOLEAN (*) (STATUS, PTCHAR) );
VOID     SortFileList( PFS, PSORTDESC, ULONG);
BOOLEAN  FindFirstNt( PTCHAR, PWIN32_FIND_DATA, PHANDLE );
BOOLEAN  FindNextNt ( PWIN32_FIND_DATA, HANDLE );
STATUS   SetSearchPath ( PFS, PPATDSC, PTCHAR, ULONG);
 
STATUS
BuildFSFromPatterns (
    IN  PDRP     pdpr,
    IN  BOOLEAN  fAddWild,
    OUT PFS *    ppfs
    )
{
 
    struct cpyinfo *    pcisFile;
    TCHAR	        szCurDir[MAX_PATH + 2];
    TCHAR	        szFilePattern[MAX_PATH + 2];
    PTCHAR              pszPatternCur;
    PPATDSC             ppatdscCur;
    PFS                 pfsFirst;
    PFS                 pfsCur;
    ULONG	        cbPath;
    BOOLEAN             fFatDrive;
    ULONG               i;
    PTCHAR              pszT;
 
    //
    // determine FAT drive from original pattern.
    // Used in several places to control name format etc.
    //
    DosErr = 0;
 
    //
    // Run through each pattern making all sorts of FAT etc. specific
    // changes to it and creating the directory list for it. Then
    // combine groups of patterns into common directories and recurse
    // for each directory group.
    //
 
    *ppfs = pfsFirst = (PFS)gmkstr(sizeof(FS));
    pfsFirst->pfsNext = NULL;
    pfsFirst->pszDir = NULL;
    pfsCur = pfsFirst;
    pfsCur->cpatdsc = 1;
 
    for(i = 1, ppatdscCur = &(pdpr->patdscFirst);
        i <= pdpr->cpatdsc;
        i++, ppatdscCur = ppatdscCur->ppatdscNext) {
 
        pszPatternCur = ppatdscCur->pszPattern;
 
        if (!(fFatDrive = IsFATDrive(pszPatternCur)) && DosErr) {
 
            //
            // Error in determining file system type so get out.
            //
            PutStdErr(DosErr, NOARGS);
            return( FAILURE );
 
        }
        ppatdscCur->fIsFat = fFatDrive;
 
        //
        // Do any alterations that require wild cards for searching
        // such as change .xxx to *.xxx for FAT file system requests
        //
        // Note that if the return values is a different buffer then
        // the input the input will be freed when we are done with the
        // Dir command.
        //
        //
        // Note that though SetWildCards will allocate heap for the
        // modified pattern this will get freed when FreeStack is
        // called at the end of the Dir call.
        //
        // An out of memory is the only reason to fail and we would not
        // return from that but go through the abort call in gmstr
        //
 
        if (fAddWild) {
 
            pszT = SetWildCards(pszPatternCur, fFatDrive);
            FreeStr(pszPatternCur);
            pszPatternCur = pszT;
 
        }
 
        //
        // Convert the current pattern into a path and file part
        //
        // Save the current directory in SaveDir, change to new directory
        // and parse pattern into a copy information structure. This also
        // converts pszPatternCur into the current directory which also produces
        // a fully qualified name.
        //
 
        DosErr = 0;
 
        DEBUG((ICGRP, DILVL, "PrintPattern pattern `%ws'", pszPatternCur));
        if ((pcisFile = SetFsSetSaveDir(pszPatternCur)) == (struct cpyinfo *) FAILURE) {
 
            //
            // DosErr is set in SetFs.. from GetLastError
            //
            // BUGBUG map to DIR error code
            //
            PutStdErr(DosErr, NOARGS);
            return( FAILURE );
        }
 
        DEBUG((ICGRP, DILVL, "PrintPattern fullname `%ws'", pcisFile->fnptr));
 
        //
        // CurDrvDir ends in '\' (old code also and a DOT but I do not
        // understand where this would come from I will leave it in for now.
        // Remove the final '\' from a copy of the current directory and
        // print that version out.
        //
 
        mystrcpy(szCurDir,CurDrvDir);
 
        //
        // SetFsSetSaveDir changes directories as a side effect. Since all
        // work will be in fully qualified paths we do not need this. Also
        // since we will change directories for each pattern that is examined
        // we will force the directory back to the original each time.
        //
        // This can not be done until after all use of the current directory
        // is made.
        //
        if (SaveDir) {
            mystrcpy(CurDrvDir,SaveDir);
            SaveDir = NULL;
        }
 
        DEBUG((ICGRP, DILVL, "PrintPattern Current Drive `%ws'", szCurDir));
 
        cbPath = mystrlen(szCurDir);
        //
        // BUGBUG this is BS. it will not work for
        //        dbcs. It is assuming character widths.
        //
        if (cbPath > 3) {
            if (fFatDrive && *penulc(szCurDir) == DOT) {
        	szCurDir[cbPath-2] = NULLC;
            } else {
        	szCurDir[cbPath-1] = NULLC;
            }
        }

This is very interesting code, I wonder if it would even compile on a modern Windows operating system. But when will the Windows `98 source code ever leak? That would be a great find.

\PRIVATE\MAKEFILE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
This is the Windows NT Makefile, this builds the whole project.
all: nt.bsc
!IF "$(BUILDMSG)" != ""
    echo $(BUILDMSG)
!ENDIF
 
nt.bsc:
!IF "$(BROWSER_INFO)" == "yes"
    where /r . *.sbr >sbrfiles
    pwbrmake -o nt.bsc @sbrfiles
    del sbrfiles
 
!ENDIF
 
clean: cleanbsc all
 
cleanbsc:
!IF "$(BROWSER_INFO)" == "yes"
    -erase nt.bsc
 
!ENDIF

I am not sure if I can upload this source code, but I have the whole thing. It is a very interesting find indeed. There is also a collection of icons, the source of MORICONS.DLL. These could be converted to PPM or PNG format to be used as icons on Linux. I can certainly upload those somewhere.

Another good code snippet.

\PRIVATE\SDKTOOLS\MSTEST\NTDLGS\DLL\WCTAPI.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//*-----------------------------------------------------------------------
//| DynAdd
//|
//| PURPOSE:    Adds a control to the dynamic dialog.
//|
//|
//*-----------------------------------------------------------------------
INT FARPUBLIC DynAdd (LPCTLDEF Ctl)
{
        // Make sure the dynamic dialog has been created - if not, tell
        // the user he's an idiot
        //----------------------------------------------------------------
        if (!hDynDialog)
                return ErrorTrap(WCT_NODYNDIALOG);
 
        // Add the user's control to the list - GOTCHA: check to see if
        // the control to be added is the same kind as those already in
        // the list (menu vs. other control info).  This is done by
        // checking the value of fDynMenu -- if TRUE, that means the first
        // control added to the list was a menu type, which means that
        // ONLY menu types can be added from this point on, and vice versa.
        //----------------------------------------------------------------
        if (nDynCount == 0)
            {
                // As above, the first dialog added to the list is a
                // special case - if it can be either menu or some other
                // kind of control - but the fDynMenu flag gets set here
                //--------------------------------------------------------
                if (!lstrcmpi (Ctl->rgClass, "MenuItem"))
                        fDynMenu = TRUE;
                else
                        fDynMenu = FALSE;
            }
        else
            {
                // Here, the class name of the control to be added is
                // checked -- if it is "MenuItem", and fDynMenu is true,
                // then the control can be added, as well as if the class
                // name is NOT "MenuItem" and fDynMenu if false.  If both
                // cases fail, we return WCT_BADCTLTYPE.
                //--------------------------------------------------------
                if (!lstrcmpi (Ctl->rgClass, "MenuItem"))
                        if (!fDynMenu)
                                return ErrorTrap(WCT_BADCTLTYPE);
                        else;
                else
                        if (fDynMenu)
                                return ErrorTrap(WCT_BADCTLTYPE);
            }
 
        // Okay, this is a valid add.  Insert the control and return the
        // success/failure of the add operation.
        //----------------------------------------------------------------
        return ErrorTrap(fAddCtl (hDynDialog, Ctl, &nDynCount));
}

I do wonder how much the coding standards at Microsoft have changed in all this time, considering the many problems plaguing Windows 10. I have seen Windows NT 3.51 in operation, it had the Windows 3.11 interface, and it was running in an office, but this was a very long time ago.

Finally a bit more of the source code.

\PRIVATE\WINDOWS\BASE\SERVER\SRVACCES.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*++
 
Copyright (c) 1990  Microsoft Corporation
 
Module Name:
 
    srvacces.c
 
Abstract:
 
    This file contains the Access Pack support routines
 
Author:
 
    Gregory Wilson (gregoryw) 28-Jul-1993
 
Revision History:
 
--*/
 
#include "basesrv.h"
 
BOOL
InternalSoundSentry(
    UINT uVideoMode
    );
 
BOOL (*_UserSoundSentry)(
    UINT uVideoMode
    ) = InternalSoundSentry;
 
BOOL
InternalSoundSentry(
    UINT uVideoMode
    )
{
    STRING ProcedureName;
    ANSI_STRING DllName;
    UNICODE_STRING DllName_U;
    HANDLE UserServerModuleHandle;
    NTSTATUS Status;
    BOOL (*pfnSoundSentryProc)(UINT) = NULL;
    static BOOL fInit = FALSE;
 
    if (fInit == TRUE) {
 
        //
        // If the real user soundsentry routine cannot be found, deny access
        //
 
        return( FALSE );
        }
 
    fInit = TRUE;
 
    RtlInitAnsiString(&DllName, "winsrv");
    RtlAnsiStringToUnicodeString(&DllName_U, &DllName, TRUE);
    Status = LdrGetDllHandle(
                UNICODE_NULL,
                NULL,
                &DllName_U,
                (PVOID *)&UserServerModuleHandle
                );
 
    RtlFreeUnicodeString(&DllName_U);
 
    if ( NT_SUCCESS(Status) ) {
        RtlInitString(&ProcedureName,"_UserSoundSentry");
        Status = LdrGetProcedureAddress(
                        (PVOID)UserServerModuleHandle,
                        &ProcedureName,
                        0L,
                        (PVOID *)&pfnSoundSentryProc
                        );
 
        if ( NT_SUCCESS(Status) ) {
 
            //
            // We now have the real soundsentry routine
            //
 
            _UserSoundSentry = pfnSoundSentryProc;
            return( _UserSoundSentry( uVideoMode ) );
        }
    }
 
    //
    // Deny access
    //
 
    return( FALSE );
}
 
#ifdef CONSOLESOUNDSENTRY
BOOL
InternalConsoleSoundSentry(
    UINT uVideoMode
    );
 
BOOL (*_ConsoleSoundSentry)(
    UINT uVideoMode
    ) = InternalConsoleSoundSentry;
 
BOOL
InternalConsoleSoundSentry(
    UINT uVideoMode
    )
{
    STRING ProcedureName;
    ANSI_STRING DllName;
    UNICODE_STRING DllName_U;
    HANDLE ConsoleServerModuleHandle;
    NTSTATUS Status;
    BOOL (*pfnSoundSentryProc)(UINT) = NULL;
    static BOOL fConsoleInit = FALSE;
 
    if (fConsoleInit == TRUE) {
 
        //
        // If the real soundsentry routine cannot be found, deny access
        //
 
        return( FALSE );
        }
 
    fConsoleInit = TRUE;
 
    RtlInitAnsiString(&DllName, "winsrv");
    RtlAnsiStringToUnicodeString(&DllName_U, &DllName, TRUE);
    Status = LdrGetDllHandle(
                UNICODE_NULL,
                NULL,
                &DllName_U,
                (PVOID *)&ConsoleServerModuleHandle
                );
 
    RtlFreeUnicodeString(&DllName_U);
 
    if ( NT_SUCCESS(Status) ) {
        RtlInitString(&ProcedureName,"_ConsoleSoundSentry");
        Status = LdrGetProcedureAddress(
                        (PVOID)ConsoleServerModuleHandle,
                        &ProcedureName,
                        0L,
                        (PVOID *)&pfnSoundSentryProc
                        );
 
        if ( NT_SUCCESS(Status) ) {
 
            //
            // We now have the real console soundsentry routine
            //
 
            _ConsoleSoundSentry = pfnSoundSentryProc;
            return( _ConsoleSoundSentry( uVideoMode ) );
        }
    }
 
    //
    // Deny access
    //
 
    return( FALSE );
}
#endif
 
ULONG
BaseSrvSoundSentryNotification(
    IN OUT PCSR_API_MSG m,
    IN OUT PCSR_REPLY_STATUS ReplyStatus
    )
{
    PBASE_SOUNDSENTRY_NOTIFICATION_MSG a =
            (PBASE_SOUNDSENTRY_NOTIFICATION_MSG)&m->u.ApiMessageData;
    BOOL SoundSentryStatus;
 
    //
    // The possible values for a->VideoMode are:
    //     0 : windows mode
    //     1 : full screen mode
    //     2 : full screen graphics mode
    //
    SoundSentryStatus = _UserSoundSentry( a->VideoMode );
 
    if (SoundSentryStatus) {
        return( (ULONG)STATUS_SUCCESS );
    } else {
        return( (ULONG)STATUS_ACCESS_DENIED );
    }
 
    ReplyStatus;    // get rid of unreferenced parameter warning message
}

I hope you find this source code interesting. I am not sure if I can put it all on Github. But time will tell.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.