Discussion about design patterns

  • SpinRite v6.1 Release #3
    The 3rd release of SpinRite v6.1 is published and may be obtained by all SpinRite v6.0 owners at the SpinRite v6.1 Pre-Release page. (SpinRite will shortly be officially updated to v6.1 so this page will be renamed.) The primary new feature, and the reason for this release, was the discovery of memory problems in some systems that were affecting SpinRite's operation. So SpinRite now incorporates a built-in test of the system's memory. For the full story, please see this page in the "Pre-Release Announcements & Feedback" forum.
  • Be sure to checkout “Tips & Tricks”
    Dear Guest Visitor → Once you register and log-in please checkout the “Tips & Tricks” page for some very handy tips!

  • BootAble – FreeDOS boot testing freeware

    To obtain direct, low-level access to a system's mass storage drives, SpinRite runs under a GRC-customized version of FreeDOS which has been modified to add compatibility with all file systems. In order to run SpinRite it must first be possible to boot FreeDOS.

    GRC's “BootAble” freeware allows anyone to easily create BIOS-bootable media in order to workout and confirm the details of getting a machine to boot FreeDOS through a BIOS. Once the means of doing that has been determined, the media created by SpinRite can be booted and run in the same way.

    The participants here, who have taken the time to share their knowledge and experience, their successes and some frustrations with booting their computers into FreeDOS, have created a valuable knowledgebase which will benefit everyone who follows.

    You may click on the image to the right to obtain your own copy of BootAble. Then use the knowledge and experience documented here to boot your computer(s) into FreeDOS. And please do not hesitate to ask questions – nowhere else can better answers be found.

    (You may permanently close this reminder with the 'X' in the upper right.)


Well-known member
Jul 19, 2021
I have a programming question / discussion. It pertains to both object oriented languages and assembly. The idea of it is: do modern operating systems like linux and windows have design patterns. I have recently been digging into the gang of four design patterns. For those not familiar design pattern they are just ways of thinking about how software is built. The first pattern I learn, about six years ago, is called a singleton, the “single” part means that a particular object can be instantiated only once. As only one instance is needed and often a reference to that one object instance is given when the object is needed. The gang of four books groups them into three categorizes: creational, structural and behavioral. I am sure there is a wikipedia. They make a lot of sense to me, especially if one wants to understand new APIs and software that they can not fully familiar with and wrote understandable good code. I guess my basic question is do modern operating system make use of design pattern in roughly the way the gang of four book describes them. I would think that even something like a memory manager or however processes are handled would have patterns. Even the idea of a library that is used dynamically seems like it would be a pattern of some kind, so both linux and windows do that. I am not sure if they can be approximated to gang of four patterns. I was also wondering if Steve thinks in terms of patterns when he codes. I know when I was working on an Angular front end a few years ago, I was studying patterns at home at the same time and when I learned of Observables in Angular/RxJS, I was like hey I think it is named after it’s pattern. I know operating systems are not always object oriented and as an assembly programmer, I am not sure if Steve makes code that could be understood as object oriented. Assembly certainly is not when presented to a beginner.
I know operating systems are not always object oriented and as an assembly programmer, I am not sure if Steve makes code that could be understood as object oriented. Assembly certainly is not when presented to a beginner.
To answer your question: Yes, definitely.

Not all problems to be solved benefit from the slight organizational and structural overhead that an object orientation incurs. But a great many can and do. Some of the best assembly code I've ever written has been highly object oriented. Specifically, the code that runs GRC's DNS Spoofability system:

It's massively parallel, with any number of DNS servers being queried repetitively and with the current query state of each one needing to be maintained separately. So a "job" object exists which represents the user's task and it maintains all of the "state" that's needed for that job.

And that Job object contains a pointer to a linked list of "server" objects. As servers for a user are discovered, memory for a new server object is allocated from the OS and that server object is added to the end of the server object list. So objects are all referred to by reference to pointers to them with their various datums as offsets from those pointers.

A future SpinRite will be 100% multitasking, able to run on all of a machine's drives at once. And the only effective way to pull that off will be to create any number of "drive objects." And since SpinRite is headed toward a "deferred recovery" model, where a first pass scan only performs an analysis before getting down into the job of recovery and maintenance, I'm pretty sure that we'll also have a "trouble spot" object as well. (y)

I LOVE tackling problems that are complex enough to benefit from that sort of organizational structure. The results are SO clean and manageable. (And note that I've also just done this to a lesser degree with SpinRite v6.1's new I/O abstraction design.)
Yes, that is very interesting. I seen on today’s SN the clip from TSS, I guess you have been coding on Windows a long time. I have been more compelled by Linux these days. Why what you posted is interesting is that it starts to answer the questions of how you code, I think people wonder because you speech is so packed with detail. Like when you describe how SQRL works. To honest most of the work I have done that is not mindless debugging old (bad) code is writing restful services in C#. I also just started a spring project to day to try it in Java. I am guessing that you don’t use many libraries or frameworks in MASM assembler. Unless you write your own. I recently did some (cruddy) MASM programming by turning a few C programs to MASM assembly. I’ve always wounder how you code so much in assembly without all the include files. I don’t think what is included for INC files in MASM32 covers everything, even things like COM. Do you just use Vs for debugging when coding Win32? I had the best luck with OllyDbg. People on MASM32 have pointed me to projects on GitHub that provide more support for windows assembler. I am not sure how a person would reverse the INC files from headers from the Windows SDK. I have considered trying to code assembly projects in Linux. As a C# developer I am depended on frameworks like WebAPI and MVC and other nuget libraries. That is what the architects and project managers want and it seems like that is where the money is for someone at my skill level. And I have to say that the good architects turn the project into something that is very easy to code in. There are programmers that are just to lazy and managers that are to volatile. I imagine the same when switching to Java.

