Getting into PhD programme when having not the best grades due to personal issues I have studied Physics (Diploma) and since 3 years I work as a Software Engineer.

But I am starting to miss the high degree of intellectual challenge. So I am thinking to go back to academia. Unfortunately my Diploma grade was B (German 2), likewise the grade of my in-depth elective Theoretical Particle Physics. I think I could have done better, but my mother died of cancer during my Diploma thesis and this didn't leave much focus and time for me. Plus I started working on a Web App in the last 2 months of my studies. Other grades were better, my Math elective (Functional Analysis) was A+, likewise Theoretical Physics. My undergraduate studies' grades were mixed, between A+ and B-.

My thesis also does not look so well. Because of a lack of time it has orthographic errors, discussion of results is too short and the source code snippets in it look ugly. Once I applied for a job through a head hunter and after they saw my thesis they completely lost interest in me as a candidate.

So question: how hard is it in such a situation to apply for a PhD Programme and is it a good idea at all? What would be a good strategy when applying? I am interested in Mathematics, Theoretical Physics, Mathematical Physics or Computer Science.
In Germany even some renowned research institutes mention in the job offers that people with at least grade B should be encouraged to apply for a position. So I don't see here a major problem for you. No one looks on your pre-diploma grades, this is now different with the bachelor AND master degree. But you have to make a presentation of your diploma work for the job interview. I don't know what speaks against adding results that you worked out after that thesis to make the work more impressive, as you didn't have as much time as other students with a scholarship or rich parents and were forced to work besides your diploma work, especially as the diploma needs 12 months in germany. If they want you to send them your diplom pdf, than of course you have to look for another group.

The major problem I see is that you wrote your thesis now 3 years ago, and 2-2.5 years is also a deadline I saw several times in such german PhD job offers, as after some time you simply loose knowledge. 

Nonetheless you should try it, write a few dozen applications and look how much invitations for a job interview you get and in what fields, but be clear what your motivation is. Your question does sound to me like you a bored and desperated in your current job, that is not the best reason for a Prof. to hire you, you should show interest in a specific topic, related to your diploma work would make your motivation to do a PhD more credible to me.