What kind of work are you planning on doing?
I believe you would need to apply for a work permit from outside of Malaysia, at a Malaysian embassy. For clarity, consult with your local Malaysian embassy to find out the proper process. You might find our page on Work Permits for Malaysia useful.
I assume your girlfriend is a Malaysian citizen?
I've done an extensive search online but I'm struggling to find an answer to your question. As far as I know, the application for the spouse visa (known as a long-term social visit pass) must be done from within the country. I'm not sure if there is a specific visa for the purpose of coming into Malaysia to get married or if this can be done on a visit visa. If your girlfriend is currently in Malaysia, I think it would be best if she contacted immigration directly with your question. Otherwise, and perhaps in addition, you should get in touch with your local Malaysian embassy or consulate.
I found a blog post you may find useful: Guide to applying for a Long Term Social Visit Pass in Malaysia (Spouse Visa)
However, it appears to have been written in 2015, so a great deal may have changed since then. Elsewhere on the same blog you can find a few updates, but since this is not an official source it's best to only take this as a very basic idea of the possible steps, and still contact a Malaysian embassy or the Malaysian immigration department for clarity on the issue.
Best of luck.