My Alpha NT Devlog
#11
RE: My Alpha NT Devlog
I wouldn't mind, if there's somewhere to upload it too.

I searched and I couldn't find cygwin in this collection either!
Irinikus
Hardware Connoisseur

Trade Count: (0)
Posts: 3,475
Threads: 319
Joined: Dec 2017
Location: South Africa
Website Find Reply
04-11-2020, 01:52 PM
#12
RE: My Alpha NT Devlog
that's what I have:

9.4M 20 Jun 2010 cygnus10.zip
5.9M 20 Jun 2010 cygwin-20000108src.zip
1.6M 20 Jun 2010 cygwin-inst20000108.zip
108B 20 Jun 2010 cygwin-update.zip
2.9M 20 Jun 2010 cygwin-user10.zip
21M 20 Jun 2010 gcc-alpha-b19-src.tar.gz
9.8M 20 Jun 2010 gcc-alpha-b19.zip
12M 20 Jun 2010 gcc281.zip
lunatic
insane in the mainframe

Trade Count: (0)
Posts: 150
Threads: 1
Joined: Apr 2019
Find Reply
04-11-2020, 04:24 PM
#13
RE: My Alpha NT Devlog
You could probably just toss it all up on archive.org. I'd love to have that as well.

Computers: Amiga 1200, DEC VAXStation 4000/60, DEC MicroPDP-11/73
Synthesizers: Roland JX-10/SH-09/MT-32/D-50, Yamaha DX7-II/V50/TX7/TG33/FB-01, Korg MS-20 Mini/ARP Odyssey/DW-8000/X5DR, Ensoniq SQ-80, E-mu Proteus/2, Nord Lead 2, Behringer Model D
commodorejohn
PDP-X

Trade Count: (0)
Posts: 367
Threads: 7
Joined: May 2018
Find Reply
04-11-2020, 05:28 PM
#14
RE: My Alpha NT Devlog
I just noticed that one of the files is just a 404 error message from the web server saved as a .zip.
If anybody of you can test these things and can document how to turn this into a working distribution, please let me know. Maybe it is even possible to build a more recent version of cygwin with those files as a starting point.

My own experience with NT on Alpha wasn't all that great. Sure, it works, but the overall lack of applications is annoying. FX32 isn't bad, but then you could only run some old Win32 software as long as the software is fully 32bit NT clean.
You can have a similar experience with Windows XP or Windows Server 2003 on Itanium. Just faster und with more compatible x86 software.

Good luck!
lunatic
insane in the mainframe

Trade Count: (0)
Posts: 150
Threads: 1
Joined: Apr 2019
Find Reply
04-11-2020, 08:47 PM
#15
RE: My Alpha NT Devlog
Ok, time for the first post with meat!

