private void btnExportRootSig_Click(object sender, EventArgs e) { if (m_RootSignature != null) { SaveFileDialog save = new SaveFileDialog(); if (save.ShowDialog() != DialogResult.Cancel) { File.WriteAllBytes(save.FileName, m_RootSignature.ReadBytes()); } } }
public FXCResultsPanel(HLSLShader shader) { string error = shader.Messages; IDXShaderBlob blob = shader.CompiledBlob; m_Shader = blob; InitializeComponent(); txtMessages.Text = error; if (blob == null) { tabControl1.TabPages.Remove(hexPage); tabControl1.TabPages.Remove(asmPage); } else { txtASM.Text = blob.Disassemble(); // generate a blob dump try { byte[] rawBytes = blob.ReadBytes(); StringBuilder str = new StringBuilder(); str.AppendFormat("Blob size is {0} ({1:X}) bytes", rawBytes.Length, rawBytes.Length); str.AppendLine(); HexBumpBlob(str, rawBytes); if (blob is IDXBCShaderBlob) { IDXBCShaderBlob blobDXBC = blob as IDXBCShaderBlob; IDXBCShaderBlob strip = blobDXBC.Strip(); IDXBCShaderBlob sig = strip.GetSignatureBlob(); byte[] stripBytes = strip.ReadBytes(); byte[] sigBytes = sig.ReadBytes(); str.AppendFormat("Stripped blob size is {0} ({1:x}) bytes", stripBytes.Length, stripBytes.Length); str.AppendLine(); HexBumpBlob(str, stripBytes); str.AppendFormat("Signature blob size is {0} ({1:x}) bytes", sigBytes.Length, sigBytes.Length); str.AppendLine(); HexBumpBlob(str, sigBytes); } txtHex.Text = str.ToString(); } catch (Exception ex) { txtHex.Text = String.Format("EXCEPTION while generating hex dump: {0}", ex.Message); } } IDXBlob rsBlob = shader.CompiledRootSig; m_RootSignature = rsBlob; txtMessages.Text = String.Concat(txtMessages.Text, shader.RootSigMessages); if (rsBlob == null) { tabControl1.TabPages.Remove(rootSigPage); } else { try { byte[] rawBytes = rsBlob.ReadBytes(); StringBuilder str = new StringBuilder(); str.AppendFormat("RootSig blob size is {0} ({1:X}) bytes", rawBytes.Length, rawBytes.Length); str.AppendLine(); HexBumpBlob(str, rawBytes); txtRootSig.Text = str.ToString(); } catch (Exception ex) { txtRootSig.Text = String.Format("EXCEPTION while generating rootsig dump: {0}", ex.Message); } } }