Changed the COM signatures....using ildasm.....

Hi,

I have a .exe COM which I used in .NET but some signatures got changed....so I opened it with ildasm and changed the signatures so that it should return something from the function....This is the error I'm getting now....

The runtime has encountered a fatal error. The address of the error was at 0x79e8aff6, on thread 0xb4. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

Any Ideas....

Thanks,

Harsimrat



Answer this question

Changed the COM signatures....using ildasm.....

  • autodoc

    for each(char s in Password)

    {

    inparr[index++] = (unsigned char)s;

    }

    inparr[index] = 0;



  • Sourabh

    I'm at a loss. Isn't this your COM code

    Either way, I don't see any code to put a null at the end of the char array. You should also use the memory window in debug mode to make sure your password is being passed into the array OK.



  • Anonymous_2075

    No, the function does work but that function is suppose to return S_OK....

    I'm checking the password in that function.....until I return S_OK or return true; I dont know it thinks the password is wrong.....I have no clue why thats happening....

    I'm 100% i'm wrong somewhere.....but cant figure out where......


  • sdfsedfdsfsdf

    Where is inparr defined Perhaps it's not long enough.



  • BaruchAshkenazi

    Hello Christian,

    Sorry for my annoying questions...This thing just bugged me too much...

    Can you please tell me, how to put null at the end of the char array....

    Thanks,

    Harsimrat


  • XDJ

    A long is 32 bit. A byte and unsigned char are both 8 bit, and I thought byte was unsigned. I see no reason why this would not work.



  • Moojjoo

    First of all, don't change the signatures unless you also change the code. You need to recompile your com object to support the return types you're hoping to get out of it.



  • Turkalp Kucur

    Hello Christian,

    I was wondering if you can provide a solution or someone could...I have no idea what is going now.....

    Thanks,

    Harsimrat


  • Melvin S. Bernstein

    I just have the .exe COM from a 3rd Party and no control over the source code of that .exe.....

    The original signature was

    HRESULT challenge ( long attemepts, unsigned char password[20]);

    // Raw methods

    virtual HRESULT __stdcall challenge( long attempts, unsigned char password[20]) = 0;

    But .NET changed them to

    System.Void Challenge(System.Int32 attemptsRemaining, System.Byte[] password)

    Now Unfortunately I cannot return anything from this function.......What is the best solution......


  • viobass

    Hi,

    If I do inparr[index] = 0;

    It gets COM Error saying....

    {"Linked object's source class has changed (Exception from HRESULT: 0x80040008 (OLE_E_CLASSDIFF))"} System.Exception {System.Runtime.InteropServices.COMException}

    I dont see any reason why this is throwing this error....



  • MartinOosthuizen

    The string you were passing in was a char *. A char * is an ASCII encoded string. It uses one byte per character. .NET uses UNICODE by default, which is two bytes per character. So, before you pass the string in to you dll, you probably want to use a method from that URL I gave you to convert the string to an ASCII string, because otherwise, you won't be passing in the string you think you are.



  • Inna Tzipris

    I dont know if I m following you.....

    This is what I'm doing, when I call my dll.....this function gets called which .NET changed the signatures...to void

    virtual void OnChallenge( int attemptsRemaining, cli::array<unsigned char> ^passwordHash)

    {

    String ^pAttempts = String::Empty;

    // Get DevicePin

    String ^BBPIN = String::Empty;

    BBPIN = RIM_USBClient::USBClient::GetDevicePin();

    // Figure out how many attemps are remaining

    if (attemptsRemaining.ToString() == "10")

    {

    pAttempts = "(" + "1" + "/" + "10" + ")" + ".";

    }

    else

    {

    int attempts = 10 - attemptsRemaining;

    // Add 1

    attempts = attempts + 1;

    // Put final number in a string

    pAttempts = "(" + attempts.ToString() + "/" + "10" + ")" + ".";

    }

    // Message to the User in case user doesn't enter correct 8 times

    if (attemptsRemaining.ToString() == "2")

    {

    }

    // Get the Form Instance

    RIM_USBClient::UserPassvalidation uValid;

    // Update some form stuff

    uValid.label4->Text = BBPIN->ToString();

    uValid.label5->Text = pAttempts->ToString();

    // Show Dialog

    uValid.ShowDialog();

    // Get the Password from label6

    String ^Password = String::Empty;

    Password = uValid.label6->Text;

    /*

    pin_ptr<unsigned char> pass = &passwordHash[20];

    pin_ptr<const wchar_t> pstr = PtrToStringChars(Password);

    sha_hash(pstr, Password->Length, pass);

    */

    array<unsigned char>^ inparr = gcnew array<unsigned char>(Password->Length);

    int index = 0;

    for each(char s in Password)

    {

    inparr[index++] = (unsigned char)s;

    }

    SHA1^ sha = gcnew SHA1CryptoServiceProvider();

    //array<unsigned char>^ outarr = sha->ComputeHash(inparr);

    passwordHash = sha->ComputeHash(inparr);

    }

    This function is supposed to (return S_OK) when the password is correct to get out of this function...How should I do it....


  • jretelny

    Sorry can you please explain me, I dont understand where.....
  • csdcomp

    Perhaps the issue is that you are passing a unicode string in, and it wants an ASCII string

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfsystemtextencodingclasstopic.asp

    That's a link to an MSDN page that talks about how to convert text between encodings.



  • Changed the COM signatures....using ildasm.....