예제 #1
0
        /// <summary>
        /// Returns an IAddressFinder based on the country name or
        /// 2- or 3-letter ISO country code
        /// </summary>
        /// <param name="countryNameOrCode"></param>
        /// <returns></returns>
        public IAddressFinder GetAddressFinder(string countryNameOrCode)
        {
            IAddressFinder addressFinder = null;

            try
            {
                // Get the country region info from it's ISO code or name
                var countryRegionInfo = Utilities.GetCountryByCode(countryNameOrCode) ?? Utilities.GetCountryByName(countryNameOrCode);
                if (countryRegionInfo == null)
                {
                    _logger.LogError($"Invalid country code or country name. Value provided {countryNameOrCode}");
                    return(null);
                }

                Constants.WellKnownAddressExtractorCountryName countryName = (Constants.WellKnownAddressExtractorCountryName)Enum.Parse(typeof(Constants.WellKnownAddressExtractorCountryName), countryRegionInfo.Name);

                // Return the respective address finder as per the country
                switch (countryName)
                {
                case Constants.WellKnownAddressExtractorCountryName.CA:
                    return(new CanadianAddressFinder(_logger));

                default:
                    return(new GenericAddressFinder(_logger));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                addressFinder = new GenericAddressFinder(_logger);
            }
            return(addressFinder);
        }
        /// <inheritdoc/>>
        public async Task WaitUntilCodeIsReadyToBeInjected(Process gameProcess)
        {
            IAddressFinder addressFinder = _addressFinderFactory.CreateAddressFinder(gameProcess);

            await WaitUntilSaveGameLoaded(gameProcess, addressFinder).ConfigureAwait(false);
            await WaitUntilNotInLoadingScreen(gameProcess, addressFinder).ConfigureAwait(false);
        }
        private async Task WaitUntilNotInLoadingScreen(Process gameProcess, IAddressFinder addressFinder)
        {
            int loadingScreenFlagAddress = addressFinder.GetLoadingScreenFlagAddress();

            while (true)
            {
                int  loadingScreenFlag = _processFunctionsService.ReadMemoryInt(gameProcess.Handle, loadingScreenFlagAddress);
                bool isInLoadingScreen = (loadingScreenFlag & 1) == 1;
                if (!isInLoadingScreen)
                {
                    break;
                }

                await Task.Delay(1000).ConfigureAwait(false);
            }
        }
        private async Task WaitUntilSaveGameLoaded(Process gameProcess, IAddressFinder addressFinder)
        {
            int saveGameLoadedFlagAddress = addressFinder.GetSaveGameLoadedFlagAddress();

            while (true)
            {
                int  saveGameLoadedFlag = _processFunctionsService.ReadMemoryInt(gameProcess.Handle, saveGameLoadedFlagAddress);
                bool isSaveGameLoaded   = (saveGameLoadedFlag & 1) == 1;
                if (isSaveGameLoaded)
                {
                    break;
                }

                await Task.Delay(1000).ConfigureAwait(false);
            }
        }
 public GameFunctionHookService
 (
     IDllInjector dllInjector,
     IProcessFunctionsService processFunctionsService,
     IDllFunctionFinder dllFunctionFinder,
     IAddressFinder addressFinder,
     string hookDllPath,
     Process gameProcess
 )
 {
     _dllInjector             = dllInjector;
     _processFunctionsService = processFunctionsService;
     _dllFunctionFinder       = dllFunctionFinder;
     _addressFinder           = addressFinder;
     _hookDllPath             = hookDllPath;
     _gameProcess             = gameProcess;
     InjectDll(hookDllPath, gameProcess);
 }
예제 #6
0
 internal void OnPostAuthorizeRequest(HttpContextBase context)
 {
     Diagnostics.SendWatsonReportOnUnhandledException(delegate()
     {
         if (!this.isEnabled)
         {
             return;
         }
         IAddressFinderDiagnostics addressFinderDiagnostics = this.GetDiagnostics(context);
         IAddressFinder addressFinder = this.addressFinderFactory.CreateAddressFinder(HttpProxyGlobals.ProtocolType, context.Request.Url.AbsolutePath);
         if (addressFinder != null)
         {
             AddressFinderSource source   = new AddressFinderSource(context.Items, context.Request.Headers, context.Request.QueryString, context.Request.Url, context.Request.ApplicationPath, context.Request.FilePath, context.Request.Cookies);
             IRoutingKey[] value          = addressFinder.Find(source, addressFinderDiagnostics);
             context.Items["RoutingKeys"] = value;
         }
         else
         {
             ExTraceGlobals.VerboseTracer.TraceDebug <string, Uri, ProtocolType>((long)this.GetHashCode(), "[AddressFinderModule::OnPostAuthorizeRequest]: addressFinder is null: Method {0}; Url {1}; Protocol {2};", context.Request.HttpMethod, context.Request.Url, HttpProxyGlobals.ProtocolType);
             addressFinderDiagnostics.AddErrorInfo("addressFinder is null");
         }
         addressFinderDiagnostics.LogRoutingKeys();
     }, new Diagnostics.LastChanceExceptionHandler(this.LastChanceExceptionHandler));
 }
 private void RetrieveAddresses(IAddressFinder addressFinder)
 {
     _xCameraAddress                            = addressFinder.GetXCameraAddress();
     _yCameraAddress                            = addressFinder.GetYCameraAddress();
     _zCameraAddress                            = addressFinder.GetZCameraAddress();
     _unlimitedZoomCodeAddress                  = addressFinder.GetUnlimitedZoomCodeAddress();
     _horizontalCameraAngleAddress              = addressFinder.GetHorizontalCameraAngleAddress();
     _verticalCameraAngleAddress                = addressFinder.GetVerticalCameraAngleAddress();
     _freeCameraCodeAddress                     = addressFinder.GetFreeCameraCodeAddress();
     _collisionZoomAdjustmentCodeAddress        = addressFinder.GetCollisionZoomAdjustmentCodeAddress();
     _autoCameraAngleAdjustmentCodeAddress      = addressFinder.GetAutoCameraAngleAdjustmentCodeAddress();
     _cameraZoomDistanceAddress                 = addressFinder.GetCameraZoomDistanceAddress();
     _loadingScreenFlagAddress                  = addressFinder.GetLoadingScreenFlagAddress();
     _menuScreenFlagAddress                     = addressFinder.GetMenuScreenFlagAddress();
     _saveGameLoadedFlagAddress                 = addressFinder.GetSaveGameLoadedFlagAddress();
     _dialogueFlagAddress                       = addressFinder.GetDialogueFlagAddress();
     _menuOrDialogueFlagAddress                 = addressFinder.GetMenuOrDialogueFlagAddress();
     _zoomStateCodeAddress                      = addressFinder.GetZoomStateCodeAddress();
     _centeringCameraBehindCharacterCodeAddress = addressFinder.GetCenteringCameraBehindCharacterCodeAddress();
     _menuOrDialogueEnteredCodeAddress          = addressFinder.GetMenuOrDialogueEnteredCodeAddress();
     _menuOrDialogueExitedCodeAddress           = addressFinder.GetMenuOrDialogueExitedCodeAddress();
     _loadingScreenEnteredCodeAddress           = addressFinder.GetLoadingScreenEnteredCodeAddress();
     _loadingScreenExitedCodeAddress            = addressFinder.GetLoadingScreenExitedCodeAddress();
 }
예제 #8
0
        public IGameValueService CreateGameValueService(Process process)
        {
            IAddressFinder addressFinder = _addressFinderFactory.CreateAddressFinder(process);

            return(new GameValueService(addressFinder, _processFunctionsService, process.Handle));
        }
예제 #9
0
 public GameValueService(IAddressFinder addressFinder, IProcessFunctionsService processFunctionsService, IntPtr processHandle)
 {
     _addressFinder           = addressFinder;
     _processFunctionsService = processFunctionsService;
     _processHandle           = processHandle;
 }
예제 #10
0
 public AddressController(ILogger <AddressController> logger, IAddressFinder addressFinder)
 {
     _logger        = logger;
     _addressFinder = addressFinder;
 }
예제 #11
0
        public IGameFunctionHookService CreateGameFunctionHookService(Process gameProcess)
        {
            IAddressFinder addressFinder = _addressFinderFactory.CreateAddressFinder(gameProcess);

            return(new GameFunctionHookService(_dllInjector, _processFunctionsService, _dllFunctionFinder, addressFinder, _hookDllPath, gameProcess));
        }
 public AddressFinderWithCache(IAddressFinder addressFinder)
 {
     RetrieveAddresses(addressFinder);
 }