Dead reckoning is a promising yet often overlooked smartphone-based indoor localization technology that relies on phone-mounted sensors for counting steps and estimating walking directions, without the need for extensive sensor or landmark deployment. However, misalignment between the phone's direction and the user's actual movement direction can lead to unreliable direction estimates and inaccurate location tracking. To address this issue, this paper introduces SWiLoc (Smartphone and WiFi-based Localization), an enhanced direction correction system that integrates passive WiFi sensing with smartphone-based sensing to form Correction Zones. Our two-phase approach accurately measures the user's walking directions when passing through a Correction Zone and further refines successive direction estimates outside the zones, enabling continuous and reliable tracking. In addition to direction correction, SWiLoc extends its capabilities by incorporating a localization technique that leverages corrected directions to achieve precise user localization. This extension significantly enhances the system's applicability for high-accuracy localization tasks. Additionally, our innovative Fresnel zone-based approach, which utilizes unique hardware configurations and a fundamental geometric model, ensures accurate and robust direction estimation, even in scenarios with unreliable walking directions. We evaluate SWiLoc across two real-world environments, assessing its performance under varying conditions such as environmental changes, phone orientations, walking directions, and distances. Our comprehensive experiments demonstrate that SWiLoc achieves an average 75th percentile error of 8.89 degrees in walking direction estimation and an 80th percentile error of 1.12 m in location estimation. These figures represent reductions of 64% and 49%, respectively for direction and location estimation error, over existing state-of-the-art approaches.