Small-angle X-ray scattering (SAXS) is an effective method to obtain microstructural information of materials. However, due to the influence of crystal surface effects, SAXS has a deviation in the characterization of the crystal microstructure. In order to solve the influence of crystal surface effect on the internal defect signal, the microstructure of Octahydro-1,3,5,7-tetranitro-1,3,5,7-tetrazocine (HMX) crystal was characterized by soaking the sample in the matching solution. We found that the absolute scattering intensity, specific surface and volume fraction of the sample in the matching solution are significantly lower than the initial sample, which solves the influence of the crystal surface effect on the test results. Comparing the scattering results of the samples in different electron density matching solutions, it was found that the best result was obtained when using GPL-107 perfluoropolyether (PFPE) matching solution and the same law was obtained by controlling the experiment with 2,4,6,8,10,12-hexanitrohexaazaisowurtzitane (CL-20) crystal. The fitting density was calculated according to the theoretical density and void volume fraction of the sample, and the calculated results are close to the test results of Particle Density Distribution Analyzer (PDDA). Based on this paper, we provide a method to obtain the correct information of crystal microstructure.