|
@@ -26,43 +26,55 @@ const (
|
|
|
procResizeConsoleInComputeSystem = "ResizeConsoleInComputeSystem"
|
|
|
|
|
|
// Storage related functions in the shim DLL
|
|
|
- procLayerExists = "LayerExists"
|
|
|
- procCreateLayer = "CreateLayer"
|
|
|
- procDestroyLayer = "DestroyLayer"
|
|
|
- procActivateLayer = "ActivateLayer"
|
|
|
- procDeactivateLayer = "DeactivateLayer"
|
|
|
- procGetLayerMountPath = "GetLayerMountPath"
|
|
|
- procCopyLayer = "CopyLayer"
|
|
|
- procCreateSandboxLayer = "CreateSandboxLayer"
|
|
|
- procPrepareLayer = "PrepareLayer"
|
|
|
- procUnprepareLayer = "UnprepareLayer"
|
|
|
- procExportLayer = "ExportLayer"
|
|
|
- procImportLayer = "ImportLayer"
|
|
|
+ procLayerExists = "LayerExists"
|
|
|
+ procCreateLayer = "CreateLayer"
|
|
|
+ procDestroyLayer = "DestroyLayer"
|
|
|
+ procActivateLayer = "ActivateLayer"
|
|
|
+ procDeactivateLayer = "DeactivateLayer"
|
|
|
+ procGetLayerMountPath = "GetLayerMountPath"
|
|
|
+ procCopyLayer = "CopyLayer"
|
|
|
+ procCreateSandboxLayer = "CreateSandboxLayer"
|
|
|
+ procPrepareLayer = "PrepareLayer"
|
|
|
+ procUnprepareLayer = "UnprepareLayer"
|
|
|
+ procExportLayer = "ExportLayer"
|
|
|
+ procImportLayer = "ImportLayer"
|
|
|
+ procGetSharedBaseImages = "GetBaseImages"
|
|
|
+
|
|
|
+ // Name of the standard OLE dll
|
|
|
+ oleDLLName = "Ole32.dll"
|
|
|
+
|
|
|
+ // Utility functions
|
|
|
+ procCoTaskMemFree = "CoTaskMemFree"
|
|
|
)
|
|
|
|
|
|
-// loadAndFind finds a procedure in the DLL. Note we do NOT do lazy loading as
|
|
|
+// loadAndFindFromDll finds a procedure in the given DLL. Note we do NOT do lazy loading as
|
|
|
// go is particularly unfriendly in the case of a mismatch. By that - it panics
|
|
|
// if a function can't be found. By explicitly loading, we can control error
|
|
|
// handling gracefully without the daemon terminating.
|
|
|
-func loadAndFind(procedure string) (dll *syscall.DLL, proc *syscall.Proc, err error) {
|
|
|
-
|
|
|
- logrus.Debugf("hcsshim::loadAndFind %s", procedure)
|
|
|
+func loadAndFindFromDll(dllName, procedure string) (dll *syscall.DLL, proc *syscall.Proc, err error) {
|
|
|
+ logrus.Debugf("hcsshim::loadAndFindFromDll %s %s", dllName, procedure)
|
|
|
|
|
|
- dll, err = syscall.LoadDLL(shimDLLName)
|
|
|
+ dll, err = syscall.LoadDLL(dllName)
|
|
|
if err != nil {
|
|
|
- err = fmt.Errorf("Failed to load %s - error %s", shimDLLName, err)
|
|
|
+ err = fmt.Errorf("Failed to load %s - error %s", dllName, err)
|
|
|
logrus.Error(err)
|
|
|
- return nil, nil, err
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
proc, err = dll.FindProc(procedure)
|
|
|
if err != nil {
|
|
|
- err = fmt.Errorf("Failed to find %s in %s", procedure, shimDLLName)
|
|
|
+ err = fmt.Errorf("Failed to find %s in %s", procedure, dllName)
|
|
|
logrus.Error(err)
|
|
|
- return nil, nil, err
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
- return dll, proc, nil
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// loadAndFind finds a procedure in the shim DLL.
|
|
|
+func loadAndFind(procedure string) (*syscall.DLL, *syscall.Proc, error) {
|
|
|
+
|
|
|
+ return loadAndFindFromDll(shimDLLName, procedure)
|
|
|
}
|
|
|
|
|
|
// use is a no-op, but the compiler cannot see that it is.
|