private void WriteDebugRedirect() { Region r = writer.AllocateRegion(".debug"); r.WriteInt32(0); // Characteristics r.WriteInt32(0); // Timestamp r.WriteInt16(0); // Major version of debug format r.WriteInt16(0); // Minor r.WriteInt32(4); // type: IMAGE_DEBUG_TYPE_MISC IntToken t = r.InsertIntToken(); // SizeOfData; Placeholder startLocation = r.CurrentLocation.Increment(8); r.WritePlaceholderRelative(startLocation); //starts immediatly after this header r.WritePlaceholderFile(startLocation); //starts immediatly after this header // /!\ windbg doesn't seem to allow unicode names form dbg files string dbgName = moduleName + ".dbg"; int len = dbgName.Length + 1; int fill = 4 - (len % 4); if (fill == 4) { fill = 0; } len += fill; r.WriteInt32(1); // DataType: IMAGE_DEBUG_MISC_EXENAME r.WriteInt32(len); r.WriteByte(0); // Ascii r.Write(new byte[] { 0, 0, 0 }); // reserved r.WriteAsUtf8NullTerminated(dbgName); for (int i = 0; i < fill; ++i) { r.WriteByte(0); } t.SetValue((int)(r.CurrentLocation.MemoryDistanceFrom(startLocation))); }
private static IToken CreateIntToken(IReadOnlyList<string> tokens, int startPosition, Action<IToken, int, string> callback) { string item = tokens[0]; IToken token = new IntToken(int.Parse(item)); //callback?.Invoke(token, startPosition, item); return token; }
// get token element from current line feed // returns null if no token to get is found. public Token getNextToken() { // Note from Colin: // write code to take chars out of string named // inputBufferLine // IMPORTANT: before using this method, make sure to put this getNextToken with it's // own loop (in SPP.cs) nested inside one that reads a good newLine from the readAnotherLine // so we have something to read tokens from // only used for buffer if last look was peek. other wise a fresh new token is found //gives a previous new find if (this.preinspected_PEEK_token == null) { return(null); } if (this.ifPast_lookWasPeek == true && !this.makeANew_Peek) { // this only really gets set to false by a call purely from getNextToken in Parser // since // peek's method behind the scenes set ifPast_lookWasPeek to true this.ifPast_lookWasPeek = false; return(this.preinspected_PEEK_token); } // else // find a new token to be returned Token returnToken = null; try { // start parsing getToken() process off // by reading a line from input // Is run once only : in SPP. if (!this.readFirstLine) { this.readFirstLine = true; // readAnotherLine returns false if there is no new line to be read! this.noMoreLinesOfInput = this.readAnotherLine(); if (this.noMoreLinesOfInput == false) { Console.Error.WriteLine("error: no input given."); this.preinspected_PEEK_token = null; return(null); } } // read another line :: because last line's characters are all used Up if (charIndexOfReadLine > this.inputBufferLine.Length - 1) { // readAnotherLine returns false if there is no new line to be read! this.noMoreLinesOfInput = this.readAnotherLine(); } if (!this.noMoreLinesOfInput) { this.preinspected_PEEK_token = null; // return null value return(returnToken); } int numberDotsForDecimal = 0; //bool currentTokenIsNumber = false; bool number_lastCharWasDecimal = false; // setup reference for a Start and End Index, of a String in input expression int someStringLowerBound; int someStringLength; int someStringUpperBound; // if true, stop reading characters in constant someString bool endOfSomeStringReached; // It would be more efficient if we'd maintain our own // input buffer and read characters out of that // buffer, but reading individual characters from the // input stream is easier. //// wrong code in original zip was: ch = reader.Read(); char ch; ch = buf[charIndexOfReadLine]; while (charIndexOfReadLine <= inputBufferLine.Length - 1) { ch = buf[charIndexOfReadLine]; // if whitespace or a tab ... skip and iterate to next character. if (ch == 32 || ch == 9) { charIndexOfReadLine++; continue; } else { break; } } // if end of current line read , return getNextToken() if (charIndexOfReadLine > inputBufferLine.Length - 1) { return(getNextToken()); } // reset this boolean to null or false. endOfSomeStringReached = false; // reset all these to zero someStringLowerBound = 0; someStringLength = 0; someStringUpperBound = 0; numberDotsForDecimal = 0; // need to use this variable in revision number 1 that is to happen //currentTokenIsNumber = false; number_lastCharWasDecimal = false; // Special characters if (ch == '\'') { this.quoteMark_engaged = true; charIndexOfReadLine++; Parser.quote_mark_misc_to_placed_cursor__is_not_new_data = true; return(new Token(TokenType.LPAREN)); } else if (ch == '(') { // copy char to token this.charIndexOfReadLine++; //return new Token (TokenType.LPAREN); numberParentheses_L++; returnToken = new Token(TokenType.LPAREN); return(returnToken); } else if (ch == ')') { //return new Token (TokenType.RPAREN); if (numberParentheses_R > numberParentheses_L) { this.charIndexOfReadLine++; if (flag_debugger) { Console.WriteLine("RPAREN"); } else { Console.Error.WriteLine("Too many Right Parentheses>: error! \n continued... :Last input ignored!"); } return(getNextToken()); } else { if (this.numberParentheses_L > this.numberParentheses_R) { this.numberParentheses_L--; } // copy char to token this.charIndexOfReadLine++; returnToken = new Token(TokenType.RPAREN); return(returnToken); } } else if (ch == '.') { // copy char to token this.charIndexOfReadLine++; // We ignore the special identifier `...'. returnToken = new Token(TokenType.DOT); //return new Token (TokenType.DOT); return(returnToken); } // Boolean constants else if (ch == '#') { // note... Work on.. As said above: charIndexOfReadLine++; if (charIndexOfReadLine <= inputBufferLine.Length - 1) { ch = buf[charIndexOfReadLine]; if (ch == 't') { // copy char to token this.charIndexOfReadLine++; returnToken = new Token(TokenType.TRUE); //return new Token (TokenType.TRUE); return(returnToken); } else if (ch == 'f') { // copy char to token this.charIndexOfReadLine++; returnToken = new Token(TokenType.FALSE); //return new Token (TokenType.FALSE); return(returnToken); } else { this.charIndexOfReadLine++; if (!flag_debugger) { Console.Error.WriteLine("Illegal character '" + ch + "' following #"); } //Console.Error.WriteLine ("Illegal character '" + // char)ch + "' following #"); return(getNextToken()); } } return(getNextToken()); } // String constants else if (ch == '"') { // TODO: scan a string into the buffer variable buf //return new StringToken (new String (buf, 0, 0)); // colin's dealing someStringLowerBound = charIndexOfReadLine; // increment by 1 more character in array charIndexOfReadLine++; // increment someStringLength 1 for quotation mark " someStringLength++; while (!endOfSomeStringReached && charIndexOfReadLine <= inputBufferLine.Length - 1) { // set tentative someStringLength... someStringLength++; // tentative upper bound of someString for future reference.... someStringUpperBound = charIndexOfReadLine; // check if next scanned character is backslash delimiter... if (buf[charIndexOfReadLine] == '\\') { // skip past the delimiter backslash and also the following quote Char charIndexOfReadLine += 2; someStringLength++; } else if (buf[charIndexOfReadLine] == '"') { endOfSomeStringReached = true; this.charIndexOfReadLine++; someStringUpperBound = this.charIndexOfReadLine; } // iterate to next Char else { charIndexOfReadLine++; } } if (!endOfSomeStringReached) { Console.Error.WriteLine("String does not finish on line,... error: ran out of characters."); return(null); } // Given that upperBound cannot have been written to be out of array bounds, // this checks if the end of quote is the last term in the current Line. else if (someStringUpperBound == inputBufferLine.Length - 1) { returnToken = new StringToken(new String(buf, someStringLowerBound, someStringLength)); // return string literal ... that was just scanned // return string literal ... that was just scanned //if (!flag_debugger) //Console.WriteLine("value: " + new String(buf, someStringLowerBound, someStringLength)); return(returnToken); // remove comment not necessary // Console.WriteLine("continuation Halted: lineTerminates Abruptedly"); } // copy char to token // return string literal ... that was just scanned else if (someStringLength != 0) { // copy char to token //if (!flag_debugger) //Console.WriteLine("value: " + new String(buf, someStringLowerBound, someStringLength)); returnToken = new StringToken(new String(buf, someStringLowerBound, someStringLength)); return(returnToken); } // String has nothing to it : i.e. "[blank] //else // { // Console.WriteLine("value: error Incomplete expression String literal"); // return getNextToken(); //} // dummy return null; return(returnToken); } // Integer constants else if (ch >= '0' && ch <= '9') { //int i = ch - '0'; someStringLength++; someStringLowerBound = charIndexOfReadLine; // increment by 1 more character in array charIndexOfReadLine++; // someStringLength starts at 0 while (!endOfSomeStringReached && charIndexOfReadLine <= inputBufferLine.Length - 1) { ch = buf[charIndexOfReadLine]; // if a space appears, ... move out of number retrieval loop if (ch == 32 || ch == 9) { if (numberDotsForDecimal == 1 && number_lastCharWasDecimal) { // error if (!flag_debugger) { Console.Error.WriteLine("incorrect decimal form: needs a number for right side of decimal."); } else { Console.WriteLine("unknown type number decimal: i.e. 10._blank"); } return(getNextToken()); } else { endOfSomeStringReached = true; break; } } /** * DONT NEED THIS * else if (ch == '(') * { * * * this.charIndexOfReadLine++; * * Console.WriteLine("illegal previous number. Use of right ')' not correct."); * * return getNextToken(); * * } * **/ else if (ch == ')') { endOfSomeStringReached = true; //return new Token (TokenType.RPAREN); if (numberParentheses_R > numberParentheses_L) { this.charIndexOfReadLine++; //Console.WriteLine("Too many Right Parentheses>: error! \n continued... :Last input ignored!"); return(getNextToken()); } else { // rules out having a right Parenthesis if number was like // 10.) if (number_lastCharWasDecimal) { this.charIndexOfReadLine++; if (!flag_debugger) { Console.Error.WriteLine("illegal previous number. Use of right ')' not correct."); } else { Console.WriteLine("unknown type number decimal: i.e. 10.) so on "); } return(getNextToken()); } else { // copy char to token // need to configure token to take either decimal or integer. double intermediateVal = Convert.ToDouble(new String(buf, someStringLowerBound, someStringLength)); int intVal = Convert.ToInt32(intermediateVal); returnToken = new IntToken(intVal); return(returnToken); //endOfSomeStringReached dont activate already printed //numberParentheses_L--; // on next getToken() call... take in token of parenthesis... later.. } } } // scan over first decimal for a floating p if (numberDotsForDecimal == 0 && ch == '.') { number_lastCharWasDecimal = true; numberDotsForDecimal = 1; // set tentative someStringLength... someStringLength++; charIndexOfReadLine++; continue; } // rules out more than one dot symbol else if (numberDotsForDecimal >= 1 && ch == '.') { this.charIndexOfReadLine++; if (!flag_debugger) { Console.Error.WriteLine("illegal numeric decimal form: cannot have more than one period."); } else { Console.WriteLine("unknown type number decimal: i.e. 10.. ends abruptedly at number dot followed by dot"); } return(getNextToken()); //break; } // rules out wrong symbols for numeric decimal digits right side of dot else if (numberDotsForDecimal == 1 && number_lastCharWasDecimal && !(ch >= '0' && ch <= '9')) { this.charIndexOfReadLine++; if (!flag_debugger) { Console.Error.WriteLine("incorrect decimal form: need a number for right side of decimal \n illegal start of identifier. : an identifier cannot start with numerical digits."); } else { Console.WriteLine("unknown type number decimal: i.e. 10.$*$U)) so on "); } return(getNextToken()); //break; } // rules out symbols that are not numbers if (!(ch >= '0' && ch <= '9')) { this.charIndexOfReadLine++; if (!flag_debugger) { Console.Error.WriteLine("illegal start of number. : an number cannot start with numerical digits."); } else { Console.WriteLine("unknown type number form : i.e. 10**$ so on "); } return(getNextToken()); //break; } // set tentative someStringLength... with our latest new character someStringLength++; // tentative upper bound of someString for future reference.... someStringUpperBound = charIndexOfReadLine; number_lastCharWasDecimal = false; // proceed next increment of a loop charIndexOfReadLine++; } // write out to console any full decimal number // Given that upperBound cannot have been written to be out of array bounds, // this checks if the end of quote is the last term in the current Line. if (endOfSomeStringReached && someStringUpperBound == inputBufferLine.Length - 1) { // copy char to token // need to configure token to take either decimal or integer. double intermediateVal = Convert.ToDouble(new String(buf, someStringLowerBound, someStringLength)); int intVal = Convert.ToInt32(intermediateVal); returnToken = new IntToken(intVal); // if (flag_debugger) // Console.WriteLine("value: " + new String(buf, someStringLowerBound, someStringLength)); return(returnToken); //Console.WriteLine("continuation Halted: lineTerminates Abruptedly"); } else if (endOfSomeStringReached) { // copy char to token // need to configure token to take either decimal or integer. double intermediateVal = Convert.ToDouble(new String(buf, someStringLowerBound, someStringLength)); int intVal = Convert.ToInt32(intermediateVal); returnToken = new IntToken(intVal); // return string literal ... that was just scanned // if (flag_debugger) // Console.WriteLine("value: " + new String(buf, someStringLowerBound, someStringLength)); return(returnToken); } // number ends at line's end /after the new line char delimiter else if (!endOfSomeStringReached && (!number_lastCharWasDecimal && numberDotsForDecimal <= 1)) { double intermediateVal = Convert.ToDouble(new String(buf, someStringLowerBound, someStringLength)); int intVal = Convert.ToInt32(intermediateVal); returnToken = new IntToken(intVal); // if (flag_debugger) // Console.WriteLine("number does not finish on line,... or, error: ran out of characters current line."); return(returnToken); } else if (!endOfSomeStringReached && (number_lastCharWasDecimal)) { // if (flag_debugger) // Console.WriteLine("number incomplete __ ends with decimal at end of line,... error: ran out of characters current line."); return(getNextToken()); } // dummy return; return(returnToken); } // Identifiers else if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || ch == '!' || ch == '$' || ch == '%' || ch == '&' || ch == '*' || ch == '+' || ch == '-' || ch == '.' || ch == '/' || ch == ':' || ch == '<' || ch == '=' || ch == '>' || ch == '?' || ch == '@' || ch == '@' || ch == '^' || ch == '_' || ch == '~') { // or ch is some other valid first character // for an identifier) { // TODO: scan an identifier into the buffer // make sure that the character following the integer // is not removed from the input stream //return new IdentToken (new String (buf, 0, 0)); // check for quote token someStringLength++; someStringLowerBound = charIndexOfReadLine; // increment by 1 more character in array charIndexOfReadLine++; // someStringLength starts at 0 while (!endOfSomeStringReached && charIndexOfReadLine <= inputBufferLine.Length - 1) { ch = buf[charIndexOfReadLine]; // noted as a extra evaluation of extended symbols char Char1 = ch; // if a space appears, ... move out of Identifier retrieval loop if (ch == 32 || ch == 9) { endOfSomeStringReached = true; this.charIndexOfReadLine++; break; } else if (ch == ')') { //return new Token (TokenType.RPAREN); if (numberParentheses_R > numberParentheses_L) { this.charIndexOfReadLine++; if (flag_debugger) { Console.WriteLine("RPAREN"); } else { Console.Error.WriteLine("Too many Right Parentheses>: error! \n continued... :Last input ignored!"); } return(getNextToken()); } else { // note: need to configure token to take either decimal or integer. //Console.WriteLine("Identifier: " + new String(buf, someStringLowerBound, someStringLength)); //endOfSomeStringReached dont activate already printed //numberParentheses_L--; // take in token of parenthesis... later.. // copy char to token // this.charIndexOfReadLine++; // Console.WriteLine("value: )"); endOfSomeStringReached = true; break; } } else if ((Char1 >= 'A' && Char1 <= 'Z') || (Char1 >= 'a' && Char1 <= 'z') || (Char1 >= '0' && Char1 <= '9') || Char1 == '!' || Char1 == '$' || Char1 == '%' || Char1 == '&' || Char1 == '*' || Char1 == '+' || Char1 == '-' || Char1 == '.' || Char1 == '/' || Char1 == ':' || Char1 == '<' || Char1 == '=' || Char1 == '>' || Char1 == '?' || Char1 == '@' || Char1 == '@' || Char1 == '^' || Char1 == '_' || Char1 == '~') { // set tentative someStringLength... with our latest new character someStringLength++; // tentative upper bound of someString for future reference.... someStringUpperBound = charIndexOfReadLine; // proceed next increment of a loop charIndexOfReadLine++; continue; } else { this.charIndexOfReadLine++; if (!flag_debugger) { Console.Error.WriteLine("illegal character within identifier: error with accepted char' code elements."); } else { Console.WriteLine("Ident_not_right"); } return(getNextToken()); //break; } } // write out to console any full decimal number // Given that upperBound cannot have been written to be out of array bounds, // this checks if the end of identifier quote is the last term in the current Line. if (endOfSomeStringReached && someStringUpperBound == inputBufferLine.Length - 1) { // copy char to token // return string literal ... that was just scanned returnToken = new IdentToken(new String(buf, someStringLowerBound, someStringLength)); //if (flag_debugger) // Console.WriteLine("Identifier: " + new String(buf, someStringLowerBound, someStringLength)); return(returnToken); // Console.WriteLine("continuation Halted: lineTerminates Abruptedly"); } else if (endOfSomeStringReached) { // copy char to token returnToken = new IdentToken(new String(buf, someStringLowerBound, someStringLength)); //if (flag_debugger) // Console.WriteLine("Identifier: " + new String(buf, someStringLowerBound, someStringLength)); return(returnToken); } else if (!endOfSomeStringReached) { // copy char to token returnToken = new IdentToken(new String(buf, someStringLowerBound, someStringLength)); //if (flag_debugger) // Console.WriteLine("Identifier: " + new String(buf, someStringLowerBound, someStringLength)); return(returnToken); } return(returnToken); } // Illegal character else { this.charIndexOfReadLine++; Console.Error.WriteLine("Illegal input error char |_|."); return(getNextToken()); //Console.WriteLine ("Illegal input character '" //+ ch + '\''); //return getNextToken (); //return new Object(); } } catch (IOException e) { Console.Error.WriteLine("IOException: " + e.Message); //return null; } return(returnToken); }
public override void Close() { debugabbrev.WriteULEB(1); debugabbrev.WriteULEB(0x11); // compile_unit debugabbrev.WriteByte(0); // no children debugabbrev.WriteULEB(0x10); // stmt_list debugabbrev.WriteULEB(0x6); debugabbrev.WriteULEB(0x12); // high_addr debugabbrev.WriteULEB(0x1); debugabbrev.WriteULEB(0x11); // low_addr debugabbrev.WriteULEB(0x1); debugabbrev.WriteULEB(0x3); // name debugabbrev.WriteULEB(0x8); debugabbrev.WriteULEB(0x25); // producer debugabbrev.WriteULEB(0x8); debugabbrev.WriteByte(0x0); // terminator debugabbrev.WriteByte(0x0); debugabbrev.WriteByte(0x0); foreach (string file in sourceLines.Keys) { List <SourceLine> list = sourceLines[file]; Placeholder lowAddr = list[0].placeholder; Placeholder highAddr = list[list.Count - 1].placeholder; IntToken cu_length = debuginfo.InsertIntToken(); // cu_length; Placeholder cu_length_begin = debuginfo.CurrentLocation; debuginfo.WriteInt16(2); debuginfo.WriteInt32(0); debuginfo.WriteInt8(debuginfo.SizeOfWord); debuginfo.WriteULEB(1); // DW_TAG_compile_unit debuginfo.WriteInt32((int)debugline.CurrentLocation.Offset); debuginfo.WritePlaceholder(highAddr); debuginfo.WritePlaceholder(lowAddr); debuginfo.WriteAsUtf8NullTerminated(file); debuginfo.WriteAsUtf8NullTerminated("pluk plux0r 1.2.3"); cu_length.SetValue((int)(debuginfo.CurrentLocation.MemoryDistanceFrom(cu_length_begin))); IntToken total_length = debugline.InsertIntToken(); Placeholder begin = debugline.CurrentLocation; debugline.WriteInt16(2); //version IntToken prologue_length = debugline.InsertIntToken(); Placeholder prologue = debugline.CurrentLocation; debugline.WriteByte(1); // minimum_instruction_length debugline.WriteByte(1); // default_is_stmt debugline.Write(new byte[] { 256 - 5, 14, 10, 0, 1, 1, 1, 1, 0, 0, 0, 1 }); string directory = System.IO.Path.GetDirectoryName(file); string filename = System.IO.Path.GetFileName(file); if (string.IsNullOrEmpty(directory)) { directory = "."; } debugline.WriteAsUtf8NullTerminated(directory); debugline.WriteByte(0); Require.NotEmpty(file); debugline.WriteAsUtf8NullTerminated(filename); debugline.Write(new byte[] { 1, 0, 0 }); debugline.WriteByte(0); prologue_length.SetValue((int)(debugline.CurrentLocation.MemoryDistanceFrom(prologue))); int line = 1; int column = 0; SourceLine prev = new SourceLine(); foreach (SourceLine x in list) { if (SourceLine.Match(prev, x)) { prev = x; continue; } prev = x; debugline.WriteByte(0); // DW_LNE_set_address debugline.WriteULEB(1 + debugline.SizeOfWord); debugline.WriteByte(2); debugline.WritePlaceholder(x.placeholder); int l = x.location.Line; if (l < 0) { l = 0; } int delta = l - line; line = l; if (delta != 0) { debugline.WriteByte(3); // advance_line debugline.WriteSLEB(delta); } if (x.location.Column != column) { debugline.WriteByte(5); // set_column if (x.location.Column < 0) { column = 0; } else { column = x.location.Column; } debugline.WriteULEB(column); } if (x.mark == SourceMark.EndSequence) { debugline.Write(new byte[] { 0, 1, 1 }); // end_sequence line = 1; column = 0; } else { debugline.WriteByte(1); // copy } } debugline.Write(new byte[] { 0, 1, 1 }); // end_sequence total_length.SetValue((int)(debugline.CurrentLocation.MemoryDistanceFrom(begin))); } }
private void WriteVersionHeader() { Region resourceHeader = writer.AllocateRegion(".rsrc"); // Resouce Directory Table resourceHeader.WriteInt32(0); //Characteristics resourceHeader.WriteInt32(0); // TimeDateStamp resourceHeader.WriteInt16(0); // mayor version resourceHeader.WriteInt16(0); // minor verson resourceHeader.WriteInt16(0); // number of named entries resourceHeader.WriteInt16(1); // number of id'ed entries // Resource Directory Entry resourceHeader.WriteInt32(0x10); // ID (VERSION) resourceHeader.WriteInt32(0x80000018); //pointer to next directory // Resouce Directory Table resourceHeader.WriteInt32(0); //Characteristics resourceHeader.WriteInt32(0); // TimeDateStamp resourceHeader.WriteInt16(0); // mayor version resourceHeader.WriteInt16(0); // minor verson resourceHeader.WriteInt16(0); // number of named entries resourceHeader.WriteInt16(1); // number of id'ed entries // Resource Directory Entry resourceHeader.WriteInt32(1); // ID (1) resourceHeader.WriteInt32(0x80000030); //pointer to next directory // Resouce Directory Table resourceHeader.WriteInt32(0); //Characteristics resourceHeader.WriteInt32(0); // TimeDateStamp resourceHeader.WriteInt16(0); // mayor version resourceHeader.WriteInt16(0); // minor verson resourceHeader.WriteInt16(0); // number of named entries resourceHeader.WriteInt16(1); // number of id'ed entries // Resource Directory Entry resourceHeader.WriteInt32(0); // ID resourceHeader.WriteInt32(0x48); //pointer to leaf // Resource Data Entry resourceHeader.WritePlaceholderRelative(resourceHeader.CurrentLocation.Increment(0x10)); IntToken SizeOfResourceBody1 = resourceHeader.InsertIntToken(); resourceHeader.WriteInt32(0); // codepage (default unicode) resourceHeader.WriteInt32(0); // reserved long RelativeSizeOfHeader = resourceHeader.CurrentLocation.Offset; // struct VS_VERSIONINFO { WordToken SizeOfResourceBody2 = resourceHeader.InsertWordToken(); // wLength resourceHeader.WriteInt16(0x34); // wValueLength resourceHeader.WriteInt16(0); // wType resourceHeader.WriteAsUtf16NullTerminated2("VS_VERSION_INFO"); resourceHeader.WriteInt16(0); // padding1 // struct VS_FIXEDFILEINFO { resourceHeader.WriteInt32(0xFEEF04BD); // dwSignature resourceHeader.WriteInt32(0x00010000); // dwStrucVersion resourceHeader.WriteInt32(0x00010000); // dwFileVersionMS resourceHeader.WriteInt32(0x00000000); // dwFileVersionLS resourceHeader.WriteInt32(0x00010000); // dwProductVersionMS resourceHeader.WriteInt32(0x00000000); // dwProductVersionLS resourceHeader.WriteInt32(0x3f); // dwFileFlagsMask; resourceHeader.WriteInt32(0); // dwFileFlags; resourceHeader.WriteInt32(4); // dwFileOS; resourceHeader.WriteInt32(1); // dwFileType resourceHeader.WriteInt32(0); // dwFileSubtype resourceHeader.WriteInt32(0); // dwFileDateMS resourceHeader.WriteInt32(0); // dwFileDateLS // rest of //struct VS_VERSIONINFO { // WORD Padding2[]; //WORD Children[]; WordToken varFileInfo = WriteEntry(resourceHeader, 0, 1, "VarFileInfo"); WordToken translation = WriteEntry(resourceHeader, 4, 0, "Translation"); resourceHeader.WriteInt32(0x04B00000); // codepage unicode translation.SetDistanceSinceTaken(); varFileInfo.SetDistanceSinceTaken(); WordToken varStringFileInfo = WriteEntry(resourceHeader, 0, 1, "StringFileInfo"); WordToken varVersion = WriteEntry(resourceHeader, 0, 1, "000004b0"); WriteEntry2(resourceHeader, "FileDescription", "Something compiled by Bart's compiler."); WriteEntry2(resourceHeader, "FileVersion", "1.0.0.0"); WriteEntry2(resourceHeader, "InternalName", moduleName + ".exe"); WriteEntry2(resourceHeader, "LegalCopyright", " "); WriteEntry2(resourceHeader, "OriginalFilename", moduleName + ".exe"); WriteEntry2(resourceHeader, "ProductName", moduleName); WriteEntry2(resourceHeader, "ProductVersion", "1.0.0.0"); varVersion.SetDistanceSinceTaken(); varStringFileInfo.SetDistanceSinceTaken(); RelativeSizeOfHeader = resourceHeader.CurrentLocation.Offset - RelativeSizeOfHeader; SizeOfResourceBody1.SetValue((int)RelativeSizeOfHeader); SizeOfResourceBody2.SetValue((int)RelativeSizeOfHeader); }