Anyway, I don’t know how to code restful services in Windows MASM or Linux and google didn’t turn up much. I think this is the OO library someone recommend for assembly https://github.com/nidud/asmc And when will we see some code on your GitHub? I’ve got SIB. Lol, thanks Steve.

I’ve always wonder how you code so much in assembly without all the include files. I don’t think what is included for INC files in MASM32 covers everything, even things like COM.
I've just been patiently building them up through the years. I'll use H2INC to perform a basic conversion into INC files. But then as I need a definition that I don't yet have in my own "standard.inc" file I'll copy just the line from, for example, the windows.inc that H2INC created. So, over time, everything I actually use is in my own custom .INC file and it doesn't contain all the nonsense that I've never used or needed.
  • Like
Reactions: Barry Wallis
Do you just use Vs for debugging when coding Win32?
Yes. After my move from 32-bit WinXP to 64-bit Win7, its lack of support for 16-bit DOS apps forced me to abandon my beloved BRIEF text editor, which I'd been using for 30 years. Now I'm using Visual Studio for both editing and for debugging Win32 code. But I've remapped Alt-A (for assemble) to invoke my own MAKEFILE which performs the project build process.
  • Like
Reactions: Barry Wallis
Anyway, I don’t know how to code restful services in Windows MASM or Linux and google didn’t turn up much.
Well... A RESTful service is just a service that answers incoming HTTP queries, right? So you start with a simple connection-handling TCP server, which is easily written, either at the lowest level by using the Windows Sockets (Winsock) API, or these days more sanely by using the higher level WinHTTP API.

It's worth noting that, as I've written in the past, MASM on Win32 is really mostly a scripting language for the Win32 API. So the knowledge of the various Windows APIs is the key... Then you call them with whatever glue language you're comfortable using.
  • Like
Reactions: Barry Wallis
That’s really cool. I did find the H2INC when I ran into problems with not being able to find things that were available in c and c++ samples from the windows sdk. I tried to convert all of them but that obviously didn’t work. I was using the Windows 7 SDK. You must have started with the VS6 headers when you were converting. Maybe I would have better luck with that? I have a XP vm. I converted a C program from the Programming Windows book into assembler. I picked a particular Program because when looking at the source I didn’t think it would be that hard to convert. I eventually got it to work, but its not really good looking code. When you debug in visual studio do you have the ability to put break points on you own original asm files? When I debug with Vs 2008 or 2015, I get the disassembly of the final exe when debugging, which is little different than one original code. I am not sure why because when I use OllyDbg as long as I have the pdb symbol files generated it will show the original source in the debugger.

The problem I have with both OllyDbg and Visual Studio is I am unsure how to get either global values from the data segment and variables that are created by way of the LOCAL directive. I also don’t really understand OFFSET, MS docs says it is the offset of the relevant segment. I though the only segments in 32bit flat mode were like the stack, data and code segments. Where is the stack is defaulted to 1mb and data could/would be determined what is defined in it and the code would be the rest of a processes 4gb virtual memory. Am I way off? I was thinking that 16bit programs (like spinrite and others) one needs to more concern with segments? And that was the difference between com files and exe files, the 64k limit. Where as the flat is just 4294967296 bits of virtual memory?

I guess I could try writing a simple HTTP server, you just said it was easily done. :). Maybe start with WinSock (hardway). Are you referring to this for the WinHTTP API:


Man I am going to have to get off my Linux laptop and get on Windows/MASM. :).
Well this is just a simple open comment and people can response if they want, some of you are likely way ahead of me on somethings. I did find some information on WinHTTP api on msdn and I copied their code example and run it with a debugger several times. It was a learning experience. I think I understand what people have mean by win32 being mostly scripting, with this WinHTTP api it needs to be initialized to get the internal state correct. I have to say, this was not that hard to grasp in C++ as a two and half hour thing. I ran dumpbin on httpapi.dll and I found 37 functions, So I am guessing that means that WinHTTP API really has just 37 functions. So I don’t know if any of you feel as I do that it is import to grasp os internals and concepts to be more effective, in my career to date that has not been strictly required.

I thought the last SN was interesting but as it happens I was reading somethings about compilers, the dragon book, although I only got to the second chapter. I also recent purchased Pavel Yosifovich’s 3rd book Windows 10 System Programming part two in PDF form, but it didn’t have WinSock stuff in it. I have not work though his books in slow careful form yet, but I still recommend them for people interested os/windows programming. I am also thinking that an OS book more like a college text book might be good for os concepts. At this time I am not working and I live in a very rural location. In a short time I will be looking for remote work, so in the mean time if anyone wants to talk about programming or internal of linux or windows I am for it (Star Trek too, loved Picard, awesome), it really does not seem that hard but I imagine a very large API with windows and linux probably too. Assembly seems to be is a little more that I can handle with my current situation, I got my hands in to so many subjects, and I am currently reading three books.

Here are both links