Exetools  

Go Back   Exetools > General > General Discussion

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-13-2019, 22:12
chants chants is offline
Family
 
Join Date: Jul 2016
Posts: 456
Rept. Given: 2
Rept. Rcvd 30 Times in 18 Posts
Thanks Given: 378
Thanks Rcvd at 726 Times in 333 Posts
chants Reputation: 30
A Quiz in Advanced RE (Asm/C)

Just some interesting stuff for those interested. If anyone has their own, please share.

1) In what special circumstance is sizeof(ptr1) != sizeof(ptr2)?
2) Name the computer science algorithm which places type dependencies (typedefs) in a correct order. BONUS: how to minimize forward declarations (from structure pointer circular dependencies) and what is the complexity of the graph problem?
3) How are capture arguments of lambda functions dealt with in assembly, and with which calling convention is it effectively invoked?
4) What is the difference between parameters in a variadic function (…) verse one converted to use a va_list?
5) A recursive function has many parameters which are never changed, or even better has merely more than one argument and is using a lot of stack space, while not having an guarantee as to its depth limit. How to make this safe?

Code:
1) In compilers with compact and medium models where function pointers and data pointers could have near or far sizes. 2) Depth first search with post-order traversal, which keeps track of 3 colorings: visited (normal DFS single visit), resolved (to prevent cycles) and lastly the both unresolved/unvisited state. I don't have the answer to the bonus currently - my guess its an NP complete problem. 3) The capture arguments are turned into a data structure, and then this structure is constructed on the stack. The calling convention is basically the __thiscall calling convention as the structure and the function call are as if a class were initialized and its member function executed, just as the older functor class works. However, there is no construction/destruction and compiler optimizations make it slightly more efficient and advantageous. 4) va_list is merely a pointer to the first argument of the ellipsis in the simplest case which is incremented on consumption. Otherwise compiler and environment dependent, it becomes a pointer to a data structure describing the registers, stack, and current position. 5) Ideally, remove the recursion, make the unchanged variables local variables, and use a dynamic memory stack object such as std::stack, and push and pop the changing variables - taking special care for the pre-traversal (easier, always remove top) and post-traversal nuances of recursion (only remove top after all children recursed). Alternatively, create a class for the traversal, which makes the unchanged variables as member variables initialized via a constructor. Then combine all changing arguments into a data structure and make a single argument call which uses pointers to the data structure and member variables.

Last edited by chants; 08-13-2019 at 22:22.
Reply With Quote
The Following 3 Users Say Thank You to chants For This Useful Post:
computerline (08-14-2019), niculaita (08-13-2019), p4r4d0x (08-15-2019)
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT +8. The time now is 10:58.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX