├── .gitignore
├── GHKeyBrowser.sln
└── GHKeyBrowser
├── GHKeyBrowser.cpp
├── GHKeyBrowser.h
├── GHKeyBrowser.rc
├── GHKeyBrowser.vcxproj
├── GHKeyBrowserDlg.cpp
├── GHKeyBrowserDlg.h
├── ReadMe.txt
├── res
├── GHKeyBrowser.ico
└── GHKeyBrowser.rc2
├── resource.h
├── stdafx.cpp
├── stdafx.h
└── targetver.h
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | #################
3 | ## Eclipse
4 | #################
5 |
6 | *.pydevproject
7 | .project
8 | .metadata
9 | bin/**
10 | tmp/**
11 | tmp/**/*
12 | *.tmp
13 | *.bak
14 | *.swp
15 | *~.nib
16 | local.properties
17 | .classpath
18 | .settings/
19 | .loadpath
20 |
21 | # External tool builders
22 | .externalToolBuilders/
23 |
24 | # Locally stored "Eclipse launch configurations"
25 | *.launch
26 |
27 | # CDT-specific
28 | .cproject
29 |
30 | # PDT-specific
31 | .buildpath
32 |
33 |
34 | #################
35 | ## Visual Studio
36 | #################
37 |
38 | ## Ignore Visual Studio temporary files, build results, and
39 | ## files generated by popular Visual Studio add-ons.
40 |
41 | # User-specific files
42 | *.suo
43 | *.user
44 | *.sln.docstates
45 |
46 | # Build results
47 | [Dd]ebug/
48 | [Rr]elease/
49 | *_i.c
50 | *_p.c
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.vspscc
65 | .builds
66 |
67 | # Visual C++ cache files
68 | ipch/
69 | *.aps
70 | *.ncb
71 | *.opensdf
72 | *.sdf
73 |
74 | # Visual Studio profiler
75 | *.psess
76 | *.vsp
77 |
78 | # ReSharper is a .NET coding add-in
79 | _ReSharper*
80 |
81 | # Installshield output folder
82 | [Ee]xpress
83 |
84 | # DocProject is a documentation generator add-in
85 | DocProject/buildhelp/
86 | DocProject/Help/*.HxT
87 | DocProject/Help/*.HxC
88 | DocProject/Help/*.hhc
89 | DocProject/Help/*.hhk
90 | DocProject/Help/*.hhp
91 | DocProject/Help/Html2
92 | DocProject/Help/html
93 |
94 | # Click-Once directory
95 | publish
96 |
97 | # Others
98 | [Bb]in
99 | [Oo]bj
100 | sql
101 | TestResults
102 | *.Cache
103 | ClientBin
104 | stylecop.*
105 | ~$*
106 | *.dbmdl
107 | Generated_Code #added for RIA/Silverlight projects
108 |
109 | # Backup & report files from converting an old project file to a newer
110 | # Visual Studio version. Backup files are not needed, because we have git ;-)
111 | _UpgradeReport_Files/
112 | Backup*/
113 | UpgradeLog*.XML
114 |
115 |
116 |
117 | ############
118 | ## Windows
119 | ############
120 |
121 | # Windows image file caches
122 | Thumbs.db
123 |
124 | # Folder config file
125 | Desktop.ini
126 |
127 |
128 | #############
129 | ## Python
130 | #############
131 |
132 | *.py[co]
133 |
134 | # Packages
135 | *.egg
136 | *.egg-info
137 | dist
138 | build
139 | eggs
140 | parts
141 | bin
142 | var
143 | sdist
144 | develop-eggs
145 | .installed.cfg
146 |
147 | # Installer logs
148 | pip-log.txt
149 |
150 | # Unit test / coverage reports
151 | .coverage
152 | .tox
153 |
154 | #Translations
155 | *.mo
156 |
157 | #Mr Developer
158 | .mr.developer.cfg
159 |
160 |
--------------------------------------------------------------------------------
/GHKeyBrowser.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GHKeyBrowser", "GHKeyBrowser\GHKeyBrowser.vcxproj", "{CE1AE6D7-045B-4711-AC27-4146392B8599}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Release|Win32 = Release|Win32
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {CE1AE6D7-045B-4711-AC27-4146392B8599}.Debug|Win32.ActiveCfg = Debug|Win32
13 | {CE1AE6D7-045B-4711-AC27-4146392B8599}.Debug|Win32.Build.0 = Debug|Win32
14 | {CE1AE6D7-045B-4711-AC27-4146392B8599}.Release|Win32.ActiveCfg = Release|Win32
15 | {CE1AE6D7-045B-4711-AC27-4146392B8599}.Release|Win32.Build.0 = Release|Win32
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/GHKeyBrowser/GHKeyBrowser.cpp:
--------------------------------------------------------------------------------
1 |
2 | // GHKeyBrowser.cpp : Defines the class behaviors for the application.
3 | //
4 |
5 | #include "stdafx.h"
6 | #include "GHKeyBrowser.h"
7 | #include "GHKeyBrowserDlg.h"
8 |
9 | #ifdef _DEBUG
10 | #define new DEBUG_NEW
11 | #endif
12 |
13 |
14 | // CGHKeyBrowserApp
15 |
16 | BEGIN_MESSAGE_MAP(CGHKeyBrowserApp, CWinApp)
17 | ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
18 | END_MESSAGE_MAP()
19 |
20 |
21 | // CGHKeyBrowserApp construction
22 |
23 | CGHKeyBrowserApp::CGHKeyBrowserApp()
24 | {
25 | // TODO: add construction code here,
26 | // Place all significant initialization in InitInstance
27 | }
28 |
29 |
30 | // The one and only CGHKeyBrowserApp object
31 |
32 | CGHKeyBrowserApp theApp;
33 |
34 |
35 | // CGHKeyBrowserApp initialization
36 |
37 | BOOL CGHKeyBrowserApp::InitInstance()
38 | {
39 | // InitCommonControlsEx() is required on Windows XP if an application
40 | // manifest specifies use of ComCtl32.dll version 6 or later to enable
41 | // visual styles. Otherwise, any window creation will fail.
42 | INITCOMMONCONTROLSEX InitCtrls;
43 | InitCtrls.dwSize = sizeof(InitCtrls);
44 | // Set this to include all the common control classes you want to use
45 | // in your application.
46 | InitCtrls.dwICC = ICC_WIN95_CLASSES;
47 | InitCommonControlsEx(&InitCtrls);
48 |
49 | CWinApp::InitInstance();
50 |
51 |
52 | // Create the shell manager, in case the dialog contains
53 | // any shell tree view or shell list view controls.
54 | CShellManager *pShellManager = new CShellManager;
55 |
56 | // Standard initialization
57 | // If you are not using these features and wish to reduce the size
58 | // of your final executable, you should remove from the following
59 | // the specific initialization routines you do not need
60 | // Change the registry key under which our settings are stored
61 | // TODO: You should modify this string to be something appropriate
62 | // such as the name of your company or organization
63 | SetRegistryKey(_T("Local AppWizard-Generated Applications"));
64 |
65 | CGHKeyBrowserDlg dlg;
66 | m_pMainWnd = &dlg;
67 | INT_PTR nResponse = dlg.DoModal();
68 | if (nResponse == IDOK)
69 | {
70 | // TODO: Place code here to handle when the dialog is
71 | // dismissed with OK
72 | }
73 | else if (nResponse == IDCANCEL)
74 | {
75 | // TODO: Place code here to handle when the dialog is
76 | // dismissed with Cancel
77 | }
78 |
79 | // Delete the shell manager created above.
80 | if (pShellManager != NULL)
81 | {
82 | delete pShellManager;
83 | }
84 |
85 | // Since the dialog has been closed, return FALSE so that we exit the
86 | // application, rather than start the application's message pump.
87 | return FALSE;
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/GHKeyBrowser/GHKeyBrowser.h:
--------------------------------------------------------------------------------
1 |
2 | // GHKeyBrowser.h : main header file for the PROJECT_NAME application
3 | //
4 |
5 | #pragma once
6 |
7 | #ifndef __AFXWIN_H__
8 | #error "include 'stdafx.h' before including this file for PCH"
9 | #endif
10 |
11 | #include "resource.h" // main symbols
12 |
13 |
14 | // CGHKeyBrowserApp:
15 | // See GHKeyBrowser.cpp for the implementation of this class
16 | //
17 |
18 | class CGHKeyBrowserApp : public CWinApp
19 | {
20 | public:
21 | CGHKeyBrowserApp();
22 |
23 | // Overrides
24 | public:
25 | virtual BOOL InitInstance();
26 |
27 | // Implementation
28 |
29 | DECLARE_MESSAGE_MAP()
30 | };
31 |
32 | extern CGHKeyBrowserApp theApp;
--------------------------------------------------------------------------------
/GHKeyBrowser/GHKeyBrowser.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/github/GHKeyBrowser/53a5828e296ff6ecd225c55ea34a3348442c8f11/GHKeyBrowser/GHKeyBrowser.rc
--------------------------------------------------------------------------------
/GHKeyBrowser/GHKeyBrowser.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {CE1AE6D7-045B-4711-AC27-4146392B8599}
15 | GHKeyBrowser
16 | MFCProj
17 |
18 |
19 |
20 | Application
21 | true
22 | Unicode
23 | Static
24 |
25 |
26 | Application
27 | false
28 | true
29 | Unicode
30 | Static
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | true
44 |
45 |
46 | false
47 |
48 |
49 |
50 | Use
51 | Level3
52 | Disabled
53 | WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)
54 |
55 |
56 | Windows
57 | true
58 |
59 |
60 | false
61 | true
62 | _DEBUG;%(PreprocessorDefinitions)
63 |
64 |
65 | 0x0409
66 | _DEBUG;%(PreprocessorDefinitions)
67 | $(IntDir);%(AdditionalIncludeDirectories)
68 |
69 |
70 |
71 |
72 | Level3
73 | Use
74 | MinSpace
75 | true
76 | true
77 | WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)
78 | Size
79 | true
80 |
81 |
82 | Windows
83 | true
84 | true
85 | true
86 |
87 |
88 | false
89 | true
90 | NDEBUG;%(PreprocessorDefinitions)
91 |
92 |
93 | 0x0409
94 | NDEBUG;%(PreprocessorDefinitions)
95 | $(IntDir);%(AdditionalIncludeDirectories)
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 | Create
115 | Create
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/GHKeyBrowser/GHKeyBrowserDlg.cpp:
--------------------------------------------------------------------------------
1 |
2 | // GHKeyBrowserDlg.cpp : implementation file
3 | //
4 |
5 | #include "stdafx.h"
6 | #include "GHKeyBrowser.h"
7 | #include "GHKeyBrowserDlg.h"
8 | #include "afxdialogex.h"
9 |
10 | #ifdef _DEBUG
11 | #define new DEBUG_NEW
12 | #endif
13 |
14 |
15 | #include
16 | #include
17 | #include
18 |
19 | static char encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
20 | 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
21 | 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
22 | 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
23 | 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
24 | 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
25 | 'w', 'x', 'y', 'z', '0', '1', '2', '3',
26 | '4', '5', '6', '7', '8', '9', '+', '/'};
27 | static char *decoding_table = NULL;
28 | static int mod_table[] = {0, 2, 1};
29 |
30 | char *base64_decode(const char *data,
31 | size_t input_length,
32 | size_t *output_length)
33 | {
34 | if (input_length % 4 != 0) return NULL;
35 |
36 | *output_length = input_length / 4 * 3;
37 | if (data[input_length - 1] == '=') (*output_length)--;
38 | if (data[input_length - 2] == '=') (*output_length)--;
39 |
40 | char *decoded_data = new char[*output_length];
41 | if (decoded_data == NULL) return NULL;
42 |
43 | for (int i = 0, j = 0; i < input_length;) {
44 |
45 | uint32_t sextet_a = data[i] == '=' ? 0 & i++ : decoding_table[data[i++]];
46 | uint32_t sextet_b = data[i] == '=' ? 0 & i++ : decoding_table[data[i++]];
47 | uint32_t sextet_c = data[i] == '=' ? 0 & i++ : decoding_table[data[i++]];
48 | uint32_t sextet_d = data[i] == '=' ? 0 & i++ : decoding_table[data[i++]];
49 |
50 | uint32_t triple = (sextet_a << 3 * 6)
51 | + (sextet_b << 2 * 6)
52 | + (sextet_c << 1 * 6)
53 | + (sextet_d << 0 * 6);
54 |
55 | if (j < *output_length) decoded_data[j++] = (triple >> 2 * 8) & 0xFF;
56 | if (j < *output_length) decoded_data[j++] = (triple >> 1 * 8) & 0xFF;
57 | if (j < *output_length) decoded_data[j++] = (triple >> 0 * 8) & 0xFF;
58 | }
59 |
60 | return decoded_data;
61 | }
62 |
63 |
64 | void build_decoding_table()
65 | {
66 | decoding_table = new char[256];
67 |
68 | for (int i = 0; i < 0x40; i++)
69 | decoding_table[encoding_table[i]] = i;
70 | }
71 |
72 |
73 | void base64_cleanup() {
74 | free(decoding_table);
75 | }
76 |
77 | // CGHKeyBrowserDlg dialog
78 |
79 | CGHKeyBrowserDlg::CGHKeyBrowserDlg(CWnd* pParent /*=NULL*/)
80 | : CDialogEx(CGHKeyBrowserDlg::IDD, pParent)
81 | {
82 | m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
83 | }
84 |
85 | void CGHKeyBrowserDlg::DoDataExchange(CDataExchange* pDX)
86 | {
87 | CDialogEx::DoDataExchange(pDX);
88 | }
89 |
90 | BEGIN_MESSAGE_MAP(CGHKeyBrowserDlg, CDialogEx)
91 | ON_WM_PAINT()
92 | ON_WM_QUERYDRAGICON()
93 | ON_BN_CLICKED(IDOK, &CGHKeyBrowserDlg::OnBnClickedOk)
94 | ON_WM_GETMINMAXINFO()
95 | END_MESSAGE_MAP()
96 |
97 |
98 | // CGHKeyBrowserDlg message handlers
99 |
100 | void CGHKeyBrowserDlg::CalcHashByHand(wchar_t* fileFullPath, wchar_t* existingBuf)
101 | {
102 | char* input_buf = new char[1024*1024];
103 |
104 | DWORD input_size = 0;
105 | HANDLE hInput = CreateFile(fileFullPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
106 | ReadFile(hInput, input_buf, 1024*1024*sizeof(char), &input_size, NULL);
107 | CloseHandle(hInput);
108 |
109 | if (input_size <= 0) {
110 | return;
111 | }
112 |
113 | char* hash_start;
114 | int hash_size;
115 | for(int i=0; i < input_size; i++) {
116 | if (input_buf[i] == ' ') {
117 | hash_start = input_buf + i + 1;
118 | hash_size = input_size - i - 1;
119 | break;
120 | }
121 | }
122 |
123 | for(int i=0; i < hash_size; i++) {
124 | if (hash_start[i] == ' ') {
125 | hash_start[i] = 0;
126 | hash_size = strlen(hash_start);
127 | break;
128 | }
129 | }
130 |
131 | size_t decoded_size;
132 | char* decoded_data = base64_decode(hash_start, hash_size, &decoded_size);
133 |
134 | HCRYPTPROV hProv;
135 | HCRYPTHASH hMD5;
136 | CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
137 | CryptCreateHash(hProv, CALG_MD5, 0, 0, &hMD5);
138 |
139 | BYTE md5Buf[16];
140 | DWORD cbHash;
141 | CryptHashData(hMD5, (const BYTE*)decoded_data, decoded_size, 0);
142 | CryptGetHashParam(hMD5, HP_HASHVAL, md5Buf, &cbHash, 0);
143 | CryptDestroyHash(hMD5);
144 | CryptReleaseContext(hProv, 0);
145 |
146 | wchar_t result[MAX_PATH];
147 | wsprintf(result, L"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x %s\n",
148 | md5Buf[0], md5Buf[1], md5Buf[2], md5Buf[3], md5Buf[4], md5Buf[5], md5Buf[6], md5Buf[7],
149 | md5Buf[8], md5Buf[9], md5Buf[10], md5Buf[11], md5Buf[12], md5Buf[13], md5Buf[14], md5Buf[15],
150 | fileFullPath);
151 |
152 | wcscat(existingBuf, result);
153 | }
154 |
155 | bool CGHKeyBrowserDlg::RunSshKeyGenOnKey(wchar_t* fileFullPath, HANDLE hPipeWrite)
156 | {
157 | wchar_t ssh_keygen_path[MAX_PATH];
158 |
159 | ExpandEnvironmentStrings(L"%ProgramFiles%\\Git\\bin\\ssh-keygen.exe", ssh_keygen_path, MAX_PATH);
160 | //ExpandEnvironmentStrings(L"C:\\Users\\Paul\\AppData\\Local\\GitHub\\PortableGit_1.7.9.0\\bin\\ssh-keygen.exe", ssh_keygen_path, MAX_PATH);
161 | if (GetFileAttributes(ssh_keygen_path) == 0xFFFFFFFF) {
162 | return false;
163 | }
164 |
165 | wcscat(ssh_keygen_path, L" -lf ");
166 | wcscat(ssh_keygen_path, L"\"");
167 | wcscat(ssh_keygen_path, fileFullPath);
168 | wcscat(ssh_keygen_path, L"\"");
169 |
170 | // Create our process
171 | STARTUPINFO si;
172 | ZeroMemory(&si, sizeof(si));
173 | si.cb = sizeof(si);
174 | si.hStdOutput = hPipeWrite;
175 | si.hStdError = hPipeWrite;
176 | si.dwFlags |= STARTF_USESTDHANDLES;
177 | si.wShowWindow = SW_MINIMIZE;
178 |
179 | PROCESS_INFORMATION pi;
180 | ZeroMemory(&pi, sizeof(pi));
181 |
182 | if (!CreateProcess(NULL, ssh_keygen_path, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) {
183 | return false;
184 | }
185 |
186 | if (WaitForSingleObject(pi.hProcess, 60 * 1000) == WAIT_TIMEOUT) {
187 | TerminateProcess(pi.hProcess, -1);
188 | return false;
189 | }
190 |
191 | return true;
192 | }
193 |
194 | BOOL CGHKeyBrowserDlg::OnInitDialog()
195 | {
196 | CDialogEx::OnInitDialog();
197 |
198 | // Set the icon for this dialog. The framework does this automatically
199 | // when the application's main window is not a dialog
200 | SetIcon(m_hIcon, TRUE); // Set big icon
201 | SetIcon(m_hIcon, FALSE); // Set small icon
202 |
203 | // Set up pipes
204 | SECURITY_ATTRIBUTES sa;
205 | sa.nLength = sizeof(sa); sa.bInheritHandle = TRUE; sa.lpSecurityDescriptor = NULL;
206 | HANDLE hChildStdOutRd, hChildStdOutWr;
207 | CreatePipe(&hChildStdOutRd, &hChildStdOutWr, &sa, 0);
208 | SetHandleInformation(hChildStdOutRd, HANDLE_FLAG_INHERIT, 0);
209 |
210 | wchar_t ssh_path[MAX_PATH];
211 | ExpandEnvironmentStrings(L"%HOMEDRIVE%%HOMEPATH%\\.ssh\\*.pub", ssh_path, MAX_PATH);
212 |
213 | WIN32_FIND_DATA fd;
214 | HANDLE hFd = FindFirstFile(ssh_path, &fd);
215 | if (hFd == INVALID_HANDLE_VALUE) {
216 | MessageBox(L"You don't appear to have any SSH keys!", L"~/.ssh doesn't exist");
217 | TerminateProcess(GetCurrentProcess(), -1);
218 | }
219 |
220 | wchar_t* fallback_buf = NULL;
221 |
222 | do {
223 | ExpandEnvironmentStrings(L"%HOMEDRIVE%%HOMEPATH%\\.ssh", ssh_path, MAX_PATH);
224 | wcscat(ssh_path, L"\\");
225 | wcscat(ssh_path, fd.cFileName);
226 |
227 | if (!RunSshKeyGenOnKey(ssh_path, hChildStdOutWr)) {
228 | if (!fallback_buf) {
229 | build_decoding_table();
230 | fallback_buf = new wchar_t[8192];
231 | fallback_buf[0] = 0;
232 | }
233 |
234 | CalcHashByHand(ssh_path, fallback_buf);
235 | }
236 | } while (FindNextFile(hFd, &fd) != 0);
237 |
238 | FindClose(hFd);
239 |
240 | wchar_t* utf16buf = fallback_buf;
241 |
242 | if (!utf16buf) {
243 | CloseHandle(hChildStdOutWr);
244 |
245 | char* buf = new char[1024*1024];
246 | DWORD dwBytesRead;
247 | ZeroMemory(buf, sizeof(char) * 1024*1024);
248 |
249 | ReadFile(hChildStdOutRd, buf, 1024*1024*sizeof(char), &dwBytesRead, NULL);
250 |
251 | utf16buf = new wchar_t[1024*1024];
252 | MultiByteToWideChar(CP_UTF8, 0, buf, -1, utf16buf, 1024*1024);
253 | delete[] buf;
254 | }
255 |
256 | CString str(utf16buf);
257 | str.Replace(L"\n", L"\r\n");
258 |
259 | CEdit* pEd = (CEdit*)GetDlgItem(IDC_EDIT1);
260 | pEd->SetWindowTextW(str);
261 |
262 | return TRUE; // return TRUE unless you set the focus to a control
263 | }
264 |
265 | // If you add a minimize button to your dialog, you will need the code below
266 | // to draw the icon. For MFC applications using the document/view model,
267 | // this is automatically done for you by the framework.
268 |
269 | void CGHKeyBrowserDlg::OnPaint()
270 | {
271 | if (IsIconic())
272 | {
273 | CPaintDC dc(this); // device context for painting
274 |
275 | SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0);
276 |
277 | // Center icon in client rectangle
278 | int cxIcon = GetSystemMetrics(SM_CXICON);
279 | int cyIcon = GetSystemMetrics(SM_CYICON);
280 | CRect rect;
281 | GetClientRect(&rect);
282 | int x = (rect.Width() - cxIcon + 1) / 2;
283 | int y = (rect.Height() - cyIcon + 1) / 2;
284 |
285 | // Draw the icon
286 | dc.DrawIcon(x, y, m_hIcon);
287 | }
288 | else
289 | {
290 | CDialogEx::OnPaint();
291 | }
292 | }
293 |
294 | void CGHKeyBrowserDlg::OnGetMinMaxInfo(MINMAXINFO* mmi)
295 | {
296 | RECT r;
297 | this->GetWindowRect(&r);
298 |
299 | if (r.bottom - r.top < 10) {
300 | return;
301 | }
302 |
303 | mmi->ptMaxSize.x = r.right - r.left;
304 | mmi->ptMaxSize.y = r.bottom - r.top;
305 | mmi->ptMinTrackSize.x = r.right - r.left;
306 | mmi->ptMinTrackSize.y = r.bottom - r.top;
307 | mmi->ptMaxTrackSize.x = r.right - r.left;
308 | mmi->ptMaxTrackSize.y = r.bottom - r.top;
309 | }
310 |
311 | // The system calls this function to obtain the cursor to display while the user drags
312 | // the minimized window.
313 | HCURSOR CGHKeyBrowserDlg::OnQueryDragIcon()
314 | {
315 | return static_cast(m_hIcon);
316 | }
317 |
318 | void CGHKeyBrowserDlg::OnBnClickedOk()
319 | {
320 | TerminateProcess(GetCurrentProcess(), 0);
321 | }
322 |
--------------------------------------------------------------------------------
/GHKeyBrowser/GHKeyBrowserDlg.h:
--------------------------------------------------------------------------------
1 |
2 | // GHKeyBrowserDlg.h : header file
3 | //
4 |
5 | #pragma once
6 |
7 |
8 | // CGHKeyBrowserDlg dialog
9 | class CGHKeyBrowserDlg : public CDialogEx
10 | {
11 | // Construction
12 | public:
13 | CGHKeyBrowserDlg(CWnd* pParent = NULL); // standard constructor
14 |
15 | // Dialog Data
16 | enum { IDD = IDD_GHKEYBROWSER_DIALOG };
17 |
18 | protected:
19 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
20 |
21 |
22 |
23 | // Implementation
24 | protected:
25 | HICON m_hIcon;
26 |
27 | bool RunSshKeyGenOnKey(wchar_t* fileFullPath, HANDLE hPipeWrite);
28 | void CalcHashByHand(wchar_t* fileFullPath, wchar_t* existingBuf);
29 |
30 | // Generated message map functions
31 | virtual BOOL OnInitDialog();
32 |
33 | afx_msg void OnGetMinMaxInfo(MINMAXINFO* mmi);
34 | afx_msg void OnPaint();
35 | afx_msg HCURSOR OnQueryDragIcon();
36 | DECLARE_MESSAGE_MAP()
37 | public:
38 | afx_msg void OnBnClickedOk();
39 | };
40 |
--------------------------------------------------------------------------------
/GHKeyBrowser/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ================================================================================
2 | MICROSOFT FOUNDATION CLASS LIBRARY : GHKeyBrowser Project Overview
3 | ===============================================================================
4 |
5 | The application wizard has created this GHKeyBrowser application for
6 | you. This application not only demonstrates the basics of using the Microsoft
7 | Foundation Classes but is also a starting point for writing your application.
8 |
9 | This file contains a summary of what you will find in each of the files that
10 | make up your GHKeyBrowser application.
11 |
12 | GHKeyBrowser.vcxproj
13 | This is the main project file for VC++ projects generated using an application wizard.
14 | It contains information about the version of Visual C++ that generated the file, and
15 | information about the platforms, configurations, and project features selected with the
16 | application wizard.
17 |
18 | GHKeyBrowser.vcxproj.filters
19 | This is the filters file for VC++ projects generated using an Application Wizard.
20 | It contains information about the association between the files in your project
21 | and the filters. This association is used in the IDE to show grouping of files with
22 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the
23 | "Source Files" filter).
24 |
25 | GHKeyBrowser.h
26 | This is the main header file for the application. It includes other
27 | project specific headers (including Resource.h) and declares the
28 | CGHKeyBrowserApp application class.
29 |
30 | GHKeyBrowser.cpp
31 | This is the main application source file that contains the application
32 | class CGHKeyBrowserApp.
33 |
34 | GHKeyBrowser.rc
35 | This is a listing of all of the Microsoft Windows resources that the
36 | program uses. It includes the icons, bitmaps, and cursors that are stored
37 | in the RES subdirectory. This file can be directly edited in Microsoft
38 | Visual C++. Your project resources are in 1033.
39 |
40 | res\GHKeyBrowser.ico
41 | This is an icon file, which is used as the application's icon. This
42 | icon is included by the main resource file GHKeyBrowser.rc.
43 |
44 | res\GHKeyBrowser.rc2
45 | This file contains resources that are not edited by Microsoft
46 | Visual C++. You should place all resources not editable by
47 | the resource editor in this file.
48 |
49 |
50 | /////////////////////////////////////////////////////////////////////////////
51 |
52 | The application wizard creates one dialog class:
53 |
54 | GHKeyBrowserDlg.h, GHKeyBrowserDlg.cpp - the dialog
55 | These files contain your CGHKeyBrowserDlg class. This class defines
56 | the behavior of your application's main dialog. The dialog's template is
57 | in GHKeyBrowser.rc, which can be edited in Microsoft Visual C++.
58 |
59 |
60 | /////////////////////////////////////////////////////////////////////////////
61 |
62 | Other standard files:
63 |
64 | StdAfx.h, StdAfx.cpp
65 | These files are used to build a precompiled header (PCH) file
66 | named GHKeyBrowser.pch and a precompiled types file named StdAfx.obj.
67 |
68 | Resource.h
69 | This is the standard header file, which defines new resource IDs.
70 | Microsoft Visual C++ reads and updates this file.
71 |
72 | GHKeyBrowser.manifest
73 | Application manifest files are used by Windows XP to describe an applications
74 | dependency on specific versions of Side-by-Side assemblies. The loader uses this
75 | information to load the appropriate assembly from the assembly cache or private
76 | from the application. The Application manifest maybe included for redistribution
77 | as an external .manifest file that is installed in the same folder as the application
78 | executable or it may be included in the executable in the form of a resource.
79 | /////////////////////////////////////////////////////////////////////////////
80 |
81 | Other notes:
82 |
83 | The application wizard uses "TODO:" to indicate parts of the source code you
84 | should add to or customize.
85 |
86 | If your application uses MFC in a shared DLL, you will need
87 | to redistribute the MFC DLLs. If your application is in a language
88 | other than the operating system's locale, you will also have to
89 | redistribute the corresponding localized resources MFC100XXX.DLL.
90 | For more information on both of these topics, please see the section on
91 | redistributing Visual C++ applications in MSDN documentation.
92 |
93 | /////////////////////////////////////////////////////////////////////////////
94 |
--------------------------------------------------------------------------------
/GHKeyBrowser/res/GHKeyBrowser.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/github/GHKeyBrowser/53a5828e296ff6ecd225c55ea34a3348442c8f11/GHKeyBrowser/res/GHKeyBrowser.ico
--------------------------------------------------------------------------------
/GHKeyBrowser/res/GHKeyBrowser.rc2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/github/GHKeyBrowser/53a5828e296ff6ecd225c55ea34a3348442c8f11/GHKeyBrowser/res/GHKeyBrowser.rc2
--------------------------------------------------------------------------------
/GHKeyBrowser/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by GHKeyBrowser.rc
4 | //
5 |
6 | #define IDD_GHKEYBROWSER_DIALOG 102
7 | #define IDR_MAINFRAME 128
8 | #define IDC_LIST 1000
9 | #define IDC_EDIT1 1001
10 |
11 | // Next default values for new objects
12 | //
13 |
14 | #ifdef APSTUDIO_INVOKED
15 | #ifndef APSTUDIO_READONLY_SYMBOLS
16 | #define _APS_NEXT_RESOURCE_VALUE 129
17 | #define _APS_NEXT_COMMAND_VALUE 32771
18 | #define _APS_NEXT_CONTROL_VALUE 1002
19 | #define _APS_NEXT_SYMED_VALUE 101
20 | #endif
21 | #endif
22 |
--------------------------------------------------------------------------------
/GHKeyBrowser/stdafx.cpp:
--------------------------------------------------------------------------------
1 |
2 | // stdafx.cpp : source file that includes just the standard includes
3 | // GHKeyBrowser.pch will be the pre-compiled header
4 | // stdafx.obj will contain the pre-compiled type information
5 |
6 | #include "stdafx.h"
7 |
8 |
9 |
--------------------------------------------------------------------------------
/GHKeyBrowser/stdafx.h:
--------------------------------------------------------------------------------
1 |
2 | // stdafx.h : include file for standard system include files,
3 | // or project specific include files that are used frequently,
4 | // but are changed infrequently
5 |
6 | #pragma once
7 |
8 | #ifndef _SECURE_ATL
9 | #define _SECURE_ATL 1
10 | #endif
11 |
12 | #ifndef VC_EXTRALEAN
13 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
14 | #endif
15 |
16 | #include "targetver.h"
17 |
18 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
19 |
20 | // turns off MFC's hiding of some common and often safely ignored warning messages
21 | #define _AFX_ALL_WARNINGS
22 |
23 | #include // MFC core and standard components
24 | #include // MFC extensions
25 |
26 |
27 |
28 |
29 |
30 | #ifndef _AFX_NO_OLE_SUPPORT
31 | #include // MFC support for Internet Explorer 4 Common Controls
32 | #endif
33 | #ifndef _AFX_NO_AFXCMN_SUPPORT
34 | #include // MFC support for Windows Common Controls
35 | #endif // _AFX_NO_AFXCMN_SUPPORT
36 |
37 | #include // MFC support for ribbons and control bars
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | #ifdef _UNICODE
48 | #if defined _M_IX86
49 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
50 | #elif defined _M_X64
51 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
52 | #else
53 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
54 | #endif
55 | #endif
56 |
57 |
58 |
--------------------------------------------------------------------------------
/GHKeyBrowser/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------