How to Fix Errors with the PowerShell WebAdministration Module

Windows PowershellThe PowerShell WebAdministration module can be finicky. If you’re seeing COMException error messages, here are a few things you could try.

WebAdministration Errors

If you import the module using the 32-bit version of PowerShell, you might see the following.

PS > Import-Module WebAdministration
PS > Get-Website
Get-Website : Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed
  due to the following error: 80040154.
At line:1 char:12
+ Get-Website < <<<
    + CategoryInfo          : NotSpecified: (:) [Get-Website], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.IIs.PowerShell.Provider.GetWebsite
   Command

If you import the module using the 64-bit version of PowerShell, you might see this error.

PS > Import-Module WebAdministration
PS > Get-Website
format-default : Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
    + CategoryInfo          : NotSpecified: (:) [format-default], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.FormatDefaultCommand

Continue reading

Installing MASM

EditWell, after all this assembly programming and debugging in gdb, I think it’s time to try some assembly in Windows. I’ll start by downloading and installing MASM. It’s incredibly easy, but I’m posting because I’m excited to try some Windows assembly. :)

Continue reading

How to fix Error: suffix or operands invalid for ‘push’ or ‘pop’

TerminalIf you compile a 32-bit assembly program (or a C program that contains assembly instructions) on a 64-bit machine you may see the following error:

# as -o example32bit.o example32bit.s
example32bit.s: Assembler messages:
example32bit.s:10: Error: suffix or operands invalid for `pop'

To fix this problem you need to pass the compiler or assembler a flag telling it you want to compile the software as 32-bit and not 64-bit.

The fix for C: Compiling with the -m32 flag

If you’re using gcc to compile a C program, pass in -m32. There’s a complete example here on my blog.

The fix for assembly: Compiling with the –32 flag

If you’re using as to compile an assembly program, pass in –32. Then when you link with ld pass in -m elf_i386. There’s a complete example here on my blog.

Happy hacking!

How to Compile 32-bit Assembly Programs on a 64-bit PC in Linux

TerminalSpeaking of compiling 32-bit C programs, what about assembly language programs? Assembly varies considerably between machines as well, so it would be useful to know how to compile x86-32 software when you’re on x86-64. It’s relatively easy, so I’ll demonstrate the commands!

Compiling with the –32 flag

To compile 32-bit assembly programs with as you pass the –32 flag (found this under Target i386 options on the as man page). It’s pretty straight forward:

# as --32 -o example32bit.o example32bit.s

Linking using the -m flag

You’re not done yet! You still need to link the program and if you just tried that now you probably saw this:

# ld -o example32bit example32bit.o
ld: i386 architecture of input file `example32bit.o' is incompatible with i386:x86-64 output

Jeez ld! What’s your problem?

Well, the linker needs to know the architecture as well. Try passing -m elf_i386 so ld will calm down a bit. :)

# ld -m elf_i386 -o example32bit example32bit.o

Finished!

Your program should run now.

How to Compile 32-bit C Programs on a 64-bit PC in Linux

TerminalI’ve been writing a lot of articles recently about compiling C and assembly programs on my 64-bit machine. But eventually I needed to compile a 32-bit program and I thought I would explain how I did that in case anyone else runs into trouble.

Using the -m32 flag

To compile a 32-bit program with gcc you can just use the m32 flag (which you’ll find under i386 and x86-64 Options on the gcc man page). But if you’re on a 64-bit machine, don’t be surprised if you see something like this:

# gcc -m32 -o example32bit example32bit.c
In file included from /usr/include/features.h:378,
                 from /usr/include/stdio.h:28,
                 from example32bit.c:1:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory

Installing the 32-bit glibc headers

You see that because you don’t have the 32-bit glibc headers installed. That’s not a problem though, since most package managers should have them available for installation. If you’re on a Debian or Ubuntu machine you can install them like this:

# apt-get install gcc-multilib

Look ma, no compiler errors!

# gcc -m32 -o example32bit example32bit.c
#

Tada!