So, we installed Windows NT 4.0 on our machine. A nice and stable operating system. But, when being used to UNIX systems, one thing is particularly anoying: The shell, or the command processor (in Microsoft lingo). I guess it was because Windows was supposed to be an end user operating system, this important piece of software got little love before the PowerShell age. Though the NT version ('cmd'exe') improved a little over its DOS predecessor (the infamous 'command.com'), it is still far behind even the oldest korn shell you can remember.

It is so not surprising that I started improving the command line user experience right after installation. And boy, there is a lot to improve!

Let's start with auto completion: Nothing speeds up the command line user more than auto completion. I really cannot imagine why, of all features, Microsoft didn't enable this by default. This feauture was there all the years, stable and performant, but it remained disabled by default until Windows XP! But since it is already there, we can enable it by setting the DWORD regeistry value

Code:
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar to 9 (decimal)


to enable completion with the TAB key. Oh, how everything feels so much more familiar with this little change! For convenience, I put a .reg file 'CmdAutoCompletion.reg' in the attached tar.gz archive. Just double-click it, and you're set.

So, now that we have fixed this, the next nuisance is the fact that we can not simply switch to another drive by a 'cd' command. Well, too bad, that can't be helped, so better get used to it. But fear not, another registry hack comes to the rescue: Since most of the time this happened to me when I'm opening a default command prompt and wanted it to be in a directory on another drive, I just copied the Windows 10 'Create command prompt here' Explorer extension. That succer puts an entry into the context menu of folders in Windows Explorer. I'll spare you the details, but again, conveniently find 'CmdHereShellExtension.reg' in the tar.gz. Be aware, however, that you will have to taylor the path of 'cmd.exe' to fit your installation. I experimented with the '%SystemRoot% environment variable, but only to find out that Explorer does no variable expansion here. And though it will use the search path, relying on this will lead to unpleasent results, since all paths are given in the good old 8.3, short name 'Progra~1' convention in that case. If you hard-code the path to 'cmd.exe' file, however, long filenames work fine. So just adapt the .reg file with your editor (Notepad, if it can't be helped) before importing it into your registry.

And while we're at it, it would be great - especially when setting up environment variables - to be able to copy a path right out of the Explorer window. Turns out that this feature is missing, however. But here, the C compiler and our L337 programming skills come in handy: I hacked a little tool 'c2c' (short form of 'copy to clipboard') that will handle this situation. By default, it will copy the current directory to the clipboard, when invoked without parameters, so it is even helpful to the humble command line warrior. Copy 'c2c.exe' into your System32 directory, and (again, with a tweaked full path) double-click 'C2CShellExtension.reg'. Now you can copy any path to the clipboard and continue from there.

The last goody in that tar.gz file is 'which.exe'. Although there are some POSIX tools in the Resource Kit, 'which' is missing. My version searches the usual supects in your environment for an executable file matching the parameter. Think of 'which cl' to find the install directory of your C compiler. You'll get best results when it is copied into your 'System32' directory. Having said that, install those POSIX exe's from the ResKit, and you'll feel much more at home.

Hey, suddenly, we have a usable command line interface for our NT box! Pretty cool, eh? And you know what's the best part? Everything here will come with source code! So even if you just read through all of this in envy because your VW 320 is still running on Intel processors, you can just compile the crap yourself with minimal effort. You probably will have to create some Intel configurations, though. But if you run into trouble, I'll assist you.

Ok, enough for today!

Next time, we'll try to bridge the gap between Windows NT 4 and and Windows 2000! Stay tuned!


Attached Files
.gz CommandPrompt.tar.gz Size: 64.03 KB  Downloads: 296

"The early bird gets the worm, but the second mouse gets the cheese!"

SGI: Octane MXE, O2, Fuel (defunct), VW320 (defunct)
DEC: PC164, PC164SX, AXPpci
sgt_barnes
Octane

Trade Count: (0)
Posts: 101
Threads: 1
Joined: Mar 2019
Location: Germany
Find Reply
04-16-2020, 09:40 PM
#16
RE: My Alpha NT Devlog
There, and back again -  Part I
-------------------------------

Let me start this 3-article series with a quote:

'We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.' --T.S. Elliot

I will not go so far as to claim that I came to the end of all exploration, far from that. But the tool I'm describing here had a long journey from the late nineties to present-day. And not only was I not able to pull this off back then when I started, but it turns out now that I never stood a chance!

But back to topic. Remember that I promised to "bridge the gap between Windows 2000 and Windows NT 4.0"? Well, if you expected to perfectly run DirectX games, or to get real PnP, I'll have to disappoint you. Those things are still way over my head.

But if I had to select just one feature of Win2k to be present on NT4, I know what I'd choose: It's 'runas'.

Uhm, you say, wasn't NT designed as a multi-user OS from the get-go? Ha, yes, but not until Windows 2000 did Microsoft allow you to run programs under multiple accounts in the same session! A thing that was common on UNIX for decades was just not there in NT before 2k! Oh, you say, then how did you devlop stuff that would require root privileges? Oh, well, you'd log in as Administrator and... Madness, you say? Well, I guess, those where happy times back then... At least for crackers.

So the question was: would it be possible to write a 'runas'-like utility on NT4? The answer is a resounding yes, and it's been done many times. For example in the NT Resource Kit, there was a utility called 'SU.EXE' [1], that would do just that. But with some twists: First of all, the Micrososft of old did not bother to publish source code. It was probably too convoluted, anyway. And second, it would only allow you to run a process in another user's security context if the account you worked with had been granted some pretty nasty privileges (e.g. 'Act as part of the operating system'). That was not exactly what I was looking for. So this utility can only serve as proove that it *IS* possible to do this, but nothing more. And, of course, I didn't have access to the resource kit, anyway.

At university, however, I had access to MSDN documentation. Must have been around summer 1998. I had stumbled upon an interesting system call, 'LogonUser'. The docs stated that the handle returned by this API was suitable to 'create a process running in the context of the specified user', by leveraging an API named 'CreateProcessAsUser'! Oh, what a joy!

Disillusion came when I discovered that not even Administrator was allowed to call those functions. Writing a Win32 service didn't occur to me, so that was the end of it. At least temporarily. And I found out later that these two calls weren't nearly enough, and that the additional functions needed (implemented in 'userenv.dll') where not part of the documented Win32 API until the advent of the Windows 2000 SDK somewhere in the fall of '99...

With Windows 2000, however, my interest rekindled. I wanted something like 'runas' on NT4! And with the new enthusiasm came the 'service' idea, and an article (which sadly I can't find any more) that described in detail the importance of calling 'ImpersonateLoggedOnUser' before calling 'CreateProcessAsUser'. Actually, one could just skip the 'As User' part, and call the much more straightforward 'CreateProcess', if one impersonated the requested user first. The downside of this, of course, is, that 'CreateProcessAsUser' allows to supply an 'environment block', which was needed to get the correct environment of the user profile. That could be achieved by 'LoadUserProfile', followed by 'CreateEnvironmentBlock'.

So, we have a happy quintet of system calls: 'LogonUser', 'LoadUserProfile', 'CreateEnvironmentBlock', and finally 'CreateProcessAsUser'. That should do the trick. So, I set out to implement a service, and a communication channel (named pipe), and an ordinary, user-callable command line executable as front end.

I was halfway there, when in 2004, my VW320 died, and to this day never came up again. Thus went my last NT4 machine, and with it the justification to create something like this in the first place. For a second time, the project grinded to a halt, and dust settled on the old hard drives.

Years later, I finally found a working NT compiler for my DEC Alpha box, and I was once again hooked to the old mission. With years of experience in the trenches of Windows development, and the whole internet (and in particular, stackoverflow.com) at our disposal, it should be easy to get this up and running, right?

Sadly, not many people care about NT4 any more, and much of the usefull content of old has been lost to the mists of time. Like the MSDN Magazine, or Microsoft Systems Journal, as it was called in the nineties. One would have to dig through the internet archive to find information on these arcane techniques.

Nevertheless, I pulled the harddrive from the dead 320, and dragged my old source code over to the Alpha and went to work. I even came across a utility on codeguru.com, runasv [2], that I could use as a blueprint! Because it came with source code! And that code compiled and ran on the Alpha!

Why I didn't call off the search at this point and just use this tool? Well, though it actually worked, it didn't do so without quirks. For example, it didn't bother to call the impersonation and profile APIs, but just called 'LogonUser' and 'CreateProcessAsUser'. As expected, this resulted in a 'cmd.exe' runas'd as Administrator in not having that user's environment or HKEY_CURRENT_USER registry hive. It just had Administrator's security context. And communication between command line interface and service was established using an unencrypted TCP/IP channel. Don't get me wrong, I'm using a machine that didn't get a single security update in two decades, so speaking of security appears somehwat hypocritical. But blasting unencrypted passwords over the network still is a no-go for me.

If this sounds overly critical, however, I assure you that this is not my intention. I rather find the code very interesting and of high quality. And, to be fair, the tool probably did exactly what it's developer intended, and documentation on this process was not exactly spread far and wide. And by providing source code, he helped teremendously in development of my own service on the Alpha, because I could now install, start, stop and remove my creations while being logged in with my unprivileged user account. So the trophy for most valuable support doesn't go to some dusty, old MSJ article, but to Jesz de la Vega and his 'runasv'. Thank you, man, I owe you a beer!

But I could do better, I was sure.

And now I finally had all the pieces together to formulate a plan:

A win32 service (which runs under 'system' account) waits on a named pipe, and when a request comes in, calls 'LogonUser' to get a user handle, followed by 'LoadUserProfile' to load the profile, then go on and create the env block with 'CreateEnvironmentBlock', then 'ImpersonateLoggedOnUser', and last but not least 'CreateProcessAsUser'. And the user gets an elevated command promt, provided that he did enter the correct password. And when everything compiles and links, use 'runasv' to launch the service.

Looking back from where I am now, that sounds too easy. What I failed to recognize, for example, was that getting helpful information 20 years after the demise of the involved systems (hardware and software) proved to be harder than I thought.

But let's save that story - and my encounter with the NT security API - for another post!

Dear Reader, thank you for staying with me through this text-heavy post. Part II will come with source code and executables, I promise!

References:

[1] "SU.EXE, a utility included with the Windows NT Resource Kit", Scott Field, 1996
[2] "Special runas Utility for Windows NT and Windows 2000", Jesz de la Vega, 2003

"The early bird gets the worm, but the second mouse gets the cheese!"

SGI: Octane MXE, O2, Fuel (defunct), VW320 (defunct)
DEC: PC164, PC164SX, AXPpci
(This post was last modified: 05-31-2020, 01:34 PM by sgt_barnes.)
sgt_barnes
Octane

Trade Count: (0)
Posts: 101
Threads: 1
Joined: Mar 2019
Location: Germany
Find Reply
05-31-2020, 01:31 PM
#17
RE: My Alpha NT Devlog
(04-11-2020, 01:46 PM)Irinikus Wrote:  I downloaded that entire FTP and have it on my Mac. (It's 3.87GB)

[Image: mWTzbIg.png]


Seems your archive from alphant dump is much bigger that the one that is on archive.org (alphant).

This is the zip from archive.org uncompressed:
[Image: Screen-Shot-2021-07-23-at-12-02-11-AM.png]

Please if you wish and is possible for you to upload your archive somewhere ?.
Cool
soviet
Octane

Trade Count: (0)
Posts: 192
Threads: 22
Joined: Apr 2019
Location: Uruguay
Find Reply
07-23-2021, 03:10 AM
#18
RE: My Alpha NT Devlog
(05-31-2020, 01:31 PM)sgt_barnes Wrote:  There, and back again -  Part I
-------------------------------

Let me start this 3-article series with a quote:

[...]
Sorry for reviving that thread, but is there any chance for a continuation of that series? I find it rather interesting, in addition the possibility to replay your adventure on one of my Alphas one day sounds like a lot of fun. Smile

Indigo Indy Indigo2 R10000/IMPACT O2 Octane Octane2 Origin 200=Origin 200-Origin 200=Origin 200
johnnym
Tezro

Trade Count: (0)
Posts: 268
Threads: 9
Joined: Jun 2018
Find Reply
10-23-2022, 07:04 PM
#19
RE: My Alpha NT Devlog
Hey, Johnnym,

Thank you for your interest!

I have two more posts for the series on the shelves, but unfortunately real live got in the way!

I promise to continue this as soon as I find the time!

And, of course, there will be source code! ;-)

"The early bird gets the worm, but the second mouse gets the cheese!"

SGI: Octane MXE, O2, Fuel (defunct), VW320 (defunct)
DEC: PC164, PC164SX, AXPpci
(This post was last modified: 10-24-2022, 06:26 AM by sgt_barnes.)
sgt_barnes
Octane

Trade Count: (0)
Posts: 101
Threads: 1
Joined: Mar 2019
Location: Germany
Find Reply
10-24-2022, 06:25 AM
#20
RE: My Alpha NT Devlog
Great to hear! Looking forward to the publication.

Indigo Indy Indigo2 R10000/IMPACT O2 Octane Octane2 Origin 200=Origin 200-Origin 200=Origin 200
johnnym
Tezro

Trade Count: (0)
Posts: 268
Threads: 9
Joined: Jun 2018
Find Reply
10-24-2022, 12:33 PM


Forum Jump:


Users browsing this thread: 1 Guest(s)