Jump to content

terran

Members
  • Content Count

    11
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. 1. Plugin for Total Commander (32-bit). Total Commander is a Host App, plugin is a DLL. 2. Win7 / Delphi10 3. Plugin is running in separate thread (this is not documented, but can be seen in process explorer) 4. Error in plugin (infinite loop, as it turned out later) 5. CPU window shows not my plugin's code, or even thread, but the Host App's thread 6. No possibility to switch to another thread, or find out about its existence 7. No My or Host App's code when Step over/Trace into (F7/F8), only ntdll.dll ? 8. ???
  2. It hangs on this line when pressing F7: ntdll.NtQueryInformationThread: 77E9FC08 B822000000 mov eax,$00000022 77E9FC0D 33C9 xor ecx,ecx 77E9FC0F 8D542404 lea edx,[esp+$04] 77E9FC13 64FF15C0000000 call dword ptr fs:[$000000c0] 77E9FC1A 83C404 add esp,$04 77E9FC1D C21400 ret $0014 Stack: :77e9fc1a ntdll.NtQueryInformationThread + 0x12 :77f1f3fd ntdll.DbgUiRemoteBreakin + 0x53 :7675343d kernel32.BaseThreadInitThunk + 0x12 :77eb9812 ntdll.RtlInitializeExceptionChain + 0x63 :77eb97e5 ntdll.RtlInitializeExceptionChain + 0x36
  3. My App hangs, and I clicked Pause, and got into the CPU window. But Call Stack is empty. In CPU window, there's ntdll.RtlUserThreadStart, and after pressing F8, in Call Stack window there's only one line :77eb97cc ntdll.RtlInitializeExceptionChain + 0x1d , and after pressing F8 several times after command 77EB97E0 E806000000 call $77eb97eb , it started to run (keeps freezing), and "Process is not accessible". What should I do? Application is a DLL attached to EXE. Of course, module "Has debug info".
  4. Sorry, this unit was excluded in the above units. Del.
  5. I compiled it with bcc32c -tM -tR -Od -v (CMake did it for me). The object files compiled with the -v switch are twice as big, and of course contain some "debugging information". But it's not exact. 😄 No, the code doesn't work. It is an old LibTiff library. It worked with a (20 years) old .OBJ files with no sources (and no debugging). I compiled the new object files from .C sources, and with them it doesn't work. The delphi unit to that library is not so much outdated. But it's not exact. 😄
  6. I am debugging a Delphi application, which uses C Object files (.obj). When enters a function, it shows correct Local variables, but when a step-in, it doesn't show correct Local variables. Is it a bug? Before entering function: After entering function: Previous function in stack: Actually, ReadProc is assigned to SeekProc, WriteProc to CloseProc, and SeekProc to SizeProc. Function in delphi: type PTIFF = Pointer; TIFFReadWriteProc = function(Fd: THandle; Buffer: Pointer; Size: tmsize_t): Integer; cdecl; TIFFCloseProc = function(Fd: THandle): Integer; cdecl; TIFFSeekProc = function(Fd: THandle; Off: toff_t; Whence: Integer): toff_t; cdecl; TIFFSizeProc = function(Fd: THandle): toff_t; cdecl; TIFFMapFileProc = function(Fd: THandle; PBase: PPointer; PSize: poff_t): Integer; cdecl; TIFFUnmapFileProc = procedure(Fd: THandle; Base: Pointer; Size: toff_t); cdecl; function _TIFFClientOpenExt(name: PAnsiChar; mode: PAnsiChar; clientdata: THandle; readproc: TIFFReadWriteProc; writeproc: TIFFReadWriteProc; seekproc: TIFFSeekProc; closeproc: TIFFCloseProc; sizeproc: TIFFSizeProc; mapproc: TIFFMapFileProc; unmapproc:TIFFUnmapFileProc; opts: Pointer): PTIFF; cdecl; external; Function in C : typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void *, tmsize_t); typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); typedef int (*TIFFCloseProc)(thandle_t); typedef toff_t (*TIFFSizeProc)(thandle_t); typedef int (*TIFFMapFileProc)(thandle_t, void **base, toff_t *size); typedef void (*TIFFUnmapFileProc)(thandle_t, void *base, toff_t size); //////////// TIFF *TIFFClientOpen(const char *name, const char *mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc) { return TIFFClientOpenExt(name, mode, clientdata, readproc, writeproc, seekproc, closeproc, sizeproc, mapproc, unmapproc, NULL); } TIFF *TIFFClientOpenExt(const char *name, const char *mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc, TIFFOpenOptions *opts)
  7. Added absolute path to "Project - Options - Build - Delphi Compiler - Search path", and put it first in the list. Doesn't work if there are relative paths above. Then why? And when? And how long?
  8. Hi, why the same project has "No debug info" in Delphi 10.4 and "Has debug info" in XE7 ? The project is a DLL. Project Options -> Delphi Compiler -> Compiler -> Assertions -> True Project Options -> Delphi Compiler -> Compiler -> Debug information -> Debug information Project Options -> Delphi Compiler -> Compiler -> Local symbols -> True Project Options -> Delphi Compiler -> Compiler -> Symbol reference info -> Reference info Project Options -> Delphi Compiler -> Compiler -> Use debug .dcus -> True Project Options -> Delphi Compiler -> Linking -> Debug information -> True Project Options -> Delphi Compiler -> Linking -> Include remote debug symbols -> True Project Options -> Delphi Compiler -> Linking -> Map file -> Detailed <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <ProjectGuid>{2EDF40EE-753C-46AD-B345-E87D9FB37703}</ProjectGuid> <MainSource>WebpInfo.dpr</MainSource> <Base>True</Base> <Config Condition="'$(Config)'==''">Debug</Config> <TargetedPlatforms>1</TargetedPlatforms> <AppType>Library</AppType> <FrameworkType>None</FrameworkType> <ProjectVersion>19.2</ProjectVersion> <Platform Condition="'$(Platform)'==''">Win32</Platform> </PropertyGroup> <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''"> <Base>true</Base> </PropertyGroup> <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''"> <Base_Win32>true</Base_Win32> <CfgParent>Base</CfgParent> <Base>true</Base> </PropertyGroup> <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''"> <Cfg_1>true</Cfg_1> <CfgParent>Base</CfgParent> <Base>true</Base> </PropertyGroup> <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''"> <Cfg_1_Win32>true</Cfg_1_Win32> <CfgParent>Cfg_1</CfgParent> <Cfg_1>true</Cfg_1> <Base>true</Base> </PropertyGroup> <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''"> <Cfg_2>true</Cfg_2> <CfgParent>Base</CfgParent> <Base>true</Base> </PropertyGroup> <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''"> <Cfg_2_Win32>true</Cfg_2_Win32> <CfgParent>Cfg_2</CfgParent> <Cfg_2>true</Cfg_2> <Base>true</Base> </PropertyGroup> <PropertyGroup Condition="'$(Base)'!=''"> <DCC_K>false</DCC_K> <DCC_S>false</DCC_S> <DCC_F>false</DCC_F> <DCC_ImageBase>00400000</DCC_ImageBase> <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;Winapi;$(DCC_Namespace)</DCC_Namespace> <GenDll>true</GenDll> <VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=;CFBundleName=</VerInfo_Keys> <VerInfo_Locale>1049</VerInfo_Locale> <DCC_N>false</DCC_N> <DCC_E>false</DCC_E> <SanitizedProjectName>WebpInfo</SanitizedProjectName> </PropertyGroup> <PropertyGroup Condition="'$(Base_Win32)'!=''"> <Manifest_File>None</Manifest_File> <DCC_UnitSearchPath>.\image32;.\imaging;.\imaging\jpeglib;.\imaging\zlib;.\extensions;.\extensions\libtiff;d:\_j\MyPrograms\Examples\contplug;$(DCC_UnitSearchPath)</DCC_UnitSearchPath> <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo> <DCC_Namespace>System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace> <VerInfo_Locale>1033</VerInfo_Locale> <VerInfo_Keys>CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys> </PropertyGroup> <PropertyGroup Condition="'$(Cfg_1)'!=''"> <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols> <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define> <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo> <DCC_DebugInformation>0</DCC_DebugInformation> </PropertyGroup> <PropertyGroup Condition="'$(Cfg_1_Win32)'!=''"> <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo> <VerInfo_Keys>CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys> <VerInfo_Locale>1033</VerInfo_Locale> </PropertyGroup> <PropertyGroup Condition="'$(Cfg_2)'!=''"> <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define> <DCC_Optimize>false</DCC_Optimize> <DCC_GenerateStackFrames>true</DCC_GenerateStackFrames> </PropertyGroup> <PropertyGroup Condition="'$(Cfg_2_Win32)'!=''"> <DCC_RemoteDebug>true</DCC_RemoteDebug> <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo> <Debugger_HostApplication>D:\_d\totalcmd11\TOTALCMD.EXE</Debugger_HostApplication> <VerInfo_Locale>1033</VerInfo_Locale> <VerInfo_Keys>CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys> <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe> <DCC_MapFile>3</DCC_MapFile> <DCC_DebugDCUs>true</DCC_DebugDCUs> </PropertyGroup> <ItemGroup> <DelphiCompile Include="$(MainSource)"> <MainSource>MainSource</MainSource> </DelphiCompile> <BuildConfiguration Include="Debug"> <Key>Cfg_2</Key> <CfgParent>Base</CfgParent> </BuildConfiguration> <BuildConfiguration Include="Base"> <Key>Base</Key> </BuildConfiguration> <BuildConfiguration Include="Release"> <Key>Cfg_1</Key> <CfgParent>Base</CfgParent> </BuildConfiguration> </ItemGroup> <ProjectExtensions> <Borland.Personality>Delphi.Personality.12</Borland.Personality> <Borland.ProjectType/> <BorlandProject> <Delphi.Personality> <Source> <Source Name="MainSource">WebpInfo.dpr</Source> </Source> <Excluded_Packages> <Excluded_Packages Name="$(BDSBIN)\dcloffice2k270.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages> <Excluded_Packages Name="$(BDSBIN)\dclofficexp270.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages> </Excluded_Packages> </Delphi.Personality> <Platforms> <Platform value="Win32">True</Platform> <Platform value="Win64">False</Platform> </Platforms> </BorlandProject> <ProjectFileVersion>12</ProjectFileVersion> </ProjectExtensions> <Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/> <Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/> </Project>
  9. terran

    Creating multiple threads in a DLL

    Soorry, probabiy it is executing too fast, so I could not notice that. And the slowest part cannot be paralleled.
  10. terran

    Creating multiple threads in a DLL

    I have added the code to the first post. The plugin interface: https://ghisler.github.io/WDX-SDK/contents.htm Sorry if I don't specified the info. Because if i sure that it is written correctly, there is no need to specify the code, and if it's impossible, then, too.
  11. Hi! When I try to create a multiple threads in a DLL, they are probably running not in parallel, but sequential, and using only a single CPU core. Is it possible to make it to use multiple CPU cores? My "DLL" is a plugin for third-party app, and i have no idea what does the App with the DLL. library whatever; {$IFDEF FPC} {$MODE delphiunicode} {$ENDIF} {$R *.res} {$IFDEF WIN64} {$EXTENSION 'wdx64'} {$ENDIF} {$IFDEF WIN32} {$EXTENSION 'wdx'} {$ENDIF} {zzz$SetPEOptFlagszzz $160} uses SysUtils, Windows, Classes, contplug, RTLConsts; const cFieldsNames: array [0..0] of AnsiString = ('Data'); cFieldsTypes: array [0..High(cFieldsNames)] of Integer = (ft_Numeric64); DetectStr = 'EXT="JPG"'; type TLastInfo = record FileName: string; hash:int64; end; type TProcessFile = class private type TThreadx = class(TThread) private protected procedure Execute; override; public is_running:boolean; end; public threadx:array{[1..NUM_THREADS]} of tthreadx; function ProcessFile(const FileName: UnicodeString; FieldIndex, UnitIndex: Integer): Boolean; end; var RTL: TRTLCriticalSection; LastInfo: TLastInfo; ProcessFileVar:TProcessFile; var NUM_THREADS:integer=10; procedure TProcessFile.TThreadx.Execute; begin // dddddddd is_running:=false; end; function TProcessFile.ProcessFile(const FileName: UnicodeString; FieldIndex, UnitIndex: Integer): Boolean; var a:integer; is_finished:boolean; begin Result := false; try if LastInfo.FileName <> FileName then begin LastInfo := Default(TLastInfo); LastInfo.FileName := FileName; try setlength(threadx,NUM_THREADS); for a:=0 to NUM_THREADS-1 do begin threadx[a]:=TThreadx.Create(true); threadx[a].Priority:=tpLower; threadx[a].FreeOnTerminate:=false; threadx[a].is_running:=true; if threadx[a].Suspended then threadx[a].Resume; sleep(0); end; repeat is_finished:=true; for a:=0 to NUM_THREADS-1 do begin if threadx[a].is_running then is_finished:=false; sleep(0); end; until is_finished=true; for a:=0 to NUM_THREADS-1 do begin threadx[a].Free; end; finally end; Result := true; end; except Result := False; end; end; function ContentGetSupportedField(FieldIndex: Integer; FieldName: PAnsiChar; Units: PAnsiChar; MaxLen: Integer): Integer; stdcall; var Str: AnsiString; I: Integer; begin if FieldIndex in [0..High(cFieldsNames)] then begin StrCopy(Units,''); StrLCopy(FieldName, PAnsiChar(cFieldsNames[FieldIndex]), MaxLen - 1); Result := cFieldsTypes[FieldIndex]; StrLCopy(Units, PAnsiChar(''), MaxLen - 1); //for I := Low(cWebpEncodingString) to High(cWebpEncodingString) do // Str := cWebpEncodingString[I] + '|'; //if FieldIndex = 2 then // StrLCopy(Units, PAnsiChar(Str), MaxLen - 1); end else Result := ft_NoMoreFields; end; function GetValueW(FileName: PWideChar; FieldIndex, UnitIndex: Integer; FieldValue: PByte; MaxLen, Flags: Integer): Integer; var AFileName: string; begin Result := ft_FieldEmpty; AFileName := FileName; if Length(AFileName) > 256 then if Pos('\\', AFileName) > 0 then AFileName := '\\?\UNC\' + Copy(AFileName, 3, Length(AFileName) - 2) else AFileName := '\\?\' + AFileName; if not FileExists(AFileName) then Exit; try ProcessFileVar:=TProcessFile.Create; try if not ProcessFileVar.ProcessFile(AFileName, FieldIndex, UnitIndex) then Exit; except Exit; end; finally ProcessFileVar.Free; end; case FieldIndex of 0: PInt64(FieldValue)^ := LastInfo.hash; end; if FieldIndex in [0 .. High(cFieldsNames)] then Result := cFieldsTypes[FieldIndex] else Result := ft_fieldempty; end; function ContentGetValueW(FileName: PWideChar; FieldIndex, UnitIndex: Integer; FieldValue: PByte; MaxLen, Flags: Integer): Integer; stdcall; begin if (Flags and CONTENT_DELAYIFSLOW > 0) then begin Result := FT_DELAYED; Exit; end; EnterCriticalSection(RTL); try Result := GetValueW(FileName, FieldIndex, UnitIndex, FieldValue, MaxLen, Flags); finally LeaveCriticalSection(RTL); end; end; function ContentGetValue(FileName: PAnsiChar; FieldIndex, UnitIndex: Integer; FieldValue: PByte; MaxLen, Flags: Integer): Integer; stdcall; begin Result := ContentGetValueW(PWideChar(WideString(AnsiString(FileName))), FieldIndex, UnitIndex, FieldValue, MaxLen, Flags) end; procedure ContentGetDetectString(DetectString: PAnsiChar; MaxLen: integer); stdcall; begin StrLCopy(DetectString, PAnsiChar(DetectStr), MaxLen - 1); end; procedure ContentSetDefaultParams(dps: PContentDefaultParamStruct); stdcall; begin end; procedure DLLEntryProc; begin DeleteCriticalSection(RTL); end; exports ContentGetDetectString, ContentGetSupportedField, ContentGetValue, ContentGetValueW; //ContentSetDefaultParams; begin InitializeCriticalSectionAndSpinCount(RTL, 4000); DisableThreadLibraryCalls(HInstance); //Dll_Process_Detach_Hook := @DLLEntryProc; //DllProc := @DLLEntryProc; end.
×