TextSearch (Content plugin for fulltext search in DOC)

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

i see "crash returned 259": does this mean the process is crached? (what is 259)
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

See the code. It's simple.
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

I saw the code. 259: can it mean that WinMain() returted so, or is it always the exception code?
I see desc of GetExitCodeProcess, cannot see this.
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

i.e., what the 'exception code' may be?
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

Sorry, it's a bug. 259 is STILL_ACTIVE, defined in WinBase.h and as you can guess it indicates that the program didn't quit yet.

Fixed:
http://www.ii.uj.edu.pl/~adamczym/crash.7z

crash.exe always crashes by writing at the 0 address. (And tries to return 0 if succeeded, just to make it clear that anything else than 0 is not what main() returned).

tst.exe reads that crash returned 0xC0000005, which is STATUS_ACCESS_VIOLATION. (ntstatus.h).
But you don't need to know what does the exact number mean. Just check for 0 / STILL_ACTIVE and if it's other value then either the application got a problem and returned some error code or it crashed.
Or (better) wait for the program quit and just check for 0 - some programmers might return 259 w/out knowing that it's wrong.
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

maybe STATUS_ACCESS_VIOLATION only is a valid. 0 and later can be exit codes (for converters).
I try to test.
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

Hmm...you're right, 0 is not the only valid exit code.
Can't find anything about converters, but:
WinMain reference
It gives no indication about valid return codes. Going deeper into WM_QUIT and PostQuitMessage doesn't help.

STATUS_ACCESS_VIOLATION is surely not the only possible value, it's easy to produce STATUS_INTEGER_DIVIDE_BY_ZERO.
I think that it's pretty safe to assume that Standard Error values defined in ntstatus.h are only results of crashes.
That's 0xC00000000 to 0xC000010EL for Windows 2003 API.

ADDED: http://msdn.microsoft.com/en-us/library/k9dcesdd.aspx
says that there's convention that 0 indicates success and everything else - failure. That's what I heard before, but it seems official.
What a mess, MS doesn't know what they want. :?
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

I use

Code: Select all

  if not CreateProcess(nil, PChar(CmdLine), nil, nil, false, 0,
    nil, PChar(CurrentDir), si, pi) then
    Result:= exCannotRun
  else
    begin
    if DoWait then WaitForSingleObject(pi.hProcess, INFINITE);
    if GetExitCodeProcess(pi.hProcess, code) and
      (code >= $C0000000) and (code <= $C000010E) then
      Result:= exExcept
    else
      Result:= exOk;
    CloseHandle(pi.hThread);
    CloseHandle(pi.hProcess);
    end;
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

Thank you, it seems fine. Though it would be good to check whether Vista API added some more codes.
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

Seems fine, thank you. :)

Code: Select all

---------------------------
TextSearch plugin
---------------------------
Converter exception for "PDF".
Command: "C:\WINDOWS\system32\cmd.exe /C CONV\XDOC\XDOC2TXT.EXE "E:\Downloads\FF\BLO03024USEN.PDF">"C:\DOCUME~1\***\LOCALS~1\Temp\TextSrch.txt"".
---------------------------
OK   
---------------------------
BTW why CMD /c?
Direct CreateProcess should make the plugin faster.
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

Thank you (too)
cmd /c, because i use ">" for converter (output to file)..
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

OK.
I can send you samples of stdout redirection using pipes if you wish, but I don't insist on implementing it, though it would be better, I'm not sure if it's worth your time.
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

cmd /c can be removed, as pdf2text supports parameter(see sample ini)
No pipe needed 8)
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

I have a question:
How does TextSearch handle files with a lot of text like books?
Post Reply