I need to extract separate assembly from a particular namespace in an assembly.
I can see separate name spaces when open the assembly with ILSpy, so I assume this can be done using System.Reflection library.
Does anyone know how to do this? Or any alternative approach for this?
Thanks in advance.
Related
I'm new to clang and I'm trying to add a #include<> after all the other includes are done.
#include<iostream>
#include<math>
// I want to add my include here.
I apologize if this is a silly question. But I'm not able to find which AST Matcher does this. I am referring to :
http://clang.llvm.org/docs/LibASTMatchersReference.html
I'm not sure AST analysis will help much: #include directives are replaced by the preprocessor before the code is parsed into AST. It seems they are not represented in the AST.
A different approach might be Clang's preprocessor hooks, which allow one to register callbacks at various points during preprocessing:
https://clang.llvm.org/doxygen/classclang_1_1PPCallbacks.html
I have looked up all I need to know on how to use a stopwatch, but I can't find out how to create one. MSDN has the info System.Diagnostics::Stopwatch but I don't know how to include system diagnostics into my program. Is there a #include and/or using namespace that I need?
I believe it's:
using namespace System::Diagnostics
This is in C++/cli which has access to c# libraries.
I am working on an embedded project and have to put a complete section of our code in a specific memory region. We are using avr-gcc.
The normal way to go is to tell GCC to put the function in a section with:
__attribute__((__section__(".text_sdram"))) void foo(void);
However, this would cost us a lot of effort plus the chance to "forget" one function.
We are using C++ and all the function that have to be in .text_sdram is put in a specific namespace.
Is it possible to put a complete namespace in a specific section?
Thanks in advance for your answers.
Pieter
According to function attributes the visibility attribute can be attached to a namespace, but it doesn't look like anything else can. You could try attaching the section attribute to your namespace using the same syntax as described for visibility. I don't expect it to work, and if it doesn't I'm fairly sure there's not a good answer. If your namespace is all defined in a single module, or can be rearranged that way, you can probably solve this with a linker script.
I need a way to edit the resources (A String Table, to be exact) of a compiled executable and I need to do it in C++.
Can anybody offer any guidance/sample code on how I can go about doing this?
Start with LoadLibrary() that and load an executable(the one you want to edit)
Then FindResource() and UpdateResource() as necessary.
Read all about it here:
PE format Resource Functions
If you're on Linux or OS X there's always the "strings" command that will print out all of the static strings in the executable. Combine that with something like "objdump" and some knowledge with a hex editor you may be able to cobble something together.
I don't know if that is even possible, once you have a compiled executable & it's just machine code, there isn't really a specific way to understand how to interpret it (and therefore find/edit the resources you're looking for)...i.e. once you have just the executable, you can't for sure know whether a word is an instruction in assembly or just a word representing a number, label, etc in assembly...
As far as I know.
You can have a look at the good old reference and source code of PeDump of Matt Pietrek. He does handle (read-only) the resources of PE files in C++. Maybe it will inspires you to solve your problem...
Is there a way to programmatically enumerate a namespace and its members in C++?
I have a large C++ program which utilizes several namespaces. I am unfamiliar with the codebase, and would like to determine which functions/classes/variables are associated with which namespaces.
My current approach involves simply removing the 'using namespace' directives one by one and checking what breaks during compilation, but I assume there is a much better way to achieve the same goal.
This is not possible in C++.
However, you can use external tools, such as Doxygen, that will create documentation (HTML, and other formats) that will list all the members of your namespaces.
Unfortunately, introspection is NOT one of C++'s big features. There's no way (within the language) to do what you want. You'll need an external code analysis tool (something that can parse the code and build a reference) to do the job. I use cscope for a lot of analysis, but to my knowledge it doesn't really know about namespaces, so probably not the right tool for you.
You can use a C++ front-end (e.g. Elsa) to do the job for you.
Also consider using a good IDE that has a 'Go To Defiinition' functionality (e.g. Microsoft Visual Studio).
You can start by running Doxygen to generate an index of all the functions/classes/namespaces defined in your project. Make sure to edit the settings to generate the index for undocumented symbols.
If you know which namespaces you're looking for, you can just generate a map file (g++ -Wl,-Map,MyMapFile.map). Then search for e.g. MyNamespace:: in the map file.