Skip to content

Commit

Permalink
Fixed Edge Test Cases
Browse files Browse the repository at this point in the history
Updated Documentation
  • Loading branch information
enusbaum committed Feb 25, 2018
1 parent bd38def commit 94b8990
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 54 deletions.
6 changes: 3 additions & 3 deletions MBBSDASM/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ static void Main(string[] args)
//Only label Imports if Analysis is off, because Analysis does much more in-depth labeling
if (!bAnalysis)
{
foreach(var b in d.BranchToRecords.Where(x=> x.IsRelocation && (x.BranchType == EnumBranchType.CallImport || x.BranchType == EnumBranchType.SegAddrImport)))
d.Comments.Add($"{(b.BranchType == EnumBranchType.CallImport ? "call" : "SEG ADDR of" )} {inputFile.ImportedNameTable.First(x => x.Ordinal == b.Segment).Name}.Ord({b.Offset:X4}h)");
foreach(var b in d.BranchToRecords?.Where(x=> x.IsRelocation && (x.BranchType == EnumBranchType.CallImport || x.BranchType == EnumBranchType.SegAddrImport)))
d.Comments.Add($"{(b.BranchType == EnumBranchType.CallImport ? "call" : "SEG ADDR of" )} {inputFile.ImportedNameTable.FirstOrDefault(x => x.Ordinal == b.Segment)?.Name}.Ord({b.Offset:X4}h)");
}

var sOutputLine = $"{d.Disassembly.Offset + s.Offset:X8}h:{s.Ordinal:0000}.{d.Disassembly.Offset:X4}h {BitConverter.ToString(d.Disassembly.Bytes).Replace("-", string.Empty).PadRight(_MAX_INSTRUCTION_LENGTH, ' ')} {d.Disassembly}";
Expand Down Expand Up @@ -240,7 +240,7 @@ static void Main(string[] args)
Console.WriteLine($"{DateTime.Now} Writing Strings Output");

