Loading ...
Sorry, an error occurred while loading the content.
 

RE: Patch for ADVAPI Problems (Try Again)

Expand Messages
  • Brent Fulgham
    ... FYI -- It seems to work under Windows NT in our test lab, but I haven t done too much with it, so a real user is encouraged to try the patch. ... Done:
    Message 1 of 1 , Sep 6, 2000
      > : Attached is a patch that seems to fix the ADVAPI32.DLL problem
      > : I (and others) have had when running under Windows 95. This
      > : should work under NT, but I'd like someone to try it out.
      >
      FYI -- It seems to work under Windows NT in our test lab, but I
      haven't done too much with it, so a "real" user is encouraged to
      try the patch.

      > 1) include WINAPI in your function pointer typedefs. that way you
      > won't care whether the default calling convention is __stdcall.
      >
      > typedef DWORD WINAPI (*PSNSECINFO) (LPTSTR, enum SE_OBJECT_TYPE,
      > SECURITY_INFORMATION, PSECURITY_DESCRIPTOR*);
      >

      Done:

      diff -warc3 vim60h.orig/src/os_win32.c vim60h/src/os_win32.c
      *** vim60h.orig/src/os_win32.c Thu Aug 31 11:42:30 2000
      --- vim60h/src/os_win32.c Wed Sep 6 10:39:48 2000
      ***************
      *** 84,90 ****
      --- 84,98 ----
      FILE* fdDump = NULL;
      #endif

      + /*
      + * These are needed to dynamically load the ADVAPI DLL, which is not
      + * implemented under Windows 95 (and causes VIM to crash)
      + */
      + typedef DWORD (WINAPI *PSNSECINFO) (LPTSTR, enum SE_OBJECT_TYPE,
      SECURITY_INFORMATION,
      + PSID, PSID, PACL, PACL);

      + typedef DWORD (WINAPI *PGNSECINFO) (LPSTR, enum SE_OBJECT_TYPE,
      SECURITY_INFORMATION,
      + PSID*, PSID*, PACL*, PACL*,
      PSECURITY_DESCRIPTOR*);
      /*
      * When generating prototypes for Win32 on Unix, these lines make the
      syntax
      * errors disappear. They do not need to be correct.
      ***************
      *** 250,255 ****
      --- 258,266 ----

      static void PlatformId(void);
      static DWORD g_PlatformId;
      + static HANDLE hLibrary = NULL; /* Handle for loading ADVAPI
      library (if supported) */
      + static PSNSECINFO pSetNamedSecurityInfo;
      + static PGNSECINFO pGetNamedSecurityInfo;

      /*
      * Set g_PlatformId to VER_PLATFORM_WIN32_NT (NT) or
      ***************
      *** 268,273 ****
      --- 279,302 ----
      GetVersionEx(&ovi);

      g_PlatformId = ovi.dwPlatformId;
      +
      + /*
      + * Load the ADVAPI runtime if we are on anything
      + * other than Windows 95
      + */
      + if (g_PlatformId != VER_PLATFORM_WIN32_WINDOWS)
      + {
      + /*
      + * do this load. Problems: Doesn't unload at end of run (this
      is theoretically
      + * okay, since Windows should unload it when VIM terminates).
      Should we be using
      + * the 'mch_libcall' routines? Seems like a lot of overhead to
      load/unload
      + * ADVAPI32.DLL each time we verify security...
      + */
      + hLibrary = LoadLibrary("ADVAPI32.DLL");
      + pSetNamedSecurityInfo = (PSNSECINFO)GetProcAddress(hLibrary,
      "SetNamedSecurityInfo");
      + pGetNamedSecurityInfo = (PGNSECINFO)GetProcAddress(hLibrary,
      "GetNamedSecurityInfo");
      +
      + }
      done = TRUE;
      }
      }
      ***************
      *** 1940,1949 ****
      {
      struct my_acl *p;

      p = (struct my_acl *)alloc_clear((unsigned)sizeof(struct my_acl));
      if (p != NULL)
      {
      ! if (GetNamedSecurityInfo(
      (LPTSTR)fname, // Abstract filename
      SE_FILE_OBJECT, // File Object
      // Retrieve the entire security descriptor.
      --- 1969,1982 ----
      {
      struct my_acl *p;

      + /* This only works on Windows NT and 2000. */
      + if (g_PlatformId == VER_PLATFORM_WIN32_WINDOWS)
      + return NULL;
      +
      p = (struct my_acl *)alloc_clear((unsigned)sizeof(struct my_acl));
      if (p != NULL)
      {
      ! if (pGetNamedSecurityInfo(
      (LPTSTR)fname, // Abstract filename
      SE_FILE_OBJECT, // File Object
      // Retrieve the entire security descriptor.
      ***************
      *** 1962,1967 ****
      --- 1995,2001 ----
      p = NULL;
      }
      }
      +
      return (vim_acl_t)p;
      }

      ***************
      *** 1976,1983 ****
      {
      struct my_acl *p = (struct my_acl *)acl;

      if (p != NULL)
      ! (void)SetNamedSecurityInfo(
      (LPTSTR)fname, // Abstract filename
      SE_FILE_OBJECT, // File Object
      // Retrieve the entire security descriptor.
      --- 2010,2021 ----
      {
      struct my_acl *p = (struct my_acl *)acl;

      + /* This only works on Windows NT and 2000. */
      + if (g_PlatformId == VER_PLATFORM_WIN32_WINDOWS)
      + return;
      +
      if (p != NULL)
      ! (void)pSetNamedSecurityInfo(
      (LPTSTR)fname, // Abstract filename
      SE_FILE_OBJECT, // File Object
      // Retrieve the entire security descriptor.



      > 2) don't bother checking for the windows flavor, just call
      > LoadLibrary() and GetProcAddress(). that way if MS adds these to some
      > future win9x (ME?), things will "just work". the only wrinkle then is
      > telling the difference between uninitialized and invalid function
      > pointers. i'd probably go with the boring: having a flag variable in
      > one of three states:
      >
      > not initialized
      > acl api available
      > acl api not available
      >
      > my apologies for not supplying a patch to your patch: i don't have
      > windows handy to test it tonight.
      >

      Thanks -- I'm not sure how best to accomplish your suggestion. I'm leaving
      things as-is in the hope that a "real" Windows person can deal with it (I'm
      a Unix person who only uses Windows a bit at work!).

      Thanks,

      -Brent
    Your message has been successfully submitted and would be delivered to recipients shortly.