Archive for the ‘Programming’ Category

My journey with ioctl() on Linux

Wednesday, October 10th, 2007

Background

Lately, I’ve been working on an application that heavily uses the ioctl() function for different settings with hardware devices (get/set NIC config – IP, subnet, broadcast, MTU, etc.). This function is so versatile and has so many different uses, that it can be difficult at times to understand what exactly is needed for it to work properly. (more…)

Interaction of stdout buffering using standard stdio.h functions when using pthreads

Thursday, September 27th, 2007

I’ve been working on a project recently that stretched my C programming ability (yes, I’ve been learning quite a bit — especially since I’d never really tackled any significant programming on Linux prior to this).  The app is multithreaded, using the pthreads library.

I ran into a situation where I had multiple threads executing simultaneously, but the text output wasn’t being displayed. (more…)

NT/2000 Event Log Archiver & Viewing System

Wednesday, February 23rd, 2005

OBSELENCE NOTE: This was written well over a year ago, so may be outdated (ie. may have broken links — if so, let me know and I’ll update).  Just because it’s old doesn’t mean that it’s not worth sharing!

Summary:

There are lots of products out there that allow you to remotely view your NT/2000-based event logs.  Not many of these allow for an archival and later viewing of these events.  If you look for something free, it really narrows the field down — so I wrote a program that would archive NT/2000 event logs to a SQL database.

After I had them archived, I noticed that my SQL database was really filling up fast.  I decided to code the ability to export certain events from the SQL DB to an XML file, allowing the file to be burned to a CD/DVD for archival.

Well, now I’ve got a 600MB XML file, and no way to view it.  Naturally, I wrote a program that would view and print the XML file as if you were looking directly at the NT/2000 event log itself.

Obviously there are several pieces to the big picture:

  1. The archiver (reads event log entries – stores them in the SQL DB – exports events to XML file).
  2. The viewer (reads XML file for viewing/printing).
  3. The SQL DB (plan on having a lot of space taken up by these logs).

NOTE: You need to have the MS XML parser installed on the machine that you run any of the first two above programs on to have them work.  If you’re looking for the MS XML Parser 4.0 SP2, go to http://www.microsoft.com/downloads/details.aspx?FamilyID=3144b72b-b4f2-46da-b4b6-c5d7485f2b42&displaylang=en.

(more…)

x86 Kernel (32-bit protected-mode)

Wednesday, February 23rd, 2005

OBSELENCE NOTE: This was written well over a year ago, so may be outdated (ie. may have broken links — if so, let me know and I’ll update).  Just because it’s old doesn’t mean that it’s not worth sharing!

Summary:

Kernel design can be overwhelming.  Fortunately, there are lots of resources available (just hard to find at times).  Using IRC, UseNet, the Internet and written books, it is possible to learn quite a bit about OS design and development as well as writing your own.

This kernel operates in protected-mode (must already be in protected-mode — accomplished via boot loader — look at Boot Loader (32-bit protected-mode) for an example of such a boot loader).

It loads the Global Descriptor Table (GDT), IDT & provides a basic/buggy text output routines & keyboard driver (interrupt-driven).  Note that it’s not complete, comes with no guarantees.

One book that’s an excellent resource on OS theory is Modern Operating Systems by Andrew S. Tanenbaum (published by Prentice Hall).  See below for links to UseNet groups, IRC channels & websites that I’ve found helpful.

(more…)

Flash XML Sub Menu

Tuesday, February 15th, 2005

After creating the Flash XML Menu, I found that I wanted a dynamic sub-menu Flash movie that would display underneath it (it’s laborious having to create and maintain static Flash sub menus).  This Flash Sub Menu, like my Flash XML Menu, creates the menu based off of the values read in the input XML file that it’s given.

(more…)

Boot Loader (32-bit protected-mode)

Tuesday, February 8th, 2005

OBSELENCE NOTE: This was written several years ago, so may be outdated (ie. may have broken links — if so, let me know and I’ll update).  Just because it’s old doesn’t mean that it’s not worth sharing!

Summary:

After a successful basic boot loader that boots up to 16-bit real-mode, I wanted to see what the world or protected-mode (PM) was all about!   So, I delved into it — and became confused.  Fortunately, there are lots of resources out there (check out the links below for several of them).  This boot loader fits into 512 bytes, but enters protected-mode (PM is 32-bit on the x86 platform).

