mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00: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);
|
||||
}
|
||||
|
||||
typedef BOOL (WINAPI *p_FlashWindowEx_t)(PFLASHWINFO);
|
||||
static p_FlashWindowEx_t p_FlashWindowEx = NULL;
|
||||
DECL_WINDOWS_FUNCTION(static, BOOL, FlashWindowEx, (PFLASHWINFO));
|
||||
|
||||
static void init_flashwindow(void)
|
||||
{
|
||||
HMODULE user32_module = LoadLibrary("USER32.DLL");
|
||||
if (user32_module) {
|
||||
p_FlashWindowEx = (p_FlashWindowEx_t)
|
||||
GetProcAddress(user32_module, "FlashWindowEx");
|
||||
}
|
||||
GET_WINDOWS_FUNCTION(user32_module, FlashWindowEx);
|
||||
}
|
||||
|
||||
static BOOL flash_window_ex(DWORD dwFlags, UINT uCount, DWORD dwTimeout)
|
||||
|
@ -19,9 +19,8 @@ static int requested_help;
|
||||
static char *help_path;
|
||||
static int help_has_contents;
|
||||
#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 htmlhelp_t htmlhelp;
|
||||
#endif /* NO_HTMLHELP */
|
||||
|
||||
void init_help(void)
|
||||
@ -57,13 +56,12 @@ void init_help(void)
|
||||
chm_path = NULL;
|
||||
if (chm_path) {
|
||||
HINSTANCE dllHH = LoadLibrary("hhctrl.ocx");
|
||||
if (dllHH) {
|
||||
htmlhelp = (htmlhelp_t)GetProcAddress(dllHH, "HtmlHelpA");
|
||||
if (!htmlhelp)
|
||||
GET_WINDOWS_FUNCTION(dllHH, HtmlHelpA);
|
||||
if (!p_HtmlHelpA) {
|
||||
chm_path = NULL;
|
||||
if (dllHH)
|
||||
FreeLibrary(dllHH);
|
||||
}
|
||||
if (!htmlhelp)
|
||||
chm_path = NULL;
|
||||
}
|
||||
#endif /* NO_HTMLHELP */
|
||||
}
|
||||
@ -101,7 +99,7 @@ void launch_help(HWND hwnd, const char *topic)
|
||||
assert(topic[colonpos] != '\0');
|
||||
fname = dupprintf("%s::/%s.html>main", chm_path,
|
||||
topic + colonpos + 1);
|
||||
htmlhelp(hwnd, fname, HH_DISPLAY_TOPIC, 0);
|
||||
p_HtmlHelpA(hwnd, fname, HH_DISPLAY_TOPIC, 0);
|
||||
sfree(fname);
|
||||
} else
|
||||
#endif /* NO_HTMLHELP */
|
||||
@ -113,7 +111,7 @@ void launch_help(HWND hwnd, const char *topic)
|
||||
} else {
|
||||
#ifndef NO_HTMLHELP
|
||||
if (chm_path) {
|
||||
htmlhelp(hwnd, chm_path, HH_DISPLAY_TOPIC, 0);
|
||||
p_HtmlHelpA(hwnd, chm_path, HH_DISPLAY_TOPIC, 0);
|
||||
} else
|
||||
#endif /* NO_HTMLHELP */
|
||||
if (help_path) {
|
||||
@ -129,7 +127,7 @@ void quit_help(HWND hwnd)
|
||||
if (requested_help) {
|
||||
#ifndef NO_HTMLHELP
|
||||
if (chm_path) {
|
||||
htmlhelp(NULL, NULL, HH_CLOSE_ALL, 0);
|
||||
p_HtmlHelpA(NULL, NULL, HH_CLOSE_ALL, 0);
|
||||
} else
|
||||
#endif /* NO_HTMLHELP */
|
||||
if (help_path) {
|
||||
|
@ -113,10 +113,10 @@ static tree234 *rsakeys, *ssh2keys;
|
||||
|
||||
static int has_security;
|
||||
#ifndef NO_SECURITY
|
||||
typedef DWORD(WINAPI * gsi_fn_t)
|
||||
(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
|
||||
PSID *, PSID *, PACL *, PACL *, PSECURITY_DESCRIPTOR *);
|
||||
static gsi_fn_t getsecurityinfo;
|
||||
DECL_WINDOWS_FUNCTION(static, DWORD, GetSecurityInfo,
|
||||
(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
|
||||
PSID *, PSID *, PACL *, PACL *,
|
||||
PSECURITY_DESCRIPTOR *));
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -1848,10 +1848,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
if (getsecurityinfo(proc, SE_KERNEL_OBJECT,
|
||||
OWNER_SECURITY_INFORMATION,
|
||||
&procowner, NULL, NULL, NULL,
|
||||
&psd2) != ERROR_SUCCESS) {
|
||||
if (p_GetSecurityInfo(proc, SE_KERNEL_OBJECT,
|
||||
OWNER_SECURITY_INFORMATION,
|
||||
&procowner, NULL, NULL, NULL,
|
||||
&psd2) != ERROR_SUCCESS) {
|
||||
#ifdef DEBUG_IPC
|
||||
debug(("couldn't get owner info for process\n"));
|
||||
#endif
|
||||
@ -1859,10 +1859,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
return 0; /* unable to get security info */
|
||||
}
|
||||
CloseHandle(proc);
|
||||
if ((rc = getsecurityinfo(filemap, SE_KERNEL_OBJECT,
|
||||
OWNER_SECURITY_INFORMATION,
|
||||
&mapowner, NULL, NULL, NULL,
|
||||
&psd1) != ERROR_SUCCESS)) {
|
||||
if ((rc = p_GetSecurityInfo(filemap, SE_KERNEL_OBJECT,
|
||||
OWNER_SECURITY_INFORMATION,
|
||||
&mapowner, NULL, NULL, NULL,
|
||||
&psd1) != ERROR_SUCCESS)) {
|
||||
#ifdef DEBUG_IPC
|
||||
debug(
|
||||
("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.
|
||||
*/
|
||||
advapi = LoadLibrary("ADVAPI32.DLL");
|
||||
getsecurityinfo =
|
||||
(gsi_fn_t) GetProcAddress(advapi, "GetSecurityInfo");
|
||||
if (!getsecurityinfo) {
|
||||
GET_WINDOWS_FUNCTION(advapi, GetSecurityInfo);
|
||||
if (!p_GetSecurityInfo) {
|
||||
MessageBox(NULL,
|
||||
"Unable to access security APIs. Pageant will\n"
|
||||
"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 HMODULE shell32_module = NULL;
|
||||
typedef HRESULT (WINAPI *p_SHGetFolderPath_t)
|
||||
(HWND, int, HANDLE, DWORD, LPTSTR);
|
||||
static p_SHGetFolderPath_t p_SHGetFolderPath = NULL;
|
||||
DECL_WINDOWS_FUNCTION(static, HRESULT, SHGetFolderPathA,
|
||||
(HWND, int, HANDLE, DWORD, LPSTR));
|
||||
|
||||
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,
|
||||
* so stuff that. */
|
||||
shell32_module = LoadLibrary("SHELL32.DLL");
|
||||
if (shell32_module) {
|
||||
p_SHGetFolderPath = (p_SHGetFolderPath_t)
|
||||
GetProcAddress(shell32_module, "SHGetFolderPathA");
|
||||
}
|
||||
GET_WINDOWS_FUNCTION(shell32_module, SHGetFolderPathA);
|
||||
}
|
||||
if (p_SHGetFolderPath) {
|
||||
if (SUCCEEDED(p_SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA,
|
||||
NULL, SHGFP_TYPE_CURRENT, seedpath))) {
|
||||
if (p_SHGetFolderPathA) {
|
||||
if (SUCCEEDED(p_SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA,
|
||||
NULL, SHGFP_TYPE_CURRENT, seedpath))) {
|
||||
strcat(seedpath, "\\PUTTY.RND");
|
||||
if (try_random_seed(seedpath, action, &rethandle))
|
||||
return rethandle;
|
||||
}
|
||||
|
||||
if (SUCCEEDED(p_SHGetFolderPath(NULL, CSIDL_APPDATA,
|
||||
NULL, SHGFP_TYPE_CURRENT, seedpath))) {
|
||||
if (SUCCEEDED(p_SHGetFolderPathA(NULL, CSIDL_APPDATA,
|
||||
NULL, SHGFP_TYPE_CURRENT, seedpath))) {
|
||||
strcat(seedpath, "\\PUTTY.RND");
|
||||
if (try_random_seed(seedpath, action, &rethandle))
|
||||
return rethandle;
|
||||
|
Loading…
Reference in New Issue
Block a user