Announcement

Collapse
No announcement yet.

Weird command line issues with i_view32.exe

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Reported Weird command line issues with i_view32.exe

    Issue:
    IrfanView command line processing produces inconsistently weird results

    How to reproduce:

    1. Create a file, call it "c:\a.jpg" (preferably a valid jpg image, but that isn't really required; doesn't have to be at C: drive)
    2. Create a file, call it "c:\b.jpg" (preferably a valid jpg image, but that isn't really required; should be visually different from the "a.jpg" file, just so that you can tell them apart; doesn't have to be at C: drive, but has to be at the same drive as "a.jpg")
    3. Make sure IrfanView is located in a directory that does NOT have any spaces in its full path (i.e. not in "Program Files"). I know that people *typically* install in "Program Files", but that shouldn't be a hard requirement.
    4. Paste this C code into a file:
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    #define BSLASH_IVIEW "c:\\IrfanView\\i_view32.exe"
    #define BSLASH_FILE "c:\\b.jpg"
    #define FSLASH_IVIEW "c:/IrfanView/i_view32.exe"
    #define FSLASH_FILE "c:/b.jpg"
    
    int
    main (int argc, char **argv)
    {
      char *cmdline;
      BOOL b;
      STARTUPINFOA sa;
      PROCESS_INFORMATION pi;
    
      if (argc < 2)
        return 1;
    
      if (argv[1][0] == '1')
        cmdline = BSLASH_IVIEW " " BSLASH_FILE;
      else if (argv[1][0] == '2')
        cmdline = BSLASH_IVIEW " " FSLASH_FILE;
      else if (argv[1][0] == '3')
        cmdline = FSLASH_IVIEW " " BSLASH_FILE;
      else if (argv[1][0] == '4')
        cmdline = FSLASH_IVIEW " " FSLASH_FILE;
      else if (argv[1][0] == '5')
        cmdline = "\"" BSLASH_IVIEW "\" " BSLASH_FILE;
      else if (argv[1][0] == '6')
        cmdline = "\"" BSLASH_IVIEW "\" " FSLASH_FILE;
      else if (argv[1][0] == '7')
        cmdline = "\"" FSLASH_IVIEW "\" " BSLASH_FILE;
      else if (argv[1][0] == '8')
        cmdline = "\"" FSLASH_IVIEW "\" " FSLASH_FILE;
      else if (argv[1][0] == '9')
        cmdline = BSLASH_IVIEW " \"" BSLASH_FILE "\"";
      else if (argv[1][0] == 'a')
        cmdline = BSLASH_IVIEW " \"" FSLASH_FILE "\"";
      else if (argv[1][0] == 'b')
        cmdline = FSLASH_IVIEW " \"" BSLASH_FILE "\"";
      else if (argv[1][0] == 'c')
        cmdline = FSLASH_IVIEW " \"" FSLASH_FILE "\"";
      else if (argv[1][0] == 'd')
        cmdline = "\"" BSLASH_IVIEW "\" \"" BSLASH_FILE "\"";
      else if (argv[1][0] == 'e')
        cmdline = "\"" BSLASH_IVIEW "\" \"" FSLASH_FILE "\"";
      else if (argv[1][0] == 'f')
        cmdline = "\"" FSLASH_IVIEW "\" \"" BSLASH_FILE "\"";
      else if (argv[1][0] == 'g')
        cmdline = "\"" FSLASH_IVIEW "\" \"" FSLASH_FILE "\"";
      else if (argv[1][0] == 'h')
        cmdline = BSLASH_IVIEW "  " BSLASH_FILE;
      else if (argv[1][0] == 'i')
        cmdline = BSLASH_IVIEW "  " FSLASH_FILE;
      else if (argv[1][0] == 'j')
        cmdline = FSLASH_IVIEW "  " BSLASH_FILE;
      else if (argv[1][0] == 'k')
        cmdline = FSLASH_IVIEW "  " FSLASH_FILE;
      else if (argv[1][0] == 'l')
        cmdline = "\"" BSLASH_IVIEW "\"  " BSLASH_FILE;
      else if (argv[1][0] == 'm')
        cmdline = "\"" BSLASH_IVIEW "\"  " FSLASH_FILE;
      else if (argv[1][0] == 'n')
        cmdline = "\"" FSLASH_IVIEW "\"  " BSLASH_FILE;
      else if (argv[1][0] == 'o')
        cmdline = "\"" FSLASH_IVIEW "\"  " FSLASH_FILE;
      else if (argv[1][0] == 'p')
        cmdline = BSLASH_IVIEW "  \"" BSLASH_FILE "\"";
      else if (argv[1][0] == 'q')
        cmdline = BSLASH_IVIEW "  \"" FSLASH_FILE "\"";
      else if (argv[1][0] == 'r')
        cmdline = FSLASH_IVIEW "  \"" BSLASH_FILE "\"";
      else if (argv[1][0] == 's')
        cmdline = FSLASH_IVIEW "  \"" FSLASH_FILE "\"";
      else if (argv[1][0] == 't')
        cmdline = "\"" BSLASH_IVIEW "\"  \"" BSLASH_FILE "\"";
      else if (argv[1][0] == 'u')
        cmdline = "\"" BSLASH_IVIEW "\"  \"" FSLASH_FILE "\"";
      else if (argv[1][0] == 'v')
        cmdline = "\"" FSLASH_IVIEW "\"  \"" BSLASH_FILE "\"";
      else if (argv[1][0] == 'w')
        cmdline = "\"" FSLASH_IVIEW "\"  \"" FSLASH_FILE "\"";
      else
        return 2;
    
      memset (&sa, 0, sizeof (sa));
      sa.cb = sizeof (sa);
      b = CreateProcessA (NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &sa, &pi);
      if (!b)
        printf ("ERROR: %ld\n", GetLastError ());
      return 0;
    }
    5. Replace "C:\\IrfanView\\" with your IrfanView directory (with backslashes).
    6. Replace "C:/IrfanView/" with your IrfanView directory (with forward slashes)
    7. Replace "C:\\b.jpg" with your own path to "b.jpg" (with backslashes)
    8. Replace "C:/b.jpg" with your own path to "b.jpg" (with forward slashes)
    9. Compile the program
    10. Run the program repeatedly, with the first argument being a number between '1' and '9', then a letter between 'a' and 'w' (I know it's stupid, but this is a test case, not an end-user program; I coded the simplest argument parsing I could come up with).

    The program runs i_view32.exe to open the file b.jpg, with various command line variations (forward slashes, back slashes in either or both arguments; quotes around either or both arguments, single or double space between arguments).

    Expected result:
    * Each and every invocation results in IrfanView running and opening b.jpg

    Actual result:
    * Some invocations open a.jpg instead (apparently, IrfanView opens "c:" drive and picks the first file it finds, which is "a.jpg")

    Windows 10 20H2, IrfanView 4.56 32-bit

    #2
    Judging by 0 answers, everyone can't or don't want to compile your program.

    Modify it to generate batch file.
    IV 4.56 32-bit

    Comment


      #3
      You mean that I should replace the program with a batch file that does the same? Sadly, I can't do that. I need to demonstrate the issues with CreateProcess(), because that is my use-case. Batch file may very well break some of the more exotic perturbations (double spaces, double-quotes, etc).

      IMO, 0 answers is mostly because christmas, and because only a developer can compile and run the program. Since the desired result is to fix the IrfanView command line processing code, I want for a developer to look at the issue. That is, things are proceeding just fine for now. I'll start worrying when this thread goes without a reply for a few months.

      That said, it might be worthwhile to trim down the problem space to a few specific invocations. Instead of demonstrating the breadth of the problem I could just point out a couple of cases where things *clearly* work not the way they should. I'll think about it.

      Comment


        #4
        If you want an answer from the developer, you have to contact the developer directly. This forum is for users. The purpose of the Bugreport section is that other users can test the issues and share their findings before reporting bugs to the developer.
        My system: IrfanView 4.62 64bit, Windows 10 22H2, Intel Core i5-3570, 16GB RAM, NVidia GTX 1050Ti 4GB

        Comment

        Working...
        X