This boot loader does the following:

  • Enables the A20 line (so that all of the memory is available).
  • Loads the Global Descriptor Table (GDT).
  • Enters Protected-Mode (PM).
  • Parses the FAT12 directory structure to look for and load into memory BOOTNEXT.SYS.
  • Executes (transfers control) to BOOTNEXT.SYS (currently this is a flat binary file).

After getting the boot loader working right, I delved into kernel design.  That can be overwhelming (to say the least).  Anyhow, take a look at the 32-bit protected-mode kernel if you’re wanting to see working interrupts in PM, a simple keyboard driver (protected-mode doesn’t allow use of the BIOS).

(more…)

16-bit (real-mode) Boot Loader

Tuesday, February 8th, 2005

OBSELENCE NOTE: This was written over a year ago, so may be outdated (ie. may have broken links — if so, let me know and I’ll update).  Just because it’s old doesn’t mean that it’s not worth sharing!

Background

I’ve been wanting for some time to figure out how the bootup process works and how to write a boot loader!  I’ve finally figured out the basics of how it works — kind of an art in itself once you begin to understand everything that has to go on in a 512-byte program (less than 512-bytes are actually usable for program code).

This boot loader does the following:

  • Parses the FAT12 directory structure to look for and load into memory BOOTNEXT.SYS.
  • Executes (transfers control) to BOOTNEXT.SYS (currently this is a flat binary file).

The file bootnext.asm is a simple “kernel” file that pretty much just says hello, proves that the boot loader did it’s job, etc.

One of the sample “kernels” (files that can be copied to your floppy drive as BOOTNEXT.SYS) is called bootn3.asm.  This simple “kernel” (if you want to call it that) shows how to configure interrupts in real-mode (modify the Interrupt Vector Table (IVT)).

(more…)

Flash XML Menu

Tuesday, February 8th, 2005

I’ve been needing a quick and simple dynamic menu for some web projects.  I wasn’t finding much, so I decided to make a Flash-based menu.  I liked the way the menu worked on Macromedia’s website, so I fashioned this menu after the menu found on www.macromedia.com.

(more…)

Online Requisition System (ORS)

Thursday, January 13th, 2005

OBSELENCE NOTE: This was written well over a year ago, so may be outdated (ie. may have broken links — if so, let me know and I’ll update).  Just because it’s old doesn’t mean that it’s not worth sharing!

Summary:

THIS PAGE IS UNDER CONSTRUCTION AND MAY BE INCOMPLETE

This is a requisition and PO management system that I built.  The ORS interfaces with Meditech’s data repository (DR) to provide accurate shipping and status from the Meditech system itself (assuming that your site has Materials Management (MM)).  The system could still be used if you don’t have Meditech, but quite a bit of the code would have to be modified (it was originally designed to tightly integrate with Meditech).

Each user is authenticated against a Windows NT/2000 domain.  Group permission can be setup by the NT group that the user is a member of (mapping NT groups to the appropriate ORS groups requires a manual initial mapping).  There are system-wide limits for how much can be ordered without a super-user’s signature, etc.

Another added bonus for this system is the digital signature component’s integration with digital tablets.  I chose to use the ePad tablets (when originally designed, the only ePad tablets around were serial-based — you could probably get by using the USB just as easily).  The only catch is that the proper Windows drivers must be configured on the workstation that has the ePad for the digital signature piece to work properly (digital signatures need only be received from super-users — people who approve purchases over set limits within the system).

For more info, read over the docs below (go to the downloads section below).

(more…)

Windows 2000/2003 Directory Services Audit Logging Management Utility

Thursday, January 13th, 2005

Summary:

There’s a way to get very detailed event logging features for core Active Directory services.  Unfortunately, there’s no GUI for doing this — you have to dig in the registry to do it.  This can be cumbersome if you’ve got a list of servers to monitor/diagnose.  This tools allows you to specify a server, select which Active Directory service to log and what logging level it should be set at.

See http://support.microsoft.com/default.aspx?scid=kb;en-us;314980&sd=tech for more information on the registry keys and values.

(more…)