foreach (var seg in inputFile.SegmentTable.Where(x =>
x.Flags.Contains(EnumSegmentFlags.Data) && x.StringRecords.Count > 0))
x.Flags.Contains(EnumSegmentFlags.Data) && x.StringRecords?.Count > 0))
{
output.AppendLine(";-------------------------------------------");
output.AppendLine($"; Start of Data for Segment {seg.Ordinal}");
Expand Down
107 changes: 56 additions & 51 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,30 @@ For more information on The Major BBS and Worldgroup by GALACTICOMM, check out t

While **MBBSDASM** targets Major BBS/Worldgroup files for analysis, any 16-bit NE EXE/DLL file is supported and should disassemble without issue. I've tested this with both Solitaire and Calculator from Windows 3.1 to verify.

# Example Command Line
```
-i c:\bbsv6\example.dll -o c:\bbsv6\output.txt -strings -analysis
```

# Current Features
**MBBSDASM** offers several disassembly/code analysis options that are configurable through the command line.

#### Minimal Disassembly (-minimal)
Minimal will output the disassembled x86 code segments labeled with SEGMENT:OFFSET with no additional analysis.

```asm
000019CBh:0002.13CBh push ds
000019CCh:0002.13CCh push 0xa0a3
000019CFh:0002.13CFh push ds
000019D0h:0002.13D0h push 0x1998
000019D3h:0002.13D3h call word 0x0:0xffff
000019D8h:0002.13D8h add sp, 0x8
000019DBh:0002.13DBh or ax, ax
000019DDh:0002.13DDh jnz 0x1404
000019DFh:0002.13DFh push ds
000019E0h:0002.13E0h push 0x1998
000019E3h:0002.13E3h call word 0x0:0xffff
000019E8h:0002.13E8h add sp, 0x4
000019EBh:0002.13EBh or ax, ax
000019EDh:0002.13EDh jz 0x1404
00000C68h:0002.0068h 83C408 add sp, 0x8
00000C6Bh:0002.006Bh 68FF7F push 0x7fff
00000C6Eh:0002.006Eh 680180 push 0x8001
00000C71h:0002.0071h 6A07 push 0x7
00000C73h:0002.0073h 9AFFFF0000 call word 0x0:0xffff
00000C78h:0002.0078h 83C406 add sp, 0x6
00000C7Bh:0002.007Bh A3EC02 mov [0x2ec], ax
00000C7Eh:0002.007Eh 6A08 push 0x8
00000C80h:0002.0080h 9AFFFF0000 call word 0x0:0xffff
00000C85h:0002.0085h 59 pop cx
00000C86h:0002.0086h 89160403 mov [0x304], dx
00000C8Ah:0002.008Ah A30203 mov [0x302], ax
```
#### Normal Disassembly (default)
Normal will output the disassembled x86 code segments labeled with SEGMENT:OFFSET as well as processing:
Expand All @@ -39,54 +42,56 @@ Normal will output the disassembled x86 code segments labeled with SEGMENT:OFFSE
* String Reference Resolution (best guess)
* Identify and Label Conditional/Unconditional Jumps as well as Call's
```asm
000019CBh:0002.13CBh push ds ; Conditional jump from 0002:13B6
000019CCh:0002.13CCh push 0xa0a3 ; Possible String reference from SEG 5 -> "NONE"
000019CFh:0002.13CFh push ds
000019D0h:0002.13D0h push 0x1998
000019D3h:0002.13D3h call word 0x0:0xffff ; CALL MAJORBBS.Ord(0520)
000019D8h:0002.13D8h add sp, 0x8
000019DBh:0002.13DBh or ax, ax
000019DDh:0002.13DDh jnz 0x1404
000019DFh:0002.13DFh push ds
000019E0h:0002.13E0h push 0x1998
000019E3h:0002.13E3h call word 0x0:0xffff ; CALL MAJORBBS.Ord(0334)
000019E8h:0002.13E8h add sp, 0x4
000019EBh:0002.13EBh or ax, ax
000019EDh:0002.13EDh jz 0x1404
00000C68h:0002.0068h 83C408 add sp, 0x8
00000C6Bh:0002.006Bh 68FF7F push 0x7fff
00000C6Eh:0002.006Eh 680180 push 0x8001
00000C71h:0002.0071h 6A07 push 0x7
00000C73h:0002.0073h 9AFFFF0000 call word 0x0:0xffff ; call MAJORBBS.Ord(01B9h)
00000C78h:0002.0078h 83C406 add sp, 0x6
00000C7Bh:0002.007Bh A3EC02 mov [0x2ec], ax
00000C7Eh:0002.007Eh 6A08 push 0x8
00000C80h:0002.0080h 9AFFFF0000 call word 0x0:0xffff ; call MAJORBBS.Ord(0236h)
00000C85h:0002.0085h 59 pop cx
00000C86h:0002.0086h 89160403 mov [0x304], dx
00000C8Ah:0002.008Ah A30203 mov [0x302], ax
```

#### MBBS Analysis Mode (-analysis)
MBBS Analysis mode enables **MBBSDASM** to provide additional detailed analysis of Major BBS & Worldgroup Modules/DLL's with information provided from the Major BBS 6.25 Software Development Kit as well as GALACTICOMM's Developer's Guide for The Major BBS 6.2 [[link](http://software.bbsdocumentary.com/IBM/WINDOWS/MAJORBBS/devguide.pdf)]
#### Enhanced Analysis Mode (-analysis)
Enhanced Analysis mode enables **MBBSDASM** to provide additional detailed analysis of Major BBS & Worldgroup Modules/DLL's with information provided from the Major BBS 6.25 Software Development Kit as well as GALACTICOMM's Developer's Guide for The Major BBS 6.2 [[link](http://software.bbsdocumentary.com/IBM/WINDOWS/MAJORBBS/devguide.pdf)]

Additional disassembly analysis includes:
* Automatic Documentation on a large portion of the most commonly used MAJORBBS & GALGSBL functions
* Provide Method Signatures in place of the External module calls
* Automatic Documentation on a large portion of the most MAJORBBS & GALGSBL functions
* Provide Method Signatures in place of the external module calls
* Reverse Engineer and rebuild method signatures with the actual input values built from the x86 Assembly
* Identify FOR loops generated by the Borland Turbo C++ compiler and label them
* Basic variable tracking and labeling

The Enhanced Analysis mode can be extended through pull requests by adding Module Definition JSON files for known libraries.
```asm
000019CBh:0002.13CBh push ds ; Conditional jump from 0002:13B6
000019CCh:0002.13CCh push 0xa0a3 ; Possible String reference from SEG 5 -> "NONE"
000019CFh:0002.13CFh push ds
000019D0h:0002.13D0h push 0x1998
000019D3h:0002.13D3h call word 0x0:0xffff ; int match=sameas(char *stgl, char* stg2);
; Case-ignoring string match
; Returns 1 if match, 0 otherwise
000019D8h:0002.13D8h add sp, 0x8
000019DBh:0002.13DBh or ax, ax
000019DDh:0002.13DDh jnz 0x1404
000019DFh:0002.13DFh push ds
000019E0h:0002.13E0h push 0x1998
000019E3h:0002.13E3h call word 0x0:0xffff ; int haskey(lock);
; Resolved Signature: int haskey(6552);
; Does the user have the specified key
000019E8h:0002.13E8h add sp, 0x4
000019EBh:0002.13EBh or ax, ax
000019EDh:0002.13EDh jz 0x1404
00000C68h:0002.0068h 83C408 add sp, 0x8
00000C6Bh:0002.006Bh 68FF7F push 0x7fff
00000C6Eh:0002.006Eh 680180 push 0x8001
00000C71h:0002.0071h 6A07 push 0x7
00000C73h:0002.0073h 9AFFFF0000 call word 0x0:0xffff ; int numopt(int msgnum,int floor,int ceiling);
; Resolved Signature: numopt(7, 32769, 32767)
; Retrieves a numeric option from MCV file
00000C78h:0002.0078h 83C406 add sp, 0x6
00000C7Bh:0002.007Bh A3EC02 mov [0x2ec], ax ; Return value saved to 0x2ECh
00000C7Eh:0002.007Eh 6A08 push 0x8
00000C80h:0002.0080h 9AFFFF0000 call word 0x0:0xffff ; char *string=stgopt(int msgnum);
; Resolved Signature: char *string=stgopt(8);
; Gets a string from an MCV file
00000C85h:0002.0085h 59 pop cx
00000C86h:0002.0086h 89160403 mov [0x304], dx
00000C8Ah:0002.008Ah A30203 mov [0x302], ax ; Return value saved to 0x302h
; AX holds pointer, DX holds size in return from function
```
# What's Next
* Enhance MBBS Analysis
* Enhanced Variable Labeling and Tracking
* Add additional auto-documentation of GALGSBL and MAJORBBS imported function
* Enhanced Auto-Documentation of GALGSBL and MAJORBBS imported function
* Add support for DOS MZ EXE files
* This would allow disassembly of the MajorBBS/WG EXE files
* Add support for Worldgroup 3.0+
* Requires additional support for disassembly of 32-bit PE format EXE/DLL files

Expand Down

0 comments on commit 94b8990

Please sign in to comment.