1

Topic: To learn who created a flow

I use indirect dll in a multi-threaded mode. This dll creates the flows and does of them callback calls in my code. It would be desirable to learn, in what my flow the flow in dll has been created. Unique my idea - to intercept CreateThread/ExitThread and is independent pens to build a tree of flows and to analyze it in callback functions. Can be eat more  a method?

2

Re: To learn who created a flow

Hello, Aniskin, you wrote: A> I Use indirect dll in a multi-threaded mode. This dll creates the flows and does of them callback calls in my code. It would be desirable to learn, in what my flow the flow in dll has been created. Unique my idea - to intercept CreateThread/ExitThread and is independent pens to build a tree of flows and to analyze it in callback functions. Can be eat more  a method? Most likely is not present. In CreateThread to any information on a current flow anywhere it is not transferred. But it is better to look in source codes, it can and not so

3

Re: To learn who created a flow

Deleted (misunderstood the answer).

4

Re: To learn who created a flow

Hello, Aniskin, you wrote: A> I Use indirect dll in a multi-threaded mode. This dll creates the flows and does of them callback calls in my code. It would be desirable to learn, in what my flow the flow in dll has been created. Unique my idea - to intercept CreateThread/ExitThread and is independent pens to build a tree of flows and to analyze it in callback functions. Can be eat more  a method? , and what problem the knowledge of the graph of flows would allow to solve? Basically, if to guarantee that simultaneously only one flow works with that DLL simultaneously, and Id this flow is written down in any global variable, that, receiving DLL_THREAD_ATTACH TLS-notifikatsiju, it is possible to write down Id the flow in TLS for DLL a flow.

5

Re: To learn who created a flow

Hello, Alexander G, you wrote: AG> Hm, and what problem would allow to solve knowledge of the graph of flows? Roughly speaking, I intercept in dll CreateFileW and I need to understand a context of current operation. AG> basically if to guarantee that simultaneously only one flow works with that DLL simultaneously As I wrote in the initial message, I use indirect dll in a multi-threaded mode.

6

Re: To learn who created a flow

Hello, Aniskin, you wrote: A> I Use indirect dll in a multi-threaded mode. This dll creates the flows and does of them callback calls in my code. It would be desirable to learn, in what my flow the flow in dll has been created. Unique my idea - to intercept CreateThread/ExitThread and is independent pens to build a tree of flows and to analyze it in callback functions. Can be eat more  a method? A little strange desire why not to store threadId a starting flow in an operation context?

7

Re: To learn who created a flow

Hello, Aniskin, you wrote: AG>> Hm, and what problem would allow to solve knowledge of the graph of flows? A> roughly speaking, I intercept in dll CreateFileW and I need to understand a context of current operation. Clearly, well then such graph can and helps. And can and is not present, if dll actually uses  and different operations in its same flow. For a context like file name there precisely it is impossible to be hooked?

8

Re: To learn who created a flow

A> I Use indirect dll in a multi-threaded mode. This dll creates the flows and does of them callback calls in my code. It would be desirable to learn, in what my flow the flow in dll has been created. Unique my idea - to intercept CreateThread/ExitThread and is independent pens to build a tree of flows and to analyze it in callback functions. Can be eat more  a method? ExitThread  it is optional, it is possible to open simply ( in itself) and to wait controllable flows (RegisterWaitForSingleObject it is direct and arises)

9

Re: To learn who created a flow

Hello, mjau, you wrote: M> Hello, Aniskin, you wrote: A>> I Use indirect dll in a multi-threaded mode. This dll creates the flows and does of them callback calls in my code. It would be desirable to learn, in what my flow the flow in dll has been created. Unique my idea - to intercept CreateThread/ExitThread and is independent pens to build a tree of flows and to analyze it in callback functions. Can be eat more  a method? M> a little strange desire why not to store threadId a starting flow in an operation context? Not absolutely understood your comment. Where also what to store? I here launched N flows, each of which fulfills operation OpN with usage dll. Dll for each operation creates an additional flow from which causes certain callback function. In parameters callback functions are not present the parameter allowing me to identify my initial flow. How to me it to define?

