Initial checkin
This commit is contained in:
commit
5c13bab36b
|
@ -0,0 +1,2 @@
|
|||
imgread
|
||||
.DS_Store
|
|
@ -0,0 +1,17 @@
|
|||
# AT&T 3B2 Tools
|
||||
|
||||
## Assembler
|
||||
|
||||
WE32100 Assembler
|
||||
|
||||
## Disassembler
|
||||
|
||||
WE32100 Disassembler
|
||||
|
||||
## Disk Image Tools
|
||||
|
||||
Tools for working with 3B2 disk images.
|
||||
|
||||
## Utilities
|
||||
|
||||
Miscellaneous utilities.
|
|
@ -0,0 +1,2 @@
|
|||
disks
|
||||
*.txt
|
|
@ -0,0 +1,17 @@
|
|||
CC=g++
|
||||
CFLAGS=-g -c -Wall -std=c++11
|
||||
LDFLAGS=
|
||||
SOURCES=imgread.cc
|
||||
OBJECTS=$(SOURCES:.cc=.o)
|
||||
EXECUTABLE=imgread
|
||||
|
||||
all: $(SOURCES) $(EXECUTABLE)
|
||||
|
||||
clean:
|
||||
rm -f $(EXECUTABLE) *.o
|
||||
|
||||
$(EXECUTABLE): $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
|
||||
|
||||
.cc.o:
|
||||
$(CC) $(CFLAGS) $< -o $@
|
|
@ -0,0 +1,306 @@
|
|||
#include "imgread.hh"
|
||||
|
||||
namespace loomcom {
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// FileEntry
|
||||
//
|
||||
|
||||
FileEntry::FileEntry(const std::string name, uint32_t inode_num) :
|
||||
name(name), inode_num(inode_num)
|
||||
{
|
||||
}
|
||||
|
||||
FileEntry::~FileEntry()
|
||||
{
|
||||
}
|
||||
|
||||
const std::vector<dentry> &FileEntry::dir_entries() const
|
||||
{
|
||||
return dir_entries_;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// FileLoader
|
||||
//
|
||||
|
||||
FileLoader::FileLoader(const std::string file_name) :
|
||||
file_name_(file_name),
|
||||
root_("/", 1)
|
||||
{
|
||||
}
|
||||
|
||||
FileLoader::~FileLoader()
|
||||
{
|
||||
}
|
||||
|
||||
const void FileLoader::load()
|
||||
{
|
||||
std::cout << "Loading file " << file_name_ << std::endl;
|
||||
|
||||
// The first thing we do is read the superblock.
|
||||
read_superblock();
|
||||
print_superblock();
|
||||
|
||||
// Now read the root file entry
|
||||
read_root();
|
||||
}
|
||||
|
||||
const void FileLoader::read_superblock()
|
||||
{
|
||||
std::fstream file;
|
||||
file.open(file_name_.c_str(), std::ifstream::in | std::ifstream::binary);
|
||||
file.seekg(SUPERBLOCK_OFFSET, file.beg);
|
||||
|
||||
if ((file.rdstate() & std::ifstream::eofbit) != 0) {
|
||||
std::cerr << "Failed to read superblock." << std::endl;
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
file.read(reinterpret_cast<char *>(&superblock_), sizeof(struct superblock));
|
||||
|
||||
file.close();
|
||||
|
||||
superblock_.s_isize = eswap16(superblock_.s_isize);
|
||||
superblock_.s_fsize = eswap32(superblock_.s_fsize);
|
||||
superblock_.s_nfree = eswap16(superblock_.s_nfree);
|
||||
superblock_.s_ninode = eswap16(superblock_.s_ninode);
|
||||
superblock_.s_time = eswap32(superblock_.s_time);
|
||||
superblock_.s_tfree = eswap32(superblock_.s_tfree);
|
||||
superblock_.s_tinode = eswap16(superblock_.s_tinode);
|
||||
superblock_.s_state = eswap32(superblock_.s_state);
|
||||
superblock_.s_magic = eswap32(superblock_.s_magic);
|
||||
superblock_.s_type = eswap32(superblock_.s_type);
|
||||
|
||||
switch (superblock_.s_type) {
|
||||
case 1:
|
||||
block_size_ = 512;
|
||||
inode_offset_ = 512 * 20;
|
||||
break;
|
||||
case 2:
|
||||
block_size_ = 1024;
|
||||
inode_offset_ = 512 * 22;
|
||||
break;
|
||||
default:
|
||||
block_size_ = 1024;
|
||||
inode_offset_ = 512 * 22;
|
||||
}
|
||||
|
||||
// Check for MAGIC
|
||||
if (superblock_.s_magic != FS_MAGIC) {
|
||||
std::cerr << "Does not appear to be a SysV filesystem!" << std::endl;
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
superblock_.s_free[i] = eswap32(superblock_.s_free[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
superblock_.s_inode[i] = eswap16(superblock_.s_inode[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
superblock_.s_dinfo[i] = eswap16(superblock_.s_dinfo[i]);
|
||||
}
|
||||
|
||||
// Calculate the number of inode entries
|
||||
num_inodes_ = (superblock_.s_isize * block_size_) / DIRENTRY_SIZE;
|
||||
inodes_per_block_ = block_size_ / INODE_SIZE;
|
||||
|
||||
time_t t = (time_t)superblock_.s_time;
|
||||
last_update_ = *localtime(&t);
|
||||
}
|
||||
|
||||
const void FileLoader::read_inode(struct dinode &inode, const uint32_t inode_num)
|
||||
{
|
||||
std::fstream file;
|
||||
int offset = inode_offset_ + (inode_num * INODE_SIZE);
|
||||
|
||||
file.open(file_name_.c_str(), std::ifstream::in | std::ifstream::binary);
|
||||
file.seekg(offset, file.beg);
|
||||
|
||||
if ((file.rdstate() & std::ifstream::eofbit) != 0) {
|
||||
std::cerr << "Failed to read inode " << inode_num << std::endl;
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
file.read(reinterpret_cast<char *>(&inode), sizeof(struct dinode));
|
||||
|
||||
file.close();
|
||||
|
||||
// Correct endianness
|
||||
inode.di_mode = eswap16(inode.di_mode);
|
||||
inode.di_nlink = eswap16(inode.di_nlink);
|
||||
inode.di_uid = eswap16(inode.di_uid);
|
||||
inode.di_gid = eswap16(inode.di_gid);
|
||||
inode.di_size = eswap32(inode.di_size);
|
||||
inode.di_atime = eswap32(inode.di_atime);
|
||||
inode.di_mtime = eswap32(inode.di_mtime);
|
||||
inode.di_ctime = eswap32(inode.di_ctime);
|
||||
}
|
||||
|
||||
const void FileLoader::read_root()
|
||||
{
|
||||
std::fstream file;
|
||||
|
||||
read_inode(root_.inode, 1);
|
||||
|
||||
// Set some file attributes on the root.
|
||||
root_.file_type = (0xf000 & root_.inode.di_mode) >> 12;
|
||||
root_.mode = 0xfff & root_.inode.di_mode;
|
||||
|
||||
// Now load the root's directory entries.
|
||||
int block_count = (int) ceil(root_.inode.di_size / (float) block_size_);
|
||||
int entry_count = root_.inode.di_size / DIRENTRY_SIZE;
|
||||
int entries_per_block = block_size_ / DIRENTRY_SIZE;
|
||||
|
||||
std::cout << " [DBG] Root contains " << std::dec << entry_count << " entries" << std::endl;
|
||||
std::cout << " [DBG] Root is " << block_count << " block(s) long" << std::endl;
|
||||
std::cout << " [DBG] Each block contains at most " << entries_per_block << " entries." << std::endl;
|
||||
|
||||
// TODO: Support for root directories with more than 10 blocks.
|
||||
if (block_count > 10) {
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
for (int block_num = 0; block_num < block_count; block_num++) {
|
||||
int addr = disk_addr(root_.inode.di_addr + (block_num * 3));
|
||||
int offset = 0x2400 + (addr * block_size_);
|
||||
int entries_this_block = 0;
|
||||
|
||||
// How many entries are in _this_ block?
|
||||
// We know the total number of entries in the root inode is
|
||||
// "entry_count", and we know that each block can contain up
|
||||
// to "entries_per_block" entries.
|
||||
if (block_num == block_count - 1) {
|
||||
entries_this_block = entry_count % entries_per_block;
|
||||
} else {
|
||||
entries_this_block = entries_per_block;
|
||||
}
|
||||
|
||||
std::cout << " [DBG] Root block #" << block_num << " address is " <<
|
||||
addr << std::endl;
|
||||
std::cout << " [DBG] Root block #" << block_num << " offset is 0x" <<
|
||||
std::hex << offset << std::endl;
|
||||
|
||||
// Read in the file names!
|
||||
for (int i = 0; i < entries_this_block; i++) {
|
||||
// Read in the direntry.
|
||||
struct dentry entry;
|
||||
|
||||
file.open(file_name_.c_str(), std::ifstream::in | std::ifstream::binary);
|
||||
file.seekg(offset + (i * sizeof(struct dentry)), file.beg);
|
||||
|
||||
if ((file.rdstate() & std::ifstream::eofbit) != 0) {
|
||||
std::cerr << "Failed to read directory entry." << std::endl;
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
file.read(reinterpret_cast<char *>(&entry), sizeof(struct dentry));
|
||||
file.close();
|
||||
|
||||
// Create the FileEntry object
|
||||
FileEntry::Ptr f = read_fileentry(entry.d_name, eswap16(entry.d_inum));
|
||||
|
||||
std::cout << std::setfill(' ');
|
||||
std::cout << " [DBG] ";
|
||||
std::cout << std::setw(3) << std::dec << f->inode_num << " ";
|
||||
std::cout << std::setw(14) << f->name << " ";
|
||||
std::cout << std::setw(2) << f->file_type << " ";
|
||||
std::cout << std::setw(4) << std::setfill('0') << std::oct << f->mode;
|
||||
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const FileEntry::Ptr FileLoader::read_fileentry(std::string name, uint32_t inode_num)
|
||||
{
|
||||
FileEntry::Ptr file_entry = std::make_shared<FileEntry>(name, inode_num);
|
||||
|
||||
read_inode(file_entry->inode, inode_num);
|
||||
|
||||
file_entry->file_type = (0xf000 & file_entry->inode.di_mode) >> 12;
|
||||
file_entry->mode = 0x0fff & file_entry->inode.di_mode;
|
||||
file_entry->is_dir = file_entry->file_type == 8;
|
||||
|
||||
return file_entry;
|
||||
}
|
||||
|
||||
const void FileLoader::print_superblock() const
|
||||
{
|
||||
char time_str[100];
|
||||
strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S", &last_update_);
|
||||
|
||||
std::cout << "FILESYSTEM INFO" << std::endl;
|
||||
std::cout << "---------------" << std::endl;
|
||||
std::cout << " Size in blocks of i-list: " << std::dec <<
|
||||
superblock_.s_isize << std::endl;
|
||||
std::cout << " Size of inode list in entries: " << num_inodes_ << std::endl;
|
||||
std::cout << " Size in blocks of entire volume: " << superblock_.s_fsize << std::endl;
|
||||
std::cout << " Free inodes: " << superblock_.s_ninode << std::endl;
|
||||
std::cout << " Free blocks: " << superblock_.s_nfree << std::endl;
|
||||
std::cout << " File System Type: " << superblock_.s_type << std::endl;
|
||||
std::cout << " File System State: " << std::hex << superblock_.s_state << std::endl;
|
||||
std::cout << " File System Name: " << superblock_.s_fname << std::endl;
|
||||
std::cout << " Last Superblock Update Time: " << time_str << std::endl;
|
||||
}
|
||||
|
||||
const uint32_t FileLoader::eswap32(const uint32_t val) const
|
||||
{
|
||||
return (((val & 0x000000ff) << 24) |
|
||||
((val & 0x0000ff00) << 8) |
|
||||
((val & 0x00ff0000) >> 8) |
|
||||
((val & 0xff000000) >> 24));
|
||||
}
|
||||
|
||||
const uint16_t FileLoader::eswap16(const uint16_t val) const
|
||||
{
|
||||
return (((val & 0x00ff) << 8) |
|
||||
((val & 0xff00) >> 8));
|
||||
}
|
||||
|
||||
const uint32_t FileLoader::disk_addr(uint8_t *buf) const
|
||||
{
|
||||
return buf[0] << 12 | buf[1] << 8 | buf[2];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}; // namespace
|
||||
|
||||
using namespace std;
|
||||
using namespace loomcom;
|
||||
|
||||
void usage() {
|
||||
cerr << "Usage: imgread <file>" << endl;
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
|
||||
// First argument is the file name.
|
||||
if (argc < 2) {
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *name = argv[1];
|
||||
|
||||
// If the first arg isn't a file, die.
|
||||
struct stat s;
|
||||
stat(name, &s);
|
||||
|
||||
if (!S_ISREG(s.st_mode)) {
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
FileLoader file_loader(name);
|
||||
file_loader.load();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
namespace loomcom {
|
||||
|
||||
//
|
||||
// Superblock Format.
|
||||
//
|
||||
// On an "init" filesystem (partition 5), this will be Block 19
|
||||
//
|
||||
struct superblock
|
||||
{
|
||||
uint16_t s_isize; // Size in blocks of inode list
|
||||
uint32_t s_fsize; // Size in blocks of the entire volume
|
||||
uint16_t s_nfree; // Number of addresses in s_free
|
||||
uint32_t s_free[50]; // Free block list
|
||||
uint16_t s_ninode; // Number of i-nodes in s_inode
|
||||
uint16_t s_inode[100]; // free i-node list
|
||||
uint8_t s_flock; // Lock during free list manipulation
|
||||
uint8_t s_ilock; // Lock during i-list manipulation
|
||||
uint8_t s_fmod; // Super block modified flag
|
||||
uint8_t s_ronly; // Mounted read-only flag
|
||||
uint32_t s_time; // Last super block update
|
||||
uint16_t s_dinfo[4]; // Device information
|
||||
uint32_t s_tfree; // total free block
|
||||
uint16_t s_tinode; // total free inodes
|
||||
char s_fname[6]; // file system name
|
||||
char s_fpack[6]; // file system pack name
|
||||
uint32_t s_fill[12]; // adjust to make sizeof filsys
|
||||
uint32_t s_state; // file system state
|
||||
uint32_t s_magic; // magic number to indicate new file system
|
||||
uint32_t s_type; // type of new file system
|
||||
};
|
||||
|
||||
//
|
||||
// On-disk structure of an inode.
|
||||
//
|
||||
struct dinode
|
||||
{
|
||||
uint16_t di_mode; // Mode and type of file
|
||||
uint16_t di_nlink; // Number of links to file
|
||||
uint16_t di_uid; // Owner's User ID
|
||||
uint16_t di_gid; // Owner's Group ID
|
||||
uint32_t di_size; // Size of file (in bytes)
|
||||
uint8_t di_addr[40]; // Disk block addresses
|
||||
uint32_t di_atime; // Time last accessed
|
||||
uint32_t di_mtime; // Time last modified
|
||||
uint32_t di_ctime; // Time created
|
||||
};
|
||||
|
||||
//
|
||||
// On-disk structure of a directory entry.
|
||||
//
|
||||
struct dentry {
|
||||
uint16_t d_inum; // Inode number
|
||||
char d_name[14]; // Name
|
||||
};
|
||||
|
||||
class FileEntry {
|
||||
public:
|
||||
typedef std::shared_ptr<FileEntry> Ptr;
|
||||
|
||||
FileEntry(const std::string name, uint32_t inode_num);
|
||||
~FileEntry();
|
||||
|
||||
const std::vector<dentry> &dir_entries() const;
|
||||
|
||||
bool is_dir;
|
||||
struct dinode inode;
|
||||
|
||||
// File attributes
|
||||
std::string name;
|
||||
int file_type;
|
||||
int mode;
|
||||
uint32_t inode_num;
|
||||
private:
|
||||
const std::vector<dentry> dir_entries_;
|
||||
};
|
||||
|
||||
//
|
||||
// Load data from a file
|
||||
//
|
||||
class FileLoader {
|
||||
public:
|
||||
const static int SUPERBLOCK_OFFSET = 0x2600;
|
||||
|
||||
const static unsigned int FS_MAGIC = 0xfd187e20;
|
||||
|
||||
const static int DIRENTRY_SIZE = 16;
|
||||
const static int INODE_SIZE = 64;
|
||||
|
||||
FileLoader(const std::string file_name);
|
||||
~FileLoader();
|
||||
|
||||
const void load();
|
||||
const void print_superblock() const;
|
||||
const void print_inodes() const;
|
||||
private:
|
||||
const uint32_t eswap32(const uint32_t val) const;
|
||||
const uint16_t eswap16(const uint16_t val) const;
|
||||
const uint32_t disk_addr(uint8_t *buf) const;
|
||||
const void read_superblock();
|
||||
const void read_root();
|
||||
const void read_inode(struct dinode &inode, const uint32_t inode_num);
|
||||
const FileEntry::Ptr read_fileentry(std::string name, uint32_t inode_num);
|
||||
const std::string file_name_;
|
||||
uint16_t block_size_;
|
||||
uint32_t inode_offset_;
|
||||
uint32_t inodes_per_block_; // How many inodes per block of the
|
||||
// inode list
|
||||
|
||||
// The superblock
|
||||
struct superblock superblock_;
|
||||
// Number of inode entries (superblock only gives us this in blocks)
|
||||
uint32_t num_inodes_;
|
||||
struct tm last_update_;
|
||||
|
||||
// The root directory
|
||||
FileEntry root_;
|
||||
};
|
||||
|
||||
}; // namespace
|
|
@ -0,0 +1,51 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define PD_TAG(vaddr) (((vaddr >> 13) & 0xf) | ((vaddr >> 14) & 0xfff0))
|
||||
#define PD_IDX(vaddr) (((vaddr >> 11) & 3) | ((vaddr >> 15) & 4))
|
||||
|
||||
void print_paged_vaddr(uint32_t vaddr) {
|
||||
printf(" Paged Virtual Address 0x%08x\n\n", vaddr);
|
||||
|
||||
printf(" 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00\n");
|
||||
printf("+-----+-----------------------------------.--+-----------.--.--+--------------------------------+\n");
|
||||
printf("|");
|
||||
|
||||
for (int i = 31; i >= 0; i--) {
|
||||
if (i == 30 || i == 17 || i == 18 || i == 13 || i == 12 || i == 11) {
|
||||
printf(" %d|", (vaddr >> i) & 1);
|
||||
} else if (i == 0) {
|
||||
printf(" %d", (vaddr >> i) & 1);
|
||||
} else {
|
||||
printf(" %d ", (vaddr >> i) & 1);
|
||||
}
|
||||
}
|
||||
|
||||
printf("|\n");
|
||||
printf("+-----+-----------------------------------.--+-----------.--.--+--------------------------------+\n");
|
||||
|
||||
printf("\n");
|
||||
|
||||
printf(" TAG=%04x IDX=%04x\n", PD_TAG(vaddr), PD_IDX(vaddr));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
uint32_t vaddr;
|
||||
int scanret;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: check_vaddr <vaddr>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
scanret = sscanf(argv[1], "%x", &vaddr);
|
||||
|
||||
if (scanret <= 0 || scanret == EOF) {
|
||||
fprintf(stderr, "Unable to parse vaddr.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
print_paged_vaddr(vaddr);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
target
|
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "we32as"
|
||||
version = "0.1.0"
|
||||
authors = ["Seth Morabito <web@loomcom.com>"]
|
||||
|
||||
[dependencies]
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
target
|
|
@ -0,0 +1,110 @@
|
|||
[root]
|
||||
name = "we32dis"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap 2.22.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"term_size 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vec_map 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kernel32-sys"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "term_size"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-build"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"
|
||||
"checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159"
|
||||
"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
|
||||
"checksum clap 2.22.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e17a4a72ffea176f77d6e2db609c6c919ef221f23862c9915e687fb54d833485"
|
||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "88ee81885f9f04bff991e306fea7c1c60a5f0f9e409e99f6b40e3311a3363135"
|
||||
"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
|
||||
"checksum term_size 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "07b6c1ac5b3fffd75073276bca1ceed01f67a28537097a2a9539e116e50fb21a"
|
||||
"checksum unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18127285758f0e2c6cf325bb3f3d138a12fee27de4f23e146cd6a179f26c2cf3"
|
||||
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
|
||||
"checksum vec_map 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8cdc8b93bd0198ed872357fb2e667f7125646b1762f16d60b2c96350d361897"
|
||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
|
@ -0,0 +1,7 @@
|
|||
[package]
|
||||
name = "we32dis"
|
||||
version = "0.1.0"
|
||||
authors = ["Seth Morabito <web@loomcom.com>"]
|
||||
|
||||
[dependencies]
|
||||
clap = "2.22.1"
|
|
@ -0,0 +1,52 @@
|
|||
extern crate clap;
|
||||
|
||||
use std::error::Error;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::path::Path;
|
||||
use std::vec::Vec;
|
||||
use clap::{Arg, App};
|
||||
|
||||
fn disassemble(buf: &Vec<u8>) {
|
||||
println!("I'm disassembling a {} byte buffer", buf.len());
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let matches = App::new("WE32100 Disassembler")
|
||||
.version("1.0")
|
||||
.author("Seth J. Morabito <web@loomcom.com>")
|
||||
.about("WE32100 Disassembler")
|
||||
.arg(Arg::with_name("offset")
|
||||
.value_name("OFFSET")
|
||||
.short("o")
|
||||
.long("offset")
|
||||
.help("Offset within the file to start disassembly")
|
||||
.takes_value(true))
|
||||
.arg(Arg::with_name("INPUT")
|
||||
.value_name("FILE")
|
||||
.help("Input file to decompile")
|
||||
.required(true)
|
||||
.index(1))
|
||||
.get_matches();
|
||||
|
||||
let infile = matches.value_of("INPUT").unwrap();
|
||||
|
||||
let path = Path::new(infile);
|
||||
let display = path.display();
|
||||
|
||||
println!("I'm decompiling: {}", display);
|
||||
|
||||
let mut file = match File::open(&path) {
|
||||
Err(why) => panic!("Couldn't open {}: {}", display, why.description()),
|
||||
Ok(file) => file,
|
||||
};
|
||||
|
||||
let mut buf = Vec::new();
|
||||
|
||||
match file.read_to_end(&mut buf) {
|
||||
Err(why) => panic!("Couldn't open {}: {}", display, why.description()),
|
||||
Ok(_) => (),
|
||||
}
|
||||
|
||||
disassemble(&buf);
|
||||
}
|
Loading…
Reference in New Issue