Is it possible to record data being passed from a program to a library or a function using DLL injection - dll-injection

Is it possible to use DLL injection to record the data passed in a function call and can this system be used for internal calls and external calls aswell? And how would one achieve that in rough terms?
Thanks in advance

Yes its possible. When a call is hooked, you can take the arguments and record as you like. For internal calls, you will probably need to know the VTables to hook those calls by their index in VTable.

Related

Use data in plugin outside the SCIPsolve call

I would like to share data between a plugin and my main function (this is, use it outside the call to the SCIPsolve function). For example, a branching rule sets a certain int variable to 1 and then, after the optimization is done I can go and check wether the variable was changes or not.
I thought I could accomplish this by using the plugin data (e.g. SCIP_BranchruleData) but it can't be accessed from outside the plugin's source file.
How can I do it?
I will appreciate any help.
Rodolfo
An easy solution is to add a getter function to the branchrule which you implement in branch_xyc.c and prototype in branch_xyz.h. Then your code needs to include the header file and you can access the fields in the branchdata.
See also the documentation of branch_allfullstrong.cpp where an external function is defined and you can see how to get the branchdata and branchrule when passing just a SCIP pointer.

DLL zOS dynamic

I'm compiling a COBOL program as a DLL in zOS using the compiler options
PGMN(LM),DLL,EXPORTALL
When I do this, it also forces the compile to be NODYNAM. In this context, is there some other parm I can use to force the CALLS to to other subprograms from this to be dynamic (i.e. resolved at run time).
I know I can use the CALL variable-name approach to accomplish this, but I can't do this with system routines like DSNELI, the DB2 call interface.
Does the IMPORT option have something to do with this?
Thanks!
All DLL's must be complied with NODYNAM. This cannot be avoided. As you pointed out using NODYNAM does
not preclude dynamic program calls using the CALL var-name approach. As long as you are using dynamic calls
to locally developed routines you will maintain all of the advantages of not having static linked modules in
your programs.
Be less concerned about static linked system modules such as CALL 'DSNELI'. These are
stub programs that will dynamically load the appropriate language interface module at
run time. See Universal Language Interface.
Generally speaking, you want the calls to those system routines to be static. The routines tend to be stubs that locate the "real" routine at runtime.

Is there a way in IntelliJ to make a usage search of a method and filter this by specific arguments passed to the method?

I have a method in my Service class which executes an hibernate update for any domain object:
update(Object obj)
It's called from lot's of classes in my project for different kind of objects. I would like to find all usages of this method when it's called for a specific domain object. I.e. call methods call wich executes an update of my Title object:
serviceClass.update(Title title)
I'm using IntelliJ as my IDE and I'm wondering if there is a way to find all those usages.
Does anyone have an IDEA how to do this?
Thanks a lot in advance,
Ronny
I've tried it with a small sample project and was able to achieve the desired behavior using Structural Search and Replace feature with the modified method calls template:
$MethodCall$ Text constraints, Text/regexp should be set to update so that methods with other names are ignored. $Parameter$ Occurrences count, Minimum count should be set to 1 to ignore method calls with no or more parameters.
Results:
If you're interested in the call chains that are providing a specific input into a given method, try the Analyze->Data Flow to Here command.
This allows you to see which values are passed in, through which call chains. And, for example, where null values might be coming from.
Quite a powerful feature, really.

How to call non-exported functions of a DLL?

I need to call (get) non-exported functions of a DLL. Unlike PE export table, non-exports do not have any table having entries for these. More over, all disassembler like IDAPro and other debuggers only show exported function names with decorated names (After Shift+F3 in case of IDA) and show all other functions like sub_000FF sorts of.
Any idea how to get and call non-exported functions of DLL programmatically? (GetProcAddress after LoadLibrary only calls decorated exported functions not designed for non exports.)
I solved the problem myself after usage of of DIA SDK .
I collected the function address from there and then via assembly rotuines I am able to call the function directly.
Thanks everybody for comments.

How to get function name against function address by reading co-classs'es vtable?

I need to call the co-class function by reading its address from vtable of COM exposed interface methods. I need some generic way to read addresses.
Now I need to call the function, which would have specific address(NOT KNOWN) arguments(parameters) which I have collected from TLB, and name as well. How that address corresponds to that function name to which I am going to call.
For this I need to traverse vtable which is holding functional addresses, LASTLY need to correspond function address with NAME of that function. This is I dont know. How? More over one function with the same name may appear in vtable(Overloading case). In that case we need to distinguish function names w.r.t their addresses. How to tackle ?
Regards
Usman
Respectfully Sir.!!
I am designing a Unit Testing framework for which I need to pull out all function signatures of certain COM Exe or COM DLL to show in the grid or whatever interface to user, so that later by selecting certain function signature from that list, He/She can execute that function after providing the arguments(data as parameters) to that function. All this would be done dynamically at runtime, on runtime function will be called whatever user wants.
This can be achieved from various ways.
By providing TLB(Type libraries) we can pull every function signature and can show every signature to Grid control or on Tree control. Second step is to call these functions at runtime by providing data. Calling require data and address of functions(or Names). I would have some GUI panel or control which will take the data from user and that data would then become as arguments.
Now real problem comes for which I posted earlier. Call to functions/methods of that interface exposed by COM component implemented by co-class. This requires to trail down vtable of interface exposed by component , finding the address of that function and then need to know IS IT REALLY THAT ADDRESS TO WHICH I AM GOING TO CALL AS FUNCTION? So this requires to translate that address to function name and then comparison some string comparison would decide that whether it was really that function name which USER CLICKED from Tree Control showing signatures.
Suggestions or reccommendations?
Call ITypeInfo::GetFuncDesc for each function and the FUNCDESC structure you get back contains the vtable index in the oVft member. Cast an interfaces vtable to void** and just use it as an index.
Of course quite why you need to do this I do not know :)