How to view the .cod file generated by VC++ compiler? - visual-studio

In Visual Studio there is a way to output the compilation result in the form of both source code, assembler code and the machine code by setting the compiler output properties:
The generated file has the .cod extension which is by default associated with Visual Studio. However, on opening the file it is just opened as a plain text file, no syntax highlighting etc. is available here:
Is there any tool that would allow me to visualize these files, at least to be able to separate the comments containing the source code, addresses and the assembly code optically?
EDIT: I tried NotePad++, my preferred editor, as the very firs solution and it is already quite good how I can visualize it there using Assembler as a language, but still there are problems with hexadecimal numbers, the assembly code is not aligned properly etc...

Try Notepad ++.
and don;t forget to select the Language by clicking Language->A->Assembly
You will get the necessary syntax highlighting

Related

How to make some kind of Automatization Visual Studio, which helps to analize code and can operate with controls labels - not variable names?

We works in Visual Studio and write programs on C# .Net ASP.NET
For making a standard in naming text labels to controls (button, options etc.) we think to write some code analizys program which can analize code (before, of after compilation to IL) and can found in code text strings which used for naming labels, titles,. (or if label text is stored in variable, check value and make a decision, correct that name, or not.
What tool can i use for automation like that?
I have looked up internet, and found a StyleCop, FxCom, Code Analizys systems - but i understand that this systems have rules only for variable names, not label of control.
How can i make add-on to Visual Studio, which can read code (edited in this time by programmer) and make a warnings while compiling project to avoid programmer use for label non-appropriate values?
Thanks.

How to put ASM source code comments in comment window of OllyDbg?

I have the source code of an assembly language program, which has comments on every line, and I want to see those comments in the comment column of OllyDbg's disassembly as it debugs. Without writing a full blown plugin, is there any way to do this?
Comments do not make it into the final exe. I don't even think comments make it into the pdb file for a debug build.
If you have the source code that includes the comments in the directory of the exe, open the exe in olly, click the view menu then click source, this will open the source file with your comments and all.
99% of the time, what you write in your source file, is what olly shows, unless you are using a lot of macros.
After some more experience I found that there are basically 3 approaches:
Modify the .udd files that OllyDbg uses to store comments directly.
Use a label plug (unfortunately the one I found does not work on 2.01)
Create a debug file in a format OllyDbg understands (DWARF I think)
Since 3 is pretty complex, my best option is probably 1.

Debug the program using preprocessed file output?

Let say I have a file that has a lot of preprocessor macros that generate loads of code. Normally when debugging such a file I wouldn't be able to step into macroses like functions as debugger does not have line number information. On the other hand it is possible to generate a preprocessed file using /P directive to the compiler, which will result in a file that contains all generated code and no macros.
Is it possible to make Visual Studio use preprocessed file for debugging?
One solution (not very convenient though) is to copy the preprocessed file back to the source file and compile it again. One must remember to generate the processed file without line numbers and to keep the original source code somewhere.

T4 vs UTF-8 vs VS2010

I'm trying to use T4 in VS2010, but I have a weird problem. T4 always shows error message "A directive was specified in the wrong format", although all directives are in correct format. It turned out this error was caused by a UTF-8 file prefix, which is not recognized by T4. Okay, I have to remove it. But every time I'm trying to save this file to ANSI encoding with an external editor, VS2010 changes it's encoding back to UTF-8. And the same when I modify file in VS2010. So T4 doesn't work again.
Any suggestions?
What Windows and Visual Studio language editions are you using.
T4 supports UTF-8 with/without prefix as it essentially replicates the encoding of the input template unless otherwise directed. (you have to close/reopen the output file in VS after changing encodings to see the switch). I'm not able to repro what you're seeing on EN-US Windows and VS.
If you do want to save as ANSI, you can use the File/Advanced Save Options menu in VS and pick a codepage.
I've found the reason, it had nothing to do with encoding, my bad. I copied some text from a sample, and it had wrong symbol for quotation mark (looking very similar visually, but having different char code). That made T4 parser fail.

Visual Studio C# disable unicode or utf-8 as file encoding and use ASCII instead

I am currently working on some LaTeX document which embeds C# files generated by Visual Studio 2008. My problem is that these files are encoded in UTF-8 with BOM. This causes LaTeX to produce output similar to the output described in this post:
Invalid characters in generated latex sources in Doxygen?
I know that I can use a tool like Notepad++ to convert the file to ASCII or some other format without BOM. But my intention would be to:
either cause LaTeX to use correct input encoding (until now I failed doing it with the package imports like:
\usepackage{ucs} % unicode functionality
\usepackage[latin1]{inputenc}
or cause Visual Studio to save the files without BOM or in plain ASCII
Otherwise I might edit the file (compile it and save it in VC#) and unintentionally introduce BOM again, which would break the code listing in the document.
Many thanks,
Ovanes
Visual Studio does not have this option, by design I believe, because .NET is built from the ground-up to use Unicode.
However, I don't believe Visual Studio is supposed to use the byte order marks. You said that Visual Studio is "generating" these files, but what process is really creating them? Is it the result of some sort of code generation tool? If so, that's the culprit and the place where you should focus.
I checked several of my code files and none of them contain the byte order marks.
EDIT: Changing Visual Studio Project Templates
In the comments the questioner said that these files were generated by the built-in Console Application project template. These are stored on your hard drive and can be modified if necessary.
Your installation path may vary, but on my system, I navigated to this directory:
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp\Windows\1033
Here I find ConsoleApplication.zip. I copied this to my desktop (for safety) and unzipped, and inside you find 4 files - a .vstemplate file, and the 3 files that are created by the project: AssemblyInfo.cs, ConsoleApplication.csproj, and Program.cs.
If you want, you can edit these files to remove the byte order marks, zip it back up, and replace the file in the source directory.
OR, to be safer, you can change the name of the template to "Console Project - No BOM" or something like that. In the .vstemplate file, there is a Name attribute that uses a Package attribute to call in information from somewhere by a guid. You can replace this name line with a simple line that specifies the name.
<Name>Console Application - No BOM</Name>
Then rezip the files, and put the zip file in the following path:
(My Documents)\Visual Studio 2008\Templates\ProjectTemplates\Visual C#
New projects created from this template should not contain the byte order marks, but remember, Microsoft apparently wanted those byte order marks in there, so your mileage may vary.
Item templates (like Class) can be modified in the same way - it shouldn't take too much exploring to find the default and user ItemTemplates directory.
I'm not sure I understand your scenario. But if you simply want to convert a file to ASCII from within Visual Studio select "File - Save As" and switch the encoding to ASCII.
have you tried \usepackage[UTF8]{inputenc}
In VS 2015 you can specify encoding using File -> Advanced save options... dialog
You can use the plugin for Visual Studio: https://vlasovstudio.com/fix-file-encoding/, this plugin prevents Visual Studio from adding BOM to the beginning of the file, so that way all of my files can have UTF-8 encoding and raw strings can contain special character and they will be displayed/written without any issues,

Resources