mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-23 06:59:25 -05:00
Use DECL/GET_WINDOWS_FUNCTION in a few more places in place of ad-hoc
GetProcAddress(). [originally from svn r8739]
This commit is contained in:
parent
24b6168c1d
commit
b85038d8a9
@ -5041,16 +5041,12 @@ void modalfatalbox(char *fmt, ...)
|
|||||||
cleanup_exit(1);
|
cleanup_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef BOOL (WINAPI *p_FlashWindowEx_t)(PFLASHWINFO);
|
DECL_WINDOWS_FUNCTION(static, BOOL, FlashWindowEx, (PFLASHWINFO));
|
||||||
static p_FlashWindowEx_t p_FlashWindowEx = NULL;
|
|
||||||
|
|
||||||
static void init_flashwindow(void)
|
static void init_flashwindow(void)
|
||||||
{
|
{
|
||||||
HMODULE user32_module = LoadLibrary("USER32.DLL");
|
HMODULE user32_module = LoadLibrary("USER32.DLL");
|
||||||
if (user32_module) {
|
GET_WINDOWS_FUNCTION(user32_module, FlashWindowEx);
|
||||||
p_FlashWindowEx = (p_FlashWindowEx_t)
|
|
||||||
GetProcAddress(user32_module, "FlashWindowEx");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL flash_window_ex(DWORD dwFlags, UINT uCount, DWORD dwTimeout)
|
static BOOL flash_window_ex(DWORD dwFlags, UINT uCount, DWORD dwTimeout)
|
||||||
|
@ -19,9 +19,8 @@ static int requested_help;
|
|||||||
static char *help_path;
|
static char *help_path;
|
||||||
static int help_has_contents;
|
static int help_has_contents;
|
||||||
#ifndef NO_HTMLHELP
|
#ifndef NO_HTMLHELP
|
||||||
typedef HWND (CALLBACK *htmlhelp_t)(HWND, LPCSTR, UINT, DWORD);
|
DECL_WINDOWS_FUNCTION(static, HWND, HtmlHelpA, (HWND, LPCSTR, UINT, DWORD));
|
||||||
static char *chm_path;
|
static char *chm_path;
|
||||||
static htmlhelp_t htmlhelp;
|
|
||||||
#endif /* NO_HTMLHELP */
|
#endif /* NO_HTMLHELP */
|
||||||
|
|
||||||
void init_help(void)
|
void init_help(void)
|
||||||
@ -57,13 +56,12 @@ void init_help(void)
|
|||||||
chm_path = NULL;
|
chm_path = NULL;
|
||||||
if (chm_path) {
|
if (chm_path) {
|
||||||
HINSTANCE dllHH = LoadLibrary("hhctrl.ocx");
|
HINSTANCE dllHH = LoadLibrary("hhctrl.ocx");
|
||||||
if (dllHH) {
|
GET_WINDOWS_FUNCTION(dllHH, HtmlHelpA);
|
||||||
htmlhelp = (htmlhelp_t)GetProcAddress(dllHH, "HtmlHelpA");
|
if (!p_HtmlHelpA) {
|
||||||
if (!htmlhelp)
|
chm_path = NULL;
|
||||||
|
if (dllHH)
|
||||||
FreeLibrary(dllHH);
|
FreeLibrary(dllHH);
|
||||||
}
|
}
|
||||||
if (!htmlhelp)
|
|
||||||
chm_path = NULL;
|
|
||||||
}
|
}
|
||||||
#endif /* NO_HTMLHELP */
|
#endif /* NO_HTMLHELP */
|
||||||
}
|
}
|
||||||
@ -101,7 +99,7 @@ void launch_help(HWND hwnd, const char *topic)
|
|||||||
assert(topic[colonpos] != '\0');
|
assert(topic[colonpos] != '\0');
|
||||||
fname = dupprintf("%s::/%s.html>main", chm_path,
|
fname = dupprintf("%s::/%s.html>main", chm_path,
|
||||||
topic + colonpos + 1);
|
topic + colonpos + 1);
|
||||||
htmlhelp(hwnd, fname, HH_DISPLAY_TOPIC, 0);
|
p_HtmlHelpA(hwnd, fname, HH_DISPLAY_TOPIC, 0);
|
||||||
sfree(fname);
|
sfree(fname);
|
||||||
} else
|
} else
|
||||||
#endif /* NO_HTMLHELP */
|
#endif /* NO_HTMLHELP */
|
||||||
@ -113,7 +111,7 @@ void launch_help(HWND hwnd, const char *topic)
|
|||||||
} else {
|
} else {
|
||||||
#ifndef NO_HTMLHELP
|
#ifndef NO_HTMLHELP
|
||||||
if (chm_path) {
|
if (chm_path) {
|
||||||
htmlhelp(hwnd, chm_path, HH_DISPLAY_TOPIC, 0);
|
p_HtmlHelpA(hwnd, chm_path, HH_DISPLAY_TOPIC, 0);
|
||||||
} else
|
} else
|
||||||
#endif /* NO_HTMLHELP */
|
#endif /* NO_HTMLHELP */
|
||||||
if (help_path) {
|
if (help_path) {
|
||||||
@ -129,7 +127,7 @@ void quit_help(HWND hwnd)
|
|||||||
if (requested_help) {
|
if (requested_help) {
|
||||||
#ifndef NO_HTMLHELP
|
#ifndef NO_HTMLHELP
|
||||||
if (chm_path) {
|
if (chm_path) {
|
||||||
htmlhelp(NULL, NULL, HH_CLOSE_ALL, 0);
|
p_HtmlHelpA(NULL, NULL, HH_CLOSE_ALL, 0);
|
||||||
} else
|
} else
|
||||||
#endif /* NO_HTMLHELP */
|
#endif /* NO_HTMLHELP */
|
||||||
if (help_path) {
|
if (help_path) {
|
||||||
|
@ -113,10 +113,10 @@ static tree234 *rsakeys, *ssh2keys;
|
|||||||
|
|
||||||
static int has_security;
|
static int has_security;
|
||||||
#ifndef NO_SECURITY
|
#ifndef NO_SECURITY
|
||||||
typedef DWORD(WINAPI * gsi_fn_t)
|
DECL_WINDOWS_FUNCTION(static, DWORD, GetSecurityInfo,
|
||||||
(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
|
(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
|
||||||
PSID *, PSID *, PACL *, PACL *, PSECURITY_DESCRIPTOR *);
|
PSID *, PSID *, PACL *, PACL *,
|
||||||
static gsi_fn_t getsecurityinfo;
|
PSECURITY_DESCRIPTOR *));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1848,10 +1848,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (getsecurityinfo(proc, SE_KERNEL_OBJECT,
|
if (p_GetSecurityInfo(proc, SE_KERNEL_OBJECT,
|
||||||
OWNER_SECURITY_INFORMATION,
|
OWNER_SECURITY_INFORMATION,
|
||||||
&procowner, NULL, NULL, NULL,
|
&procowner, NULL, NULL, NULL,
|
||||||
&psd2) != ERROR_SUCCESS) {
|
&psd2) != ERROR_SUCCESS) {
|
||||||
#ifdef DEBUG_IPC
|
#ifdef DEBUG_IPC
|
||||||
debug(("couldn't get owner info for process\n"));
|
debug(("couldn't get owner info for process\n"));
|
||||||
#endif
|
#endif
|
||||||
@ -1859,10 +1859,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
return 0; /* unable to get security info */
|
return 0; /* unable to get security info */
|
||||||
}
|
}
|
||||||
CloseHandle(proc);
|
CloseHandle(proc);
|
||||||
if ((rc = getsecurityinfo(filemap, SE_KERNEL_OBJECT,
|
if ((rc = p_GetSecurityInfo(filemap, SE_KERNEL_OBJECT,
|
||||||
OWNER_SECURITY_INFORMATION,
|
OWNER_SECURITY_INFORMATION,
|
||||||
&mapowner, NULL, NULL, NULL,
|
&mapowner, NULL, NULL, NULL,
|
||||||
&psd1) != ERROR_SUCCESS)) {
|
&psd1) != ERROR_SUCCESS)) {
|
||||||
#ifdef DEBUG_IPC
|
#ifdef DEBUG_IPC
|
||||||
debug(
|
debug(
|
||||||
("couldn't get owner info for filemap: %d\n",
|
("couldn't get owner info for filemap: %d\n",
|
||||||
@ -1973,9 +1973,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
|||||||
* Attempt to get the security API we need.
|
* Attempt to get the security API we need.
|
||||||
*/
|
*/
|
||||||
advapi = LoadLibrary("ADVAPI32.DLL");
|
advapi = LoadLibrary("ADVAPI32.DLL");
|
||||||
getsecurityinfo =
|
GET_WINDOWS_FUNCTION(advapi, GetSecurityInfo);
|
||||||
(gsi_fn_t) GetProcAddress(advapi, "GetSecurityInfo");
|
if (!p_GetSecurityInfo) {
|
||||||
if (!getsecurityinfo) {
|
|
||||||
MessageBox(NULL,
|
MessageBox(NULL,
|
||||||
"Unable to access security APIs. Pageant will\n"
|
"Unable to access security APIs. Pageant will\n"
|
||||||
"not run, in case it causes a security breach.",
|
"not run, in case it causes a security breach.",
|
||||||
|
@ -23,9 +23,8 @@ static const char hex[16] = "0123456789ABCDEF";
|
|||||||
|
|
||||||
static int tried_shgetfolderpath = FALSE;
|
static int tried_shgetfolderpath = FALSE;
|
||||||
static HMODULE shell32_module = NULL;
|
static HMODULE shell32_module = NULL;
|
||||||
typedef HRESULT (WINAPI *p_SHGetFolderPath_t)
|
DECL_WINDOWS_FUNCTION(static, HRESULT, SHGetFolderPathA,
|
||||||
(HWND, int, HANDLE, DWORD, LPTSTR);
|
(HWND, int, HANDLE, DWORD, LPSTR));
|
||||||
static p_SHGetFolderPath_t p_SHGetFolderPath = NULL;
|
|
||||||
|
|
||||||
static void mungestr(const char *in, char *out)
|
static void mungestr(const char *in, char *out)
|
||||||
{
|
{
|
||||||
@ -499,21 +498,18 @@ static HANDLE access_random_seed(int action)
|
|||||||
* However, the invocation below requires IE5+ anyway,
|
* However, the invocation below requires IE5+ anyway,
|
||||||
* so stuff that. */
|
* so stuff that. */
|
||||||
shell32_module = LoadLibrary("SHELL32.DLL");
|
shell32_module = LoadLibrary("SHELL32.DLL");
|
||||||
if (shell32_module) {
|
GET_WINDOWS_FUNCTION(shell32_module, SHGetFolderPathA);
|
||||||
p_SHGetFolderPath = (p_SHGetFolderPath_t)
|
|
||||||
GetProcAddress(shell32_module, "SHGetFolderPathA");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (p_SHGetFolderPath) {
|
if (p_SHGetFolderPathA) {
|
||||||
if (SUCCEEDED(p_SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA,
|
if (SUCCEEDED(p_SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA,
|
||||||
NULL, SHGFP_TYPE_CURRENT, seedpath))) {
|
NULL, SHGFP_TYPE_CURRENT, seedpath))) {
|
||||||
strcat(seedpath, "\\PUTTY.RND");
|
strcat(seedpath, "\\PUTTY.RND");
|
||||||
if (try_random_seed(seedpath, action, &rethandle))
|
if (try_random_seed(seedpath, action, &rethandle))
|
||||||
return rethandle;
|
return rethandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(p_SHGetFolderPath(NULL, CSIDL_APPDATA,
|
if (SUCCEEDED(p_SHGetFolderPathA(NULL, CSIDL_APPDATA,
|
||||||
NULL, SHGFP_TYPE_CURRENT, seedpath))) {
|
NULL, SHGFP_TYPE_CURRENT, seedpath))) {
|
||||||
strcat(seedpath, "\\PUTTY.RND");
|
strcat(seedpath, "\\PUTTY.RND");
|
||||||
if (try_random_seed(seedpath, action, &rethandle))
|
if (try_random_seed(seedpath, action, &rethandle))
|
||||||
return rethandle;
|
return rethandle;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user