Archive: Installer Corrupt, Bad Opcode


Installer Corrupt, Bad Opcode
  This installer is a mess. The code is huge, long and serves a bunch of intricate functions. I get the "installer corrupt, bad opcode" error when I try to run the installation part (up to that point it is fine). I barely understand the syntax of NSIS, so I'm guessing I made a stupid mistake somewhere along those lines. Sorry about the wall-o-text; I have no idea where the problem lies. I'm certain all the required files are there. Does this forum not have line-wrapping for code snippets? I'll remove the HUGE file lists (replaced with '...', because I doubt they are the problem.

Any help would be greatly appreciated.

[edit - Moderation]
Changed code block to an attachment


Aaaaaaa!
Use PasteBin or Attach your .nsi file, do not paste so huge codes!!

Errors:
1. Add label Skip to section Essential Files
2. Your error is in function ReplaceLineStr
I do not have required files so I assume there is some parameter missing on the stack so the Exch fails.


Exch $R0 ; string to replace that whole line with <<<< HERE is the error because

MessageBox MB_OK $R0 I cannot see this MessageBox
>

Sorry, I'm really trying to understand this. Its a far cry from the OOP I'm used to...

So my first guess at what you mean is Essential files is missing the skip line at the end of the section. This is because Essential Files are required no matter what in the installer. But do I still need a skip?

As for the second part, I'm not sure what you're saying. Do I need to make that part look like you typed it? Literally throwing that message box line after the Exch line? I need more specifics, but thank you so much still for being helpful.


Invalid Opcode usually means stack corruption. You're pushing or popping (or exch'ing) values incorrectly. This is what T.Slappy meant, the Exch commands in your ReplaceLineStr function aren't correct.


Okay, well that tells me nothing unfortunately. I pretty much inherited this project so it isn't like I've been working with this stuff for long. I frankly have not the slightest clue what this function is supposed to do, which is probably why I don't even see the error to begin with. Its weird that this should pop up though. Perhaps I received a slightly outdated version of the source used because the previous released installer works fine. Regardless, I'm really new to this, I need slightly less technical explanations.

According to this, that function is fine.

This is the other major function with stacking. The version there has two differences from mine:

Example:

IfErrors error
...

StrCpy $0 ''




Mine:

IfErrors empty
...
empty:
StrCpy $0 ''


Does it matter? Also, should the functions be defined at the begging of my script to work properly? And also someone please tell me if the Skip label is needed for the non-optional essential files and why.


Originally posted by Rajada
Does it matter? Also, should the functions be defined at the begging of my script to work properly?
No and no.

If you had done a single search through your sourcecode, looking for 'ReplaceLineStr', you would have found that the code calls the function four times, but does it once without pushing the variables to the stack first. Obviously, you cannot 'Exch $R0' from the stack if the stack doesn't contain anything.

Oh how did that get there? Gosh I feel stupid. Plus HMNSIS' search function doesn't work, so that's another thing I figured out. I get it though, its like having an accessed none, its just the odd order and syntax that throws me. See, I'm used to calling functions at the same time as defining the input variables, for example DoThis(var1, var2). Now, being unfamiliar with this code, I need to determine if that first call extraneous or not. I don't see a reason for it to be there, but I want to be sure I didn't maybe accidentally remove the variables or some other equally dumb mistake.

You know, the older version doesn't have that line, how it got there I have no idea, but I'm pretty sure I get this a lot better now. From what you've said about the error itself it really does sound like this is the problem. If this works it will be a relief, I thought I was going to have to spend weeks troubleshooting it. Funny how I can be so proficient with OOP based languages but this stuff just throws me through a loop. But thanks for being patient with me guys.


Feel free to try nsL (sticky topic).

Stu


Yeah I got it working 100% with your help, thanks guys. Now I have to go back to my complicated, ten-thousand line OOP project that by some miracle I understand enough to debug myself. Wish me luck. XP


Shoot, one last problem. I re-compiled this on a Windows 7 32 bit OS and if I try to take it over to my XP computer it fails the integrity check and has no icon, just shows up as the default exe icon. What's going on?


If the integrity check fails, the file probably isn't integral anymore. If you want to check manually, you could of course do a manual CRC or MD5 check on the file. But most probably you didn't copy the file correctly.


Zipping it got it over uncorrupted, but still no icon on XP. DO I need to set that up separately than the main icon or something?


Only Windows Vista and 7 support very very large icons, so if that's all you have then you should add a smaller one. Are you sure this isn't just some icon caching issue?


I probably don't have a small one. Where would I find some help on how to define different icons for different OS's?


There are various free icon editors up on sourceforge. Google is your friend. What you want to do is make a multi-icon with different sizes. (And different color depths?)


Ok, yeah, I've used an icon editor before for this same thing, but I'll look into multi icons. Thanks!