Beispiel #1
0
        private static WIM_MSG_RETURN MessageCallback(WIM_MSG dwMessageId, IntPtr wParam, IntPtr lParam, IntPtr pvUserData)
        {
            var ret = WIM_MSG_RETURN.WIM_MSG_SUCCESS;

            if (_sinks.TryGetValue(pvUserData, out var file))
            {
                var handler = file.Event;
                if (handler != null)
                {
                    WimFileEventArgs e;
                    switch (dwMessageId)
                    {
                    case WIM_MSG.WIM_MSG_PROCESS:
                        e = new WimFileProcessEventArgs(file, dwMessageId, wParam, lParam);
                        break;

                    case WIM_MSG.WIM_MSG_ERROR:
                        e = new WimFileErrorEventArgs(file, dwMessageId, wParam, lParam);
                        break;

                    case WIM_MSG.WIM_MSG_PROGRESS:
                        e = new WimFileProgressEventArgs(dwMessageId, wParam, lParam);
                        break;

                    case WIM_MSG.WIM_MSG_SETPOS:
                        e = new WimFileSetPosEventArgs(dwMessageId, wParam, lParam);
                        break;

                    case WIM_MSG.WIM_MSG_SETRANGE:
                        e = new WimFileSetRangeEventArgs(dwMessageId, wParam, lParam);
                        break;

                    default:
                        e = new WimFileEventArgs(dwMessageId, wParam, lParam);
                        break;
                    }

                    if (Debugger.IsAttached)
                    {
                        handler(file, e);
                    }
                    else
                    {
                        try
                        {
                            handler(file, e);
                        }
                        catch (Exception exception)
                        {
                            Debug.WriteLine("An error occurred in the Event handler: " + exception);
                        }
                    }

                    ret = e.ReturnValue;
                }
            }
            return(ret);
        }
 internal WimFileErrorEventArgs(WimFile file, WIM_MSG message, IntPtr wParam, IntPtr lParam)
     : base(message, wParam, lParam)
 {
     Path         = Marshal.PtrToStringUni(wParam);
     RelativePath = file.GetRelativePath(Path);
     ErrorCode    = lParam.ToInt32();
     if (ErrorCode != 0)
     {
         ErrorMessage = new Win32Exception(ErrorCode).Message;
     }
 }
 internal WimFileProgressEventArgs(WIM_MSG message, IntPtr wParam, IntPtr lParam)
     : base(message, wParam, lParam)
 {
     Percent = wParam.ToInt32();
     MillisecondsRemaining = LParam.ToInt32();
 }
 internal WimFileSetRangeEventArgs(WIM_MSG message, IntPtr wParam, IntPtr lParam)
     : base(message, wParam, lParam)
 {
     FileCount = lParam.ToInt32();
 }
Beispiel #5
0
 internal WimFileProcessEventArgs(WimFile file, WIM_MSG message, IntPtr wParam, IntPtr lParam)
     : base(message, wParam, lParam)
 {
     Path         = Marshal.PtrToStringUni(wParam);
     RelativePath = file.GetRelativePath(Path);
 }
Beispiel #6
0
 internal WimFileEventArgs(WIM_MSG message, IntPtr wParam, IntPtr lParam)
 {
     Message = message;
     WParam  = wParam;
     LParam  = lParam;
 }