Coder Social home page Coder Social logo

messagetablereader's Introduction

MessageTableReader

A .Net class to allow access to the message table entries in a .dll or .exe file. This class can be used within PowerShell using Add-Type or compiled into a Windows library (.dll).

Build Status

Installation

First, download the MessageTableReader.cs C# file from this repo.

Method 1

Load the file into a variable in your script by using Get-Content or by pasting it into a here-string.

Import the class by running by running the following, where <variablename> is the name of the variable that you have loaded the C# into.

Add-Type -TypeDefinition <variablename>

Method 2

Import the class directly by running by running the following, where <path> is the path ot the C# file (or dll).

Add-Type -Path <path>

Compiling the .DLL

The C# file can be compiled using the C# complier csc.exe provided as part of the .Net framework. No Visual Studio required. The version of .Net must be 4.0 or greater.

csc.exe /target:library /out:MessageTableReader.dll MessageTableReader.cs

Using the Class

Methods

GetMessageList(string filename)

GetMessageList returns a list of all of the messages and message IDs in a file. If no file name is provided, then C:\WINDOWS\system32\msobjs.dll is used.

Example

PS C:\>$messageTable = New-Object MessageTableReader.Reader
PS C:\>$messageTable.GetMessageList('C:\WINDOWS\system32\msobjs.dll')
279:Undefined Access (no effect) Bit 7
1536:Unused message ID
1537:DELETE
1538:READ_CONTROL
1539:WRITE_DAC
1540:WRITE_OWNER
1541:SYNCHRONIZE
1542:ACCESS_SYS_SEC
1543:MAX_ALLOWED
...

GetMessage(string id, string filename)

GetMessage takes a message ID and file name and returns the text of the specific message in the file. If no file name is provided, then C:\WINDOWS\system32\msobjs.dll is used.

Example

PS C:\>$messageTable = New-Object MessageTableReader.Reader
PS C:\>$messageTable.GetMessage(14676,'C:\WINDOWS\system32\msobjs.dll')
Active Directory Domain Services

What Use is MessageTableReader?

MessageTableReader was originally conceived to help with monitoring and audit of Windows Event Logs. Many event log messages have placeholder codes that need to be looked up from .dll files. MessageTableReader can do this. There's more detail on this in my ebook PowerShell and Windows Event Logs.

Why not just provide a .dll ?

Some organisations are not able to introduce unapproved binary files into their environment (with good reason). The textual C# is an alternative, and the code can be easily scrutinised.

messagetablereader's People

Contributors

wightsci avatar

Stargazers

Ezequiel Haley avatar Eric Chu avatar  avatar  avatar Arioch avatar yk avatar Brian Reitz avatar

Forkers

grumo35

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.