Is there a disassembler with modification and reassembly capabilities for a 32-bit executable? [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I have a class project where we need to take a 32-bit executable written in C++ and disassemble it and modify the assembly code and then reassemble it. We're supposed to do things like hardcode cheats into the game.
I've been searching for hours and I can't find any software that will do this. I've looked at Ollydbg and spent about two hours with it and couldn't really figure out how to get it to work. I utilized Cheat Engine and that actually worked out really well for me - I was able to isolate the code modifying the addresses I cared about and replace it with code to have a favorable impact on the game, but as far as I can tell Cheat Engine has no ability to recompile the modified code.
This is a fairly lower level Computer Science class so please take into account my ability level when making suggestions but if there is any software out there or alternative ways that will allow me to do this I would greatly appreciate it. Thanks!

Since you mentioned OllyDBG and Cheat Engine I'm going to assume you're using Windows.
First, you can use OllyDBG to save a file, but for some reason I can't find this option in OllyDBG 2, only in older versions (like 1.10). You can right-click on the code window and then copy to executable > all modifications, A new window will open, right-click on the new window and then choose save file.
An alternative that I really like is x64dbg. it's an open source debugger/disassembler and has an option to save changes via "Patches".
Another option is to apply the changes via an hex editor, which allows you to modify any file (including executables) in a binary format. It is, of course, a bit harder to do since you need to translate your changes to op-codes manually, but if your changes are not too big or only consisting of modifying some constants it can be a faster and easier solution. There are a lot of hex editors out there but my favorite is XVI32.
What I personally like to do is to modify the memory via code using Windows API's WriteProcessMemory and ReadProcessMemory since it allows you to do this things dynamically.

Related

Doc string facility in C++ [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Languages like Python, MATLAB, E-Lisp have this nice facility for doc-strings.
With this feature using just a few keystrokes in the terminal, you can fetch the documentations of the functions / module you have written and imported into your code.
Now is there any "technique" (library, Editor tricks , whatever to ) to get a similar facility in
C++ / C. Suppose I include the documentation of the function within the source file at
the head of the function,
then I would like to type a command like getinfo at the terminal. (something
like a man page)
I know such a 'man' facility exists for many C functions, but the documentation for these functions are written in separate text files from the source code. I would like the
documentation to be in-place
You can use something like doxygen. It has support for generating man pages, among other formats.
Visual Studio can/will generate popups containing information extracted from DocXml formatted comments. You have to compile with /doc, which will extract the XML from the comments to a .xdc file. Then you have to run xdcmake to compile the .xdc files into an xml file. You'd typically handle all this automatically in the build process, so you don't have to do much manually (except write the comments themselves, of course). The one thing to keep in mind, however, is that the code (at least a declaration) has to build before you get the popups.
I feel obliged to add that IMO, most such comments are generally pretty close to useless. If a corporate standard makes them unavoidable, so be it -- but if they're honestly providing any useful information, I'd consider that an indication of a problem ("Code smell", if you prefer that wording). In most cases, the combination of the name of the function (or whatever) and the names/types of the parameters should make the use of the function quite clear.
If you notate your code with comments in a syntax similar to Javadoc, you can generate a documentation for your code, in various different formats, using Doxygen. It can generate, among other things, man pages, but it seems that the preferred output format people use is HTML pages.

C++ code dependency / call-graph "viewer"? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
is there such a thing as a (free) tool that would display a graph of all functions call in a given function?
For instance, if I use it on a complex function fun() I'm trying to understand, it would show me all the functions called by fun() in order, then I would have the possibility to see the same thing for the function called by fun(), and so on.
I'm looking for this for C++ code.
Does such a thing even exist?
edit : I am using VS 2008 if that helps, but I was thinking that such a software would work on the source files anyway
Doxygen can do this. See the CALL_GRAPH configuration option:
If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will generate a call dependency graph for every global function or class method. Note that enabling this option will significantly increase the time of a run. So in most cases it will be better to enable call graphs for selected functions only using the \callgraph command.
Yes, Eclipse CDT Call Hierarchy view provides exactly this. Moreover, this view has 2 options:
Show Callers
Show Callees
You are asking about second one, but I am prefer the first one in code analysis.
Intel(R) Single Event API is free open-source project that utilises GraphVis for call-graph visualisation. It takes a bit of labour to do manual or compiler-automated instrumentation, but beside statistics and call-graphs you will get the overtime views as well.
Yes such things exist. Google under the heading static code analysis. There are, for example, tools such as Understand, and it is extremely likely that your compiler can do this too for which I refer you to its documentation.
You can use callgrind, and it's GUI tool kcachegrind.
I don't know of any tool specially desgined for this. However, there are a few ways of doing it:
Using a IDE (QtCreator is free, Visual Studio Express might also be helpful, Eclipse CDT)
Using (ctags)[http://ctags.sourceforge.net/] and a able text editor.
Using callgrind and the several views it brings. Advantage: you get to see the functions that are really called. Disadvantage: only runs in unixes, and you have to profile.
Using Doxygen... this one is really fancy, as it generates an html "view" of your code, provided that you supply the correct options.
g++ and most compilers can do what you want. It is called profiling. Also there is the oprofile. A profiler gives you the call graph of an application after its execution. This is very useful to study code, you can also walk through the [debug] output as you look at the graph. A code analyzer, in contrast, will give you all possible call paths however, you will not be able to see the significant path easily.
VC++2008/2010 profiler generates among others the file *CallerCalleeSummary.csv, that contains this information. And this is the link to the article explaining how to use it with sample program: Profiling of C++ Applications in Visual Studio

Good free profiler that supports MingW32 please? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I asked in another thread, how to profile my stuff, and people gave me lots of good replies, except that when I tried to use several of free profilers, including AMD Codeanalyst for example, they only support Microsoft PDB format, and MingW is unable to generate those.
So, what profiler can help me profile a multi-threaded application with Lua scripting and is compiled with MingW?
EDIT: gprof is crap, the awnser that says why I don't want it, is right on the spot... If I get all the functions that it litsts as troublesome, NONE of them are related to the issue that I have (there are a certain action that causes a massive slowdown, and I can't figure why, and gprof can't figure it either)
If you don't want to use gprof, I'm not surprised.
It took me a while to figure out how to do this under GDB, but here's what I do. Get the app running and change focus to the app's output window, even if it's only a DOS-box. Then I hit the Control-Break key (while it's being slow). Then GDB halts and I do info threads and it tells me what threads there are, typically 1 and 2. I switch to the thread I want, like thread 2. Then I do bt to see a stack trace. This tells me exactly what it was doing when I hit Control-Break. I do this a number of times, like 10 or 20, and if there's a performance problem, no matter what it is, it shows up on multiple samples of the stack. The slower it makes the program, the fewer samples I have to take before I see it.
For a complete analysis of how and why it works, see that link.
P.S. I also do handle SIGINT stop print nopass when I start GDB.
Does gprof not do it?
I thought MingW provided a gprof version to go with it.
If you want to profile Lua scripting, I could suggest using the LuaProfiler: http://luaprofiler.luaforge.net/manual.html. It works quite nicely.
I would strongly suggest implementing some sort of timers or your own profiler to get a simple profiling tool. A really simple one is to just output the times when certain points in your code is hit, output those times into a textfile and then write a simple lua or python script to parse the file and filter the interesting information.
I've used this (or a slightly more complex) version of profiling for most of my hobby-projects and it has proven very helpful.

Code polisher / reformater for C, C++ or Fortran [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Suppose you have got a bunch of files written in C, C++ or Fortran, by different authors, with different opinions on formatting, how to comment, and so on. I think many people know situations like these.
Are there any free tools for ends like:
uniform format of code (indent, etc.)
create standard comment bodies
rename variables
?
Have a look at
AStyle. It's a command line based formatter/beautifier. It doesn't handle Fortran though it works with C, C++, C# and Java
You can have a look at the indent (unix) command. It doesn't do everything you are asking for , but that's a good start I think
For Fortran there is plusFORT, which can do much more than what you ask for, such as reorganizing code and translating from FORTRAN 77 to Fortran 90. See http://www.polyhedron.com/pf-plusfort0html and http://www.polyhedron.com/pflinux0html
The CDT Plugin for Eclipse has great formatting and refactoring tools for C/C++.
The formatter can be customized to fit almost all needs.
Also the refactoring tools are quite powerful and renaming variables, classes etc. is an easy and safe task with them. (They use the indexer/parser to recognize scope of variables, so its not a simple search and replace. Matching patterns within comments can be changed automatically, too).
However, as far as I know there is no batch processing possible.
Edit: Another - obvious - drawback is, that you have to create a project to make the indexer (and thus the refactoring tools) work. So at least you have to add all include paths and important compiler defines to project settings.
I never tried, but the indexer should work fine without a real compiler available, but it may be necessary to make the project to use the "internal builder", otherwise you cannot set include paths. (I'm unsure about this, because I use the internal builder with gcc in my projects - this works fine.)
I've used Uncrustify with UniversalIndentGui for formatting C++ code. It works pretty well. Uncrustify offers many customization options and UniversalIndentGui "offers a live preview for setting the parameters of nearly any indenter. You change the value of a parameter and directly see how your reformatted code will look like."

Visually marking conditional compilation [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
We have a large amount of C/C++ code that's compiled for multiple targets, separated by #ifdefs. One of the targets is very different from the others and it's often important to know if the code you're editing is compiled for that target. Unfortunately the #ifdefs can be very spread out, so it's not always obvious which code is compiled for which targets.
Visual Studio's #ifdef highlighting can be helpful for visually identifying which code is compiled for which target, but changing the highlighting apparently requires modifications to the project file.
I'm interested in finding a tool or method that can help coders quickly recognize which targets are using each line of code. Even if it requires some sort of manual in-source annotation I think it could still be helpful. Best case it's automated, not tied to a specific editor or IDE, and it could be configured to warn in certain conditions (eg "you modified some code on Target X, be sure to test your code on that platform!").
If your code is getting that big that you can't tell what #ifdef your in then it's time to refactor your code. I would recommend that you refactor it into seperate cpp files per platform.
I noramlly only use #idef when the code is only one or two lines long, any longer and I normally refactor into it's only function or class into there own cpp file. That makes it simple to figure out where you are.
Check out Visual SlickEdit. The "Selective Display" option might be what you are looking for. I can't find any on-line documentation on it, but it will allow you to essentially apply a set of macro definitions to the code. So you can tell it to show you the code as the compiler will see it with a set of macros defined. This is a lot more than preprocessor output since it literally hides blocks of code that would be excluded based on the macro definitions.
This doesn't give you the ability to answer the question "Under what preprocessor conditions is this line of code included in compilation" though. The nice thing is that it applies the selective display filter to searches and printing.
I know for a fact that eclipse cdt does it. It has other nice features and some not-so-nice features for an IDE. Now, I code with vi, so I might be biased.
I don't know if there is a tool for this already, but I'd guess would be fairly easy to roll your own by using the precompiler. Precompile your file with a set of specific #defines and the output is what the compiler sees for that platform. I reckon this is not the same as highlighting the current file, but it can be automated and integrated into your IDE, push a button get a temp file with te current edited one under specific #define. Didn't try it myself, is just an idea.
PS. Yes, I had to read couple times your post to searching for where exactly is 'code coverage' involved lol.
Check XRefactory and Cscout.