Mono.Cecil Modifying the RVA of a method - mono.cecil

I would like to modify the RVA of a method using Mono.Cecil. I noticed a similar question asked back in 2007 but is this doable in 0.95?
For eg: methodA.RVA = 0x1234;
I understand Mono.Cecil compute and write RVA during compilation but
are there anyways to go about modifying the RVA?
It can be done using CFF explorer though.
Thank You.

No this is not possible: that's simply not the goal of Mono.Cecil.
Cecil let you read, modify and write the managed code and metadata, but when it comes to the PE file organization, that's considered an implementation detail.

Related

How to choose a specific msvcr.dl in Nim?

I would like to use an old msvcr71.dll when compiling Nim.
Is there a way to do so? If yes, how?
This is explained in the manual, right here. As StackOverflow doesn't like link responses, a copy-paste:
proc imported_proc(): ReturnType
{.cdecl, dynlib: "msvcr71.dll", importc.}
This asumes there is a function in msvcf71.dll called imported_proc that you want to wrap in your Nim code without changing the name.
You can also tweak which libraries to load when compiling, as explained here:
$ nim c --dynlibOverride:msvcr71 --passL:msvcr71.dll program.nim
Didn't test any of the code, hope it helps. You can always try to find some code that does this kind of linking, for example https://github.com/khchen/wNim/blob/master/wNim/private/winimx.nim or maybe https://github.com/brentp/hts-nim/blob/master/src/hts/private/hts_concat.nim

Entry Point for CFI implementation in clang/llvm?

I want to implement Control-Flow Integrity in Clang/llvm. (I know there is Forward-Edge CFI already implemented)
My problem is, that I have never implemented anything for a compiler (I am new to compiler based approaches) and therefore don't know where to start.
For my implementation I need first to get a list of all calls (internal => no library calls) and than change how functions are ended (for example: pop + jmp instead of ret).
Does anyone know where to start or even if this is possible using the plugin system (LibClang, Clang Plugins, LibTooling)?
Thanks in advance
here is a advanced one CCFI :
https://bitbucket.org/CCFI/
it based on this :
http://iot.stanford.edu/pubs/mashtizadeh-ccfi-ccs15.pdf
you can learn that how to add your code to each jmp,call,jmp,ret and so on...

Java Card program using GPJ

So I was tasked to create a java client to communicate with java card.
Right now I can authenticate, write and read data using javax.smartcardio but having a bit of trouble trying to upload cap file and install it.
So after googling around, I found that I can use gpj as a library and use it in my java application to upload and install the cap file.
The problem is I can't find any documentation for gpj and I can't understand the code without one.
Here's one that I have trouble to understand public void installAndMakeSelecatable(AID paramAID1, AID paramAID2, AID paramAID3, byte paramByte, byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
Even when I look on the other part of the code, I can't find out the last parameter since all that use these method will pass null.
So if anyone know where can I find the documentation, I would be really glad. Or better yet, another library that can upload cap file and have some documentation with it.
so far, I've found gpj,jpcsc,jcManager and opal.
Nevermind, it seems that I'm not a clever guy.
For future reference, you can find out what to pass to what method by looking through the main method of the Global Platform Services class. For parameter that you are not sure what to pass, just use null.

How does cocoa's obsolete CGSCStringValue function actually work?

I've been using CGSPrivate.h for cocoa development under MacOSX for a while. I'm now using it under Lion (10.7.x), and it turns out that the CGSCStringValue() function described in that file no longer exists under that OS version.
I want to make use of the functionality of CGSCStringValue() -- i.e., converting a CGSValue to its associated char* when appropriate -- and I'm wondering if anyone knows how that function is actually implemented.
I've tried various forms of casting of the CGSValue, but to no avail. So could anyone point me to some documentation or actual cocoa code that runs in 10.7 which will take a CGSValue that's associated with a string as input and return its char* equivalent?
Thanks in advance.
It's implemented by checking the type (to make sure it's really a CFString) and calling CFStringGetCString(). You can do that yourself, there is no real need for CGSCStringValue.

Why you need to use C++'s "data_seg"

When I trace one open source, I saw someone has the following code
#prama data_seg(".XXXX")
static char *test=NULL;
FILE *f1;
#prama data_seg()
However, even after checking http://msdn.microsoft.com/en-us/library/thfhx4st(VS.80).aspx, I still not sure why we need to do so, can someone help me to understand this part?
thank you
This is usually done to share the data that's designated to be in that segment. The code you have above will normally go in a DLL. You also use a .def file that specifies that the ".XXXX" segment is going to have the "SHARED" attribute.
When you do all that, the data in that segment gets shared between all the processes that load the DLL, so those variables are shared between all those processes.

Resources