Skip to content

.brd format

chloridite edited this page May 17, 2016 · 1 revision

basically a text file

read loop uses getc, so a line ends on 0xff as well as \r and \n, and the file ends on 0xff or end-of-stream. file read code uses a char[0x200] on the stack, and so is vulnerable to stack buffer overflow, and since this is old borland with no stack cookies and ASLR disabled, someone can own you with a boardview file. this also limits lines to 512 bytes. the nice thing about this format is some programs (by which i mean web browsers) can roundtrip it through a text encoding and subtly break things.

// "business logic"
void decode(char *src, char *dst) {
  int i = 0;
  while (src[i]) {
    char x = src[i];
    dst[i] = ~( ((x >> 6) & 3) | (x << 2) );
    ++i;
  }
  dst[i] = 0;
}

Blocks

The file is arranged into blocks of lines, with each block preceded by a header naming the type of the following block. Each line consists of string and integer elements joined by whitespace. Blocks should be listed in the file in the order listed in this doc, or things will likely crash horribly.

str_length

{int partNameLen} {int netNameLen}

var_data

{int numFormat} {int numParts} {int numPins} {int numNails} {int unused0} {int unused1}

Format

{int x} {int y}

describes board shape

Parts

{string name} {int type} {int endOfPins}

  • if side is 2, hide if type >= 8
  • else hide if type < 8 && type >= 4
  • if (type & 0xc) part is SMD, else part is DIP

i.e., [1,3] are DIP parts which should display on both sides, everything else is smd; in typical usage, this is enum { DIP_Top = 1, SMD_Top = 5, SMD_Bottom = 10 } ComponentType; this seems to disallow showing DIP component outlines on the bottom (pins will still display)

Pins

{int x} {int y} {int probe} {int part} {string netName}

  • (probe < 0) => "No Probe"

Nails

{int probe} {int x} {int y} {int side} {string netName}

test points. these overlap with pins of parts named "..."

Clone this wiki locally