Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
General / Re: TThread - How to stop a thread?
« Last post by GetMem on Today at 08:38:39 am »
@Slawek
You cannot combine your "FIN" method with MyThread.Terminate it can lead to exception. When you set Fin to true, the thread's Execute method is exited and the thread terminated. At the time you call MyThread.Terminate, the thread is long gone.
A better solution is to check the Terminated flag before you do a long operation inside the thread, if Terminated is true, break the for cycle and exit the thread. On the other hand if the thread has finished all tasks, and terminated is still false, put the thread to idle and wait until MyThread.Terminated is called from the main thread. Something like this:
Code: Pascal  [Select][+][-]
  1. procedure TMyThread.Execute;
  2. var
  3.   I: Integer;
  4. begin
  5.   //...
  6.   for I := 1 to 9 do
  7.   begin
  8.     if Terminated then
  9.       Break; //abort
  10.     newStatus := 'Task no ' + I.ToString;
  11.     Sleep(500);
  12.     if newStatus <> fStatusText then
  13.     begin
  14.       fStatusText := newStatus;
  15.       if not Terminated then //only syncrhonize if terminated is false
  16.         Synchronize(@Showstatus);
  17.     end;
  18.   end;
  19.   while (not Terminated) do
  20.     Sleep(100); //thread is idle, wait until MyThread.Terminate is called
  21. end;

The idea is to create, terminate and free the worker thread(s) from the main thread. When you wish to free a particular thread:
Code: Pascal  [Select][+][-]
  1. MyThread.Terminate; //this will set the Terminated flag to true
  2. MyThread.WaitFor;
  3. MyThread.Free;
  4.  
WaitFor is critical. Not calling WaitFor can lead to deadlock(worker thread waits for the main thread, main thread waits for the worker thread...).

PS: If you have a list of mythreads, just before a particular thread goes to idle, set a public boolean variable Fin to true. From time to time loop through the list, check if a thread is idle(fin := true) then terminate/free the thread and remove it from the list.
2

That begs the question: how do you know that the parameters and types used in your declaration ...:
Code: Pascal  [Select][+][-]
  1. function MTAW(filename: string; AmplitudeTh, BarrierValueForAutoLoc, coff_TimediffBetweensta, Va, xp, xk, yp, yk, zp, zk: single; SensorForLocation: Tpindex): TMTAWSOLUTION; stdcall; external 'F:\wz_work\DelphiWork\hello word\MTAWDll.dll';
  2.  
.. are correct ?

Are you just winging/jolo it ?

If it is a library written in C then for one thing it is not using type string, rather pchar and/or pwidechar. pascal type Single is also not the same type single as used in c.


This is what I decompiled.
Code: Pascal  [Select][+][-]
  1. Mtawdll::MTAW(System::UnicodeString,float,float,float,float,float,float,float,float,float,float,System::DynamicArray<int>)     
  2.  

There are corresponding field descriptions in the document, but the last SensorForLocation:Tpindex is not sure, look at the naming and decompile it is an array.

The entire method name corresponds to the document, so it should be a delphi program.

3
General / Re: Where are the components?
« Last post by TRon on Today at 08:20:47 am »
Downloaded from sourceforge
Unfortunately naming the website is not enough. There are forks floating around. Not only that but in my experience source-code from lazarus packages from sourceforce do not match the source-code in the packages from OPM.

OPM downloads from the original repository and which is specially crafted for/supported by Lazarus and therefor should work with OPM.

Since you have manually installed/extracted the package on your earlier attempt (project use), i wonder if that perhaps conflicts when trying to install the package by the IDE package install method (I honestly have no idea).

edit: also important to know is version of FPC and Lazarus and platform you try this on (we can't trust a signature)
4
This is a library provided to us by a third party, and the documentation is also an incomplete document, because the docking personnel have left, so there are only these remnants, and this is the first time I have come into contact with it, so many things do not know how to do it. is correct
That begs the question: how do you know that the parameters and types used in your declaration ...:
Code: Pascal  [Select][+][-]
  1. function MTAW(filename: string; AmplitudeTh, BarrierValueForAutoLoc, coff_TimediffBetweensta, Va, xp, xk, yp, yk, zp, zk: single; SensorForLocation: Tpindex): TMTAWSOLUTION; stdcall; external 'F:\wz_work\DelphiWork\hello word\MTAWDll.dll';
  2.  
.. are correct ?

Are you just winging/jolo it ?

If it is a library written in C then for one thing it is not using type string, rather pchar and/or pwidechar. pascal type Single is also not the same type single as used in c.
5

If you are truly decompiling a library that is not intended to be shared (closed/undocumented library) then you are basically on your own. There are some tools available that are able to obtain some valuable information about executables and DLL's but unfortunately my Windows days are long gone (e.g. I have no idea what tools to use these days).

You could always patch the library (overtake the original functions, show the passed parameters and call the original function) in order to obtain more information or run things through a debugger (olly comes to mind if that still exists)

I will try to find out how to solve it, thank you for your reply.
If you have an idea, you can reply next time


6
General / Re: Where are the components?
« Last post by Badger on Today at 08:13:58 am »
Downloaded from sourceforge
7

What is the name of the library and/or where can I obtain more information about the library ? (yes, I know you wrote the exact filename "MTAWdll.dll" but what does the abbreviation MTAW mean or what did the author named the DLL ?)

If it is a 3th party library that is distributed then there usually is an accompanied header file so that you know what functions (and their declaration) are present in the library and how the parameters are suppose to be used.

If you are truly decompiling a library that is not intended to be shared (closed/undocumented library) then you are basically on your own. There are some tools available that are able to obtain some valuable information about executables and DLL's but unfortunately my Windows days are long gone (e.g. I have no idea what tools to use these days).

You could always patch the library (overtake the original functions, show the passed parameters and call the original function) in order to obtain more information or run things through a debugger (olly comes to mind if that still exists)


This is a library provided to us by a third party, and the documentation is also an incomplete document, because the docking personnel have left, so there are only these remnants, and this is the first time I have come into contact with it, so many things do not know how to do it. is correct
8
General / Re: Where are the components?
« Last post by TRon on Today at 08:04:11 am »
hmz, that sounds like either a question for the author of fpspreadsheet and/or OPM manager (or both)

But before doing so: where did you obtain the package from ? (link please)
9
I don't know what language the specific three-party library is. I got this result based on an incomplete document and decompilation。
What is the name of the library and/or where can I obtain more information about the library ? (yes, I know you wrote the exact filename "MTAWdll.dll" but what does the abbreviation MTAW mean or what did the author named the DLL ?)

If it is a 3th party library that is distributed then there usually is an accompanied header file so that you know what functions (and their declaration) are present in the library and how the parameters are suppose to be used.

If you are truly decompiling a library that is not intended to be shared (closed/undocumented library) then you are basically on your own. There are some tools available that are able to obtain some valuable information about executables and DLL's but unfortunately my Windows days are long gone (e.g. I have no idea what tools to use these days).

You could always patch the library (overtake the original functions, show the passed parameters and call the original function) in order to obtain more information or run things through a debugger (olly comes to mind if that still exists)
10
General / Re: Where are the components?
« Last post by Badger on Today at 07:57:25 am »
If I use the Install_Packages method, the Use>Install menu item is not enabled.
If I use the Online Packet Manager I get an error Cannot install package: "laz_fpspreadsheeet.lpk".  Continue with next one.  This is repeated for each file.
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018