This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA/win32] Problem storing result of GetProcAddress


Hello,

GetProcAddress returns a FARPROC, but the variables that we use to
store the result that GetProcAddress returned is typically defined as:

    static BOOL WINAPI (*GetModuleFileNameExA) (HANDLE, HMODULE *, DWORD, LPDWORD);

I cannot define GetModuleFileNameExA as a FARPROC, as FARPROC is a
generic type that does not have the correct profile for our function.
If the function was defined as a FARPROC, we'd have problems calling
the functions, since the number of args and the return value would
not match.

For now, the laziest way of dealing the problem was to cast the resut
to "void *", which shouldn't cause any problem on Windows. Alternatively,
we can define a function pointer type for each of the functions we import
and then cast the result to that type.

2009-01-07  Joel Brobecker  <brobecker@adacore.com>

        * win32-nat.c (has_detach_ability, set_process_privilege):
        Cast the result of GetProcAddress to (void *) to avoid
        a compilation warning.

Tested on x86-windows. Note that this depends on one of my previous
patches that renames certain global variables:

    | * win32-nat.c (kernel32_DebugSetProcessKillOnExit): Renames
    | DebugSetProcessKillOnExit.  Update all uses in this file.
    | (kernel32_DebugActiveProcessStop): Renames DebugActiveProcessStop.
    | Update all uses in this file.

OK to apply?

Thanks,
-- 
Joel

Attachment: farproc.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]