An unhandled exception of type 'System.AccessViolationException' occurred

Started by patryk_z_wawy, July 28, 2009, 01:45:56 AM

Previous topic - Next topic

patryk_z_wawy

Hi everyone,

There is an error which prevents me from checking correctness of my solution.

Here's the code connected with the problem:



        private void button2_Click(object sender, EventArgs e)
       {
         System.Text.ASCIIEncoding e = new System.Text.ASCIIEncoding();

          byte[] string1 = e.GetBytes(textBox2.Text);
          engine.hide(string1);
       }


I removed almost all code from hide procedure to isolate the problem:


hide PROC in1: PTR DWORD,

mov ebx, 1

ret
hide ENDP


When I execute ret instruction I get the following message:

Quote
QuoteAn unhandled exception of type 'System.AccessViolationException' occurred in degree.exe

It's strange that the exception is only when I use ebx register. If there is ecx or edx instead of ebx, there is no exception.

What's wrong? What I should do?

Thanks in advance!

dedndave

EBX, EBP, ESI, EDI, DF should be preserved in procedures
EAX, ECX, EDX may be modified
if you use the ebx register...

push ebx
.
.
.
mov ebx,1
.
.
.
pop ebx
ret