copypasta'd from plClient winmain