The first thing you need to know is that showModalDialog() is not cross-browser compatible, and therefore its use should be avoided. What you are attempting will not work in Firefox, for example.
That said, you are correct in thinking that this kind of modal dialog box does not automatically have access to the parent window. You need to pass a reference to the parent like this:
window.showModalDialog( 'modalwindow.html', window, '');
Then in the modal box you can use:
var parentwin = window.dialogArguments;