Sitemap

Programming on Windows

5 min readAug 18, 2024

--

  1. Review the Component Object Model in Windows
  2. Learn about the development of the .NET Framework and .NET Core

Developers use the Windows Application Programming Interface (API)1 to create applications that resemble Microsoft applications. They also make it easier to port to different versions of the operating system.

Although Windows is a graphical operating system, underneath it all are various programming interfaces and mechanisms. Let’s take some time to discuss the evolution and modern application of these mechanisms.

Windows command-line applications are differentiated by short (1–3 character) file extensions that dictate the format of the program. While there are many file extensions, the most recognized extensions for compiled, executable code in Windows are .exe and .dll, which designate executable2 and dynamic-link library3 files. Both exe and dll files are part of the portable executable (PE)4 format.

When Windows-based code is compiled, it is stored in a portable executable format. However, it’s important that we discuss the evolution of Windows programming with added security controls, and we’ll do this in the next section.

1(Wikipedia, 2021), https://en.wikipedia.org/wiki/API

2(Wikipedia, 2021), https://en.wikipedia.org/wiki/.exe

3(Wikipedia, 2021), https://en.wikipedia.org/wiki/Dynamic-link_library

4(Microsoft, 2021), https://docs.microsoft.com/en-us/windows/win32/debug/pe-format

Component Object Module (COM)

Windows’ API always used both the language and structure of the C programming language. The C language was ideal due to its access to low-level system resources as well as its widespread adoption among software developers at the time. However, as Windows grew in size and complexity, it became difficult to manage everything in a C-style language. To offset the complications, Microsoft released the Component Object Model (COM).

COM provided a versatility that was compatible with numerous programming languages as a code wrapper.1 Code wrappers can reduce complexity of code without sacrificing the utility of the codebase within them. Users could write C, C++, Visual Basic, and other forms of compiled code that could run in Windows. COM also made interprocess communication more streamlined for the average Windows user’s productivity applications.

Get pinku rajbongshi’s stories in your inbox

Join Medium for free to get updates from this writer.

For example, embedded Excel spreadsheets in Word documents could be updated from Excel, and those changes would be reflected in the embedded object in the Word document. This inter-connectivity of programs is a common user experience of interprocess communication.

As Windows-based computers became networked, the COM was upgraded resulting in the Distributed Component Object Model (DCOM). This addressed new issues between COM objects including memory issues, and formatting issues when data is passed between objects running on two different networked machines. In simple terms, DCOM allows us to open a Word document on a network share as if it were stored on our machine. DCOM also enables us to do the same with executables stored on a file server.

As users began surfing the internet with web browsers, another COM-like framework was introduced in 1996: ActiveX3. This framework provided code wrappers for COM that would enable the execution of code to run within the browser. Rather than requiring another application in Windows to view multimedia, an ActiveX control could play a sound or view a short video. However, the operating system had mismanaged control of ActiveX objects.

ActiveX was designed to have greater execution privileges than the web browser itself, which meant that malicious code hosted on early websites could harm the user’s computer. Because of this, ActiveX controls exist in most web browsers for compatibility purposes but are turned off by default. Microsoft Edge does not support ActiveX while Internet Explorer 11 does, and as of August 31, 2020, support for ActiveX has ended.

The ActiveX framework evolved into .NET as well as .NET Core, which aimed to address shortcomings of ActiveX while enhancing reliability and suitability for applications in an increasingly connected enterprise.

Wrapper_function, https://en.wikipedia.org/wiki/Wrapper_function

.NET and .NET Core

Microsoft began a significant development platform modernization in the early 2000s with the .NET Framework. .NET introduced the new programming languages C#1 and Visual Basic.NET,2 which provide wrappers for the Windows API as well as COM objects within the operating system. The framework also incorporated secure coding mechanisms and can differentiate between locally developed code and Internet-downloaded code. It can also determine whether code execution requires elevated privileges and verify if these privileges have been granted to the application.

These features are a part of the Common Language Runtime (CLR).3

The CLR is a virtual machine4 incorporated within Windows that executes code in a different way than traditionally compiled languages. Code in C# or Visual Basic.NET is translated into bytecode,5 or instructions that can be understood by the CLR. The bytecode inside the CLR is inspected and compiled as needed within the virtual machine, rather than compiled all at once.

Like Java and other compiled languages that make use of a virtual machine, this allows easier and better-protected memory management for applications that are running. Applications are restricted to memory that has been only allocated for them and are unable to read from memory of other processes, including privileged processes. This also means that our user-level software does not have to be rewritten for different operating systems that support the .NET framework. In an enterprise environment with different endpoint devices for end users, any endpoint can run a .NET application without the need for a rebuilt application or a new codebase. The only requirement is that the endpoint support the CLR.

In 2016, a free and open-source successor of the .NET Framework was released to the public. Known as .NET Core,6 this evolution of the framework makes .NET available to other operating systems in the marketplace. Applications written in C# and other supported languages can be compiled and executed in Linux as well as macOS without the use of a compatibility layer. The .NET Core was updated extensively, growing from version 1.0 to 3.1 in 2019 alone. With the release of .NET 5 (without the Core designation), the original .NET Framework and .NET Core have been combined and is now known simply as .NET without any other nomenclature.

In the beginning of this section, we discussed how Microsoft’s pre-existing programming languages can be used to support and develop applications for the Windows operating system. We discussed how COM expanded Windows operability within applications and across networks by wrapping itself around the lower-level languages of Windows such as C. Then we introduced .NET, which serves as a wrapper around COM, adding more security controls and platform compatibility. In the next Learning Unit, we’ll learn about the auditing controls designed for Windows and focus on the security auditing that takes place.

1(Wikipedia, 2021), https://en.wikipedia.org/wiki/C_Sharp_(programming_language)
2(Wikipedia, 2021), https://en.wikipedia.org/wiki/Visual_Basic_.NET
3(Microsoft, 2020), https://docs.microsoft.com/en-us/dotnet/standard/clr
4(Wikipedia, 2021), https://en.wikipedia.org/wiki/Virtual_machine
5(Wikipedia, 2021), https://en.wikipedia.org/wiki/Bytecode
6(Wikipedia, 2021), https://en.wikipedia.org/wiki/.NET

--

--