10

Re: To learn who created a flow

Hello, Alexander G, you wrote: AG> For a context like file name there precisely it is impossible to be hooked? No, there very much the general functions. Type ErrorHappens (Msg), and I should know, whether operation which this concerns callback a call is, silent or I nevertheless can show a window with an error. It simply example, but an essence approximately the such.

11

Re: To learn who created a flow

Hello, Aniskin, you wrote: M>> a little strange desire why not to store threadId a starting flow in an operation context? A> I here launched N flows, each of which fulfills operation OpN with usage dll. Dll for each operation creates an additional flow from which causes certain callback function. In parameters callback functions are not present the parameter allowing me to identify my initial flow. How to me it to define? And how you define, what operation concerns ? Or  strictly one-continuous and one operation happens at once time? In that case, would be ideologically correct to turn dll in separate process for an exception of different cheerful problems with one-continuous dll in the multi-threaded environment. In a case of one process there are no standard means to receive the parent of a flow, since Flows have no hierarchy, here or to fence bicycles or as a variant to rummage in TEB, but probability of that there there will be something approaching, is rather small.

12

Re: To learn who created a flow

Hello, mjau, you wrote: M> And how you define, what operation concerns ? The global list from pairs ThreadID-OpN M> Or  strictly one-continuous and one operation happens at once time? Dll allows operation in a multi-threaded mode, it is simple needs at me more than it is offered. M> here or to fence bicycles It and I am engaged.

13

Re: To learn who created a flow

Hello, ononim, you wrote: O> ExitThread  it is optional, it is possible to open simply ( in itself) and to wait controllable flows (RegisterWaitForSingleObject it is direct and arises) For tracing of end of a flow enough control through DLL_THREAD_DETACH from DllMain or TLS Callback, probably the Decision on waitings is hypothetically subject to race: the flow was already completed, and there can be a new flow with such ID (practically is not present, recycle there long). But it copes TerminateThread or to straight lines NtTerminateThread (for the loonies, ready to support such scenarios).

14

Re: To learn who created a flow

Hello, Aniskin, you wrote: A> Dll allows operation in a multi-threaded mode, it is simple needs at me more than it is offered. How it is possible  operation in a multi-threaded mode without provision of the mechanism of communication of request and the answer?

15

Re: To learn who created a flow

O>> ExitThread  it is optional, it is possible to open simply ( in itself) and to wait controllable flows (RegisterWaitForSingleObject it is direct and arises) AG> For tracing of end of a flow enough control through DLL_THREAD_DETACH from DllMain or TLS Callback, probably  did not speak that at it near at hand also the  is. However FlsCallback () it is not necessary AG> the Decision on waitings is hypothetically subject to race: the flow was already completed, and there can be a new flow with such ID (practically is not present, recycle there long). No. While is though one open  on a flow, it ID not . AG> But it copes TerminateThread or to straight lines NtTerminateThread (for the loonies, ready to support such scenarios). Yes

16

Re: To learn who created a flow

Hello, mjau, you wrote: M> As it is possible to allow operation in a multi-threaded mode without provision of the mechanism of communication of request and the answer? Scenarios happen everyones different. One of my actions - interception CreateFile and still steams of functions in dll. And in operation I do not know that will be transferred in CreateFile.

17

Re: To learn who created a flow

AG>> Hm, and what problem would allow to solve knowledge of the graph of flows? A> roughly speaking, I intercept in dll CreateFileW and I need to understand a context of current operation. Worthless  architecture. And if the author  zajuzal/solves  thread pool?

18

Re: To learn who created a flow

