3 Replies Latest reply on Sep 20, 2010 5:10 PM by danerjones

    Example Request: SbAdmDll.dll SBADM_execute

      I'm trying to implement a dynamic reboot element into our software installation packages for deployment to our encrypted systems.  Currently I'm having an issue getting the SBADM_execute function call to work.

       

      I'm using AutoIt to prototype my functions before I implement them into NSIS which is why I'm not using the COM objects.

       

      This is what I have..

       

      Dim $XML = "<SafeBoot><SbAdminScripting><SbAdminCommand><Command>GetVersion</Command></SbAdminCommand></SbAdminScripting></SafeBoot>"
      Dim $Result

      Dim $AppPath = @ProgramFilesDir & "\McAfee\Endpoint Encryption for PC"

      FileCopy("SbAdmDll.dll", $AppPath & "\")
      FileChangeDir($AppPath)

      $dll = DllOpen("SbAdmDll.dll")

      ;unsigned short * __cdecl SBADM_execute(unsigned short const *,int (__cdecl*)(unsigned long,void *))

      $Result = DllCall($dll, "wstr:cdecl", "SBADM_execute", "wstr", $XML, "int", 0)
      MsgBox(4096, "Test", "$DLL = " & $dll & @CRLF & "@error = " & @error & @crlf & "Result = " & $Result)

      DllClose($dll)

       

      AutoIt returns an error indicating that the "function" was not found in the DLL file.   I tried executing the call using cdecl and as a stdcall.  Any ideas?

        • 1. Re: Example Request: SbAdmDll.dll SBADM_execute

          I know this might be out of the scope of what standard SafeBoot admins do but has no one attempted to call the SbAdmDll.dll directly?

          COM and the command line interfaces are nice and all, but it adds unnecessary bloat to the final package when large scale deployments increase network traffic exponentially for every byte the package size is increased.  (Personally I think the SbAdmDll.dll is a bit too hefty at 468KB  What the heck is in there to make it so big... seriously! )

           

          Enough ranting...

           

          I used the dependency walker to verify the dll can access the required dll dependencies so I know that's not the problem.  I can use the SbAdmCOM.dll in scripts and the SbAdmCl.exe from the command line without issue so I know the system is in a state to use the SbAdmDll.dll.

           

          Even a simple C example would be great as I could at least reverse engineer it into something I can use.

           

          Even better... release the source code for the SbAdmCl.exe!   I'm sure there is nothing in there that would warrent an issue with intellectual property as it should be very straight forward and it would provide me with an example on how to use the SbAdmDll.dll.

          • 2. Re: Example Request: SbAdmDll.dll SBADM_execute

            Anders over at the NSIS forums solved it!!

             

            outfile test.exe
            section
            setoutpath
            "C:\Program Files\McAfee\Endpoint Encryption for PC"
            system::call 'kernel32::LoadLibrary(t "$OUTDIR\SbAdmDll.dll")i.r0'
            system::call 'kernel32::GetProcAddress(i r0,i 1)i.r2' ;ordinal 1
            System
            ::Call '::$2(w "<SafeBoot><SbAdminScripting><SbAdminCommand><Command>GetVersion</Command></SbAdminCommand></SbAdminScripting></SafeBoot>",i0)w .r3 ?c'
            DetailPrint $3
            system
            ::call 'kernel32::FreeLibrary(i r0)'
            sectionend

             

            Output folder: C:\Program Files\McAfee\Endpoint Encryption for PC
            ?<?xml version="1.0"?>
              <SafeBoot>
                <SbAdminScripting>
                  <SbAdminConnectionResult>
                    <ResultCode>0x00000000</ResultCode>
                    <ResultDescription>The operation completed successfully.
            </ResultDescription>
                  </SbAdminConnectionResult>
                  <SbAdminCommandResult>
                    <Command>GetVersion</Command>
                    <ResultCode>0x00000000</ResultCode>
                    <ResultDescription>The operation completed successfully.
            </ResultDescription>
                    <Version>5.2.3.5</Version>
                  </SbAdminCommandResult>
                </SbAdminScripting>
              </SafeBoot>

            Completed

             

            The example is compiled using NSIS 2.46!