#define GetConsoleFontSize dyn_GetConsoleFontSize
#define GetCurrentConsoleFont dyn_GetCurrentConsoleFont
-static BOOL WINAPI (*AdjustTokenPrivileges)(HANDLE, BOOL, PTOKEN_PRIVILEGES,
- DWORD, PTOKEN_PRIVILEGES, PDWORD);
-static BOOL WINAPI (*DebugActiveProcessStop) (DWORD);
-static BOOL WINAPI (*DebugBreakProcess) (HANDLE);
-static BOOL WINAPI (*DebugSetProcessKillOnExit) (BOOL);
-static BOOL WINAPI (*EnumProcessModules) (HANDLE, HMODULE *, DWORD,
- LPDWORD);
-static BOOL WINAPI (*GetModuleInformation) (HANDLE, HMODULE, LPMODULEINFO,
- DWORD);
-static BOOL WINAPI (*LookupPrivilegeValueA)(LPCSTR, LPCSTR, PLUID);
-static BOOL WINAPI (*OpenProcessToken)(HANDLE, DWORD, PHANDLE);
-static BOOL WINAPI (*GetCurrentConsoleFont) (HANDLE, BOOL,
- CONSOLE_FONT_INFO *);
-static COORD WINAPI (*GetConsoleFontSize) (HANDLE, DWORD);
+typedef BOOL WINAPI (AdjustTokenPrivileges_ftype) (HANDLE, BOOL,
+ PTOKEN_PRIVILEGES,
+ DWORD, PTOKEN_PRIVILEGES,
+ PDWORD);
+static AdjustTokenPrivileges_ftype *AdjustTokenPrivileges;
+
+typedef BOOL WINAPI (DebugActiveProcessStop_ftype) (DWORD);
+static DebugActiveProcessStop_ftype *DebugActiveProcessStop;
+
+typedef BOOL WINAPI (DebugBreakProcess_ftype) (HANDLE);
+static DebugBreakProcess_ftype *DebugBreakProcess;
+
+typedef BOOL WINAPI (DebugSetProcessKillOnExit_ftype) (BOOL);
+static DebugSetProcessKillOnExit_ftype *DebugSetProcessKillOnExit;
+
+typedef BOOL WINAPI (EnumProcessModules_ftype) (HANDLE, HMODULE *, DWORD,
+ LPDWORD);
+static EnumProcessModules_ftype *EnumProcessModules;
+
+typedef BOOL WINAPI (GetModuleInformation_ftype) (HANDLE, HMODULE,
+ LPMODULEINFO, DWORD);
+static GetModuleInformation_ftype *GetModuleInformation;
+
+typedef BOOL WINAPI (LookupPrivilegeValueA_ftype) (LPCSTR, LPCSTR, PLUID);
+static LookupPrivilegeValueA_ftype *LookupPrivilegeValueA;
+
+typedef BOOL WINAPI (OpenProcessToken_ftype) (HANDLE, DWORD, PHANDLE);
+static OpenProcessToken_ftype *OpenProcessToken;
+
+typedef BOOL WINAPI (GetCurrentConsoleFont_ftype) (HANDLE, BOOL,
+ CONSOLE_FONT_INFO *);
+static GetCurrentConsoleFont_ftype *GetCurrentConsoleFont;
+
+typedef COORD WINAPI (GetConsoleFontSize_ftype) (HANDLE, DWORD);
+static GetConsoleFontSize_ftype *GetConsoleFontSize;
#undef STARTUPINFO
#undef CreateProcess
#ifndef __CYGWIN__
# define __PMAX (MAX_PATH + 1)
- static DWORD WINAPI (*GetModuleFileNameEx) (HANDLE, HMODULE, LPSTR, DWORD);
+ typedef DWORD WINAPI (GetModuleFileNameEx_ftype) (HANDLE, HMODULE, LPSTR, DWORD);
+ static GetModuleFileNameEx_ftype *GetModuleFileNameEx;
# define STARTUPINFO STARTUPINFOA
# define CreateProcess CreateProcessA
# define GetModuleFileNameEx_name "GetModuleFileNameExA"
static CORE_ADDR cygwin_load_end;
# define __USEWIDE
typedef wchar_t cygwin_buf_t;
- static DWORD WINAPI (*GetModuleFileNameEx) (HANDLE, HMODULE,
- LPWSTR, DWORD);
+ typedef DWORD WINAPI (GetModuleFileNameEx_ftype) (HANDLE, HMODULE,
+ LPWSTR, DWORD);
+ static GetModuleFileNameEx_ftype *GetModuleFileNameEx;
# define STARTUPINFO STARTUPINFOW
# define CreateProcess CreateProcessW
# define GetModuleFileNameEx_name "GetModuleFileNameExW"
{
HMODULE hm = NULL;
+#define GPA(m, func) \
+ func = (func ## _ftype *) GetProcAddress (m, #func)
+
hm = LoadLibrary ("kernel32.dll");
if (hm)
{
- DebugActiveProcessStop = (void *)
- GetProcAddress (hm, "DebugActiveProcessStop");
- DebugBreakProcess = (void *)
- GetProcAddress (hm, "DebugBreakProcess");
- DebugSetProcessKillOnExit = (void *)
- GetProcAddress (hm, "DebugSetProcessKillOnExit");
- GetConsoleFontSize = (void *)
- GetProcAddress (hm, "GetConsoleFontSize");
- GetCurrentConsoleFont = (void *)
- GetProcAddress (hm, "GetCurrentConsoleFont");
+ GPA (hm, DebugActiveProcessStop);
+ GPA (hm, DebugBreakProcess);
+ GPA (hm, DebugSetProcessKillOnExit);
+ GPA (hm, GetConsoleFontSize);
+ GPA (hm, DebugActiveProcessStop);
+ GPA (hm, GetCurrentConsoleFont);
}
/* Set variables to dummy versions of these processes if the function
hm = LoadLibrary ("psapi.dll");
if (hm)
{
- EnumProcessModules = (void *)
- GetProcAddress (hm, "EnumProcessModules");
- GetModuleInformation = (void *)
- GetProcAddress (hm, "GetModuleInformation");
- GetModuleFileNameEx = (void *)
- GetProcAddress (hm, GetModuleFileNameEx_name);
+ GPA (hm, EnumProcessModules);
+ GPA (hm, GetModuleInformation);
+ GPA (hm, GetModuleFileNameEx);
}
if (!EnumProcessModules || !GetModuleInformation || !GetModuleFileNameEx)
hm = LoadLibrary ("advapi32.dll");
if (hm)
{
- OpenProcessToken = (void *) GetProcAddress (hm, "OpenProcessToken");
- LookupPrivilegeValueA = (void *)
- GetProcAddress (hm, "LookupPrivilegeValueA");
- AdjustTokenPrivileges = (void *)
- GetProcAddress (hm, "AdjustTokenPrivileges");
+ GPA (hm, OpenProcessToken);
+ GPA (hm, LookupPrivilegeValueA);
+ GPA (hm, AdjustTokenPrivileges);
/* Only need to set one of these since if OpenProcessToken fails nothing
else is needed. */
if (!OpenProcessToken || !LookupPrivilegeValueA
|| !AdjustTokenPrivileges)
OpenProcessToken = bad_OpenProcessToken;
}
+
+#undef GPA
}