Hello, ononim, you wrote: O> Worthless  architecture. An essence of one of problems in more details - I in the hand-made article TC4Shell use (including) indirect library unrar.dll for unpacking rar archives. Roughly speaking to I specify to it "unpack some files in such that a directory which was selected by the user". Accordingly, if the user selected, for example, directory Program Files at unpacking happens ERROR_ACCESS_DENIED, and to me returns what  internal ERAR_ECREATE. And I want to ask the user in this situation, whether he wants to raise the rights to the administrator (recently created a topic about it). If the user wants, we raise, and we cause CreateFile with  the rights. But that it to implement to me it would be necessary to intercept CreateFile. During too time a row of operations of type of extraction of the sketch of a file in the Explorer should be silent without everyone UI. It is one of scenarios. O> and if the author  zajuzal/solves  thread pool? It will be insulting and is necessary to refuse the invention.

19

Re: To learn who created a flow

A> in more details - I in the hand-made article TC4Shell use the Essence of one of problems (including) indirect library unrar.dll for unpacking rar archives. Roughly speaking to I specify to it "unpack some files in such that a directory which was selected by the user". Accordingly, if the user selected, for example, directory Program Files at unpacking happens ERROR_ACCESS_DENIED, and to me returns what  internal ERAR_ECREATE. And I want to ask the user in this situation, whether he wants to raise the rights to the administrator (recently created a topic about it). If the user wants, we raise, and we cause CreateFile with  the rights. But that it to implement to me it would be necessary to intercept CreateFile. During too time a row of operations of type of extraction of the sketch of a file in the Explorer should be silent without everyone UI. It is one of scenarios. I would carry out all this business in separate process. If there was a performance question  time delays on its start - would make this process , dying only when its master dies. As a variant - COM the server th.

20

Re: To learn who created a flow

Hello, ononim, you wrote: O> I would carry out all this business in separate process. And in what advantage of separate process?

21

Re: To learn who created a flow

O>> I would carry out all this business in separate process. A> and in what advantage of separate process? Well  in that that there it is not necessary to supervise flows and it is possible to show the access denied without troubles

22

Re: To learn who created a flow

Hello, Aniskin, you wrote: A> I use (including) indirect library unrar.dll There are source codes unrar, the license for them forbids to study algorithm unrar, and to play back it for a compression, but allows to modify under the surrounding and  in the application. http://www.rarlab.com/rar_add.htm http://www.rarlab.com/rar/unrarsrc-5.5.8.tar.gz

23

Re: To learn who created a flow

Hello, Alexander G, you wrote: AG> There are source codes unrar.dll It I know. unrar.dll is only a special case.

24

Re: To learn who created a flow

Hello, Aniskin, you wrote: A> I Use indirect dll in a multi-threaded mode. This dll creates the flows and does of them callback calls in my code. It would be desirable to learn, in what my flow the flow in dll has been created. Unique my idea - to intercept CreateThread/ExitThread and is independent pens to build a tree of flows and to analyze it in callback functions. Can be eat more  a method? On best-praktisu  dll should transfer in lpParameter the data structure when the new flow creates. The flow created by this call CreateThread should select a data structure in the "local" copy and in callback to transfer that that in lpParameter came. So years 20 do. If in indirect dll it did not make, you that inattentively passed that.

25

Re: To learn who created a flow

Hello, Aniskin, you wrote: A> I Use indirect dll in a multi-threaded mode. This dll creates the flows and does of them callback calls in my code. It would be desirable to learn, in what my flow the flow in dll has been created. Unique my idea - to intercept CreateThread/ExitThread and is independent pens to build a tree of flows and to analyze it in callback functions. Can be eat more  a method? With the registration  stated in other branches, the task is reduced to obtaining in  an operation context in which frames this is fulfilled . One of the general-purpose methods - to use the approach similar to volume which is used in ATL Thunk, it is possible to look at implementation as in most ATL/WTL - for WndProc, and various variants in Google.