Using v-table thunks to chain procedure calls

后端 未结 2 451
再見小時候
再見小時候 2021-01-24 21:14

I was reading some articles on net regarding Vtable thunks and I read somewhere that thunks can be used to hook /chain procedures calls.

Is it achievable?

Does a

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-24 21:56

    Well, you read that thunks are a solution, and now you are looking for a problem to solve?

    Thunks, generally, are short "forwarding" functions that provide minor - usually hardcoded - adjustments.

    VTable chunks are explained very well in wikipedia at the moment. They use the common pattern: generate a small function to avoid calculation / extra work at run time.

    Other places I've seen / used thunks:

    Associating a window handle with a window object: for each window to be subclassed, a small thunk is generated on the fly that calls the window procedure with the object reference, the thunk is then used as window procedure.

    Delay Loading DLLs: the thunk makes sure the DLL is loaded the first time any function is called.

    Trapping COM interface calls: the thunks provide an injection point for diagnostics, and jump to the actual method.

提交回复
热议问题