Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net MSIL代码问题_.net_Cil - Fatal编程技术网

.net MSIL代码问题

.net MSIL代码问题,.net,cil,.net,Cil,我试图通过ildassembling和修改MSIL代码来修改程序集(我的)。 我只想打开一个信息框 这是我的密码: .module extern Fusion.dll .module extern kernel32.dll .module extern advapi32.dll .module extern aspnet\u state.exe .module extern webengine.dll .module extern aspnet\u wp.exe .module extern m

我试图通过ildassembling和修改MSIL代码来修改程序集(我的)。 我只想打开一个信息框

这是我的密码:

.module extern Fusion.dll

.module extern kernel32.dll

.module extern advapi32.dll

.module extern aspnet\u state.exe

.module extern webengine.dll

.module extern aspnet\u wp.exe

.module extern mscorwks.dll

.module extern ole32.dll

.module extern mscoree.dll

.module extern Netapi32.dll

.assembly extern mscorlib

{

IL\u 0052:ldstr“ahahahahahahah”

IL\u 0057:callvirt实例[mscorlib]System.Windows.Forms.MessageBox::Show(string)

IL\u 005c:ldloc.0

IL_005d:ret

}//方法结束

我没有错误,但是MessageBox没有出现:\

谢谢你的帮助

应该是

  ldstr "ahahahahahah"
  call valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult[System.Windows.Forms]System.Windows.Forms.MessageBox::Show(string)
  pop
  ret
顺便说一句,
MessageBox
不应该在web应用程序中工作,因为它与桌面用户交互

您的代码有什么问题:

callvirt instance [mscorlib]System.Windows.Forms.MessageBox::Show(string)
  • 显示是静态方法。因此,它应该被称为a)带有
    调用
    b)没有
    实例
  • MessageBox位于
    System.Windows.Forms
    中,而不是
    mscorlib
  • 您应该指定结果类型,它实际上是DialogResult
  • 您应该
    pop
    result,因为您不需要它

  • MessageBox是System.windows.Forms.dll中的一个windows窗体函数,因此您需要为此添加一个外部程序并删除调用[mscorlib]位……但我认为这不会有什么帮助

    ASPX页面将如何生成Winforms消息框? 您唯一可以做的就是发出Javascript“警报(消息)”以获取网页样式的消息框,但这不是通过修改MSIL轻松做到的

    也许您应该添加如下内容:

    call void [System]System.Diagnostics.Trace::Write(string)
    
    通过对快速控制台应用程序进行反编译,消息框调用的工作方式如下:

    ldstr "blah"
    stloc.0 
    ldloc.0 
    call valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms.MessageBox::Show(string)
    pop 
    

    好的,谢谢你的帮助,现在更清楚了

    如果无法从aspx文件中抛出MessageBox,我会尝试在文件中写入一些内容

    IL_0034:  ldstr      "C:\\...\\WebSite1\\toto.txt"
    IL_0039:  newobj     instance void [mscorlib]System.IO.StreamWriter::.ctor(string)
    IL_003e:  stloc.1
    IL_003f:  ldloc.1
    IL_0040:  ldstr      "hello world"
    IL_0045:  callvirt   instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
    IL_004a:  nop
    IL_004b:  ldloc.1
    IL_004c:  callvirt   instance void [mscorlib]System.IO.TextWriter::Close()
    IL_0051:  nop
    
    加载网页时没有错误或异常,但未创建或修改文件:\

    我不明白为什么,因为如果我把同样的代码直接放在C#中的.aspx中,就可以了

    否:(我确定它是一个web.net应用程序(file.aspx)