Genes have something to do with the ease of gaining muscle size - but not as much as some might say (in my opinion). The majority of "hardgainers" are people who are trying to simultaneously gain muscle and lose fat. Gaining muscle mass requires an excess of calories above baseline, and sufficient stimulus to convince your body that your life requires it. Your body operates on a pretty straight forward energy budget, and it will do everything it takes to have enough energy to run your brain, stay warm, and make babies. Beyond that, it tries to keep your physique sufficient to survive what a "typical" day demands. Exercise is your strategy to convince your body that it is worth spending valuable energy to build (metabolically) expensive tissue like muscle, and you have to keep at it long enough for your body to recognize that the state you want is now "typical" and that it needs to adapt to it.
This
person is a voice I've come to trust in understanding how diet, exercise, and social pressures interact with body image and health. She is one of the voices on the
Fitcast podcast - they have a huge archive of good stuff going back 5 years or so.
The main strike you have in quickly gaining muscle is having 2 X chromosomes. On the other hand, you strike me as a person who can commit to and execute a long term plan, and perseverance is the name of this game. In brief, the strategy is to lose enough weight through diet and do enough gradually increasing levels of exercise to position yourself for a successful program of weight training. You then train hard, eat well, and rest enough to get a good boost of body weight through muscle mass. You then establish a long term lifestyle of exercise and moderate eating to keep your physique where you want it.