/**
* Forward declaration
*/
-static DWORD service_handler(DWORD dwControl, DWORD dwEventType,
- LPVOID lpEventData, LPVOID lpContext);
+static DWORD WINAPI service_handler(DWORD dwControl, DWORD dwEventType,
+ LPVOID lpEventData, LPVOID lpContext);
/**
* Logging hook for library logs, using stderr output
/**
* Control handler for console
*/
-static BOOL console_handler(DWORD dwCtrlType)
+static BOOL WINAPI console_handler(DWORD dwCtrlType)
{
switch (dwCtrlType)
{
/**
* Service handler function
*/
-static DWORD service_handler(DWORD dwControl, DWORD dwEventType,
- LPVOID lpEventData, LPVOID lpContext)
+static DWORD WINAPI service_handler(DWORD dwControl, DWORD dwEventType,
+ LPVOID lpEventData, LPVOID lpContext)
{
switch (dwControl)
{
/**
* Service main routine when running as service
*/
-static void service_main(DWORD dwArgc, LPTSTR *lpszArgv)
+static void WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv)
{
memset(&status, 0, sizeof(status));
status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
/**
* NotifyIpInterfaceChange() callback
*/
-static void change_interface(private_kernel_iph_net_t *this,
- MIB_IPINTERFACE_ROW_FIXUP *row, MIB_NOTIFICATION_TYPE type)
+static void WINAPI change_interface(void *user, PMIB_IPINTERFACE_ROW row_badal,
+ MIB_NOTIFICATION_TYPE type)
{
+ private_kernel_iph_net_t *this = user;
+ MIB_IPINTERFACE_ROW_FIXUP* row = (MIB_IPINTERFACE_ROW_FIXUP*)row_badal;
IP_ADAPTER_ADDRESSES addrs[64], *current;
ULONG res, size = sizeof(addrs);
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
.ifaces = linked_list_create(),
);
-
+ /* PIPINTERFACE_CHANGE_CALLBACK is not using WINAPI in MinGW, which seems
+ * to be wrong. Force a cast to our WINAPI call */
res = NotifyIpInterfaceChange(AF_UNSPEC, (void*)change_interface,
this, TRUE, &this->changes);
if (res != NO_ERROR)
/**
* FwpmNetEventSubscribe0() callback
*/
-static void event_callback(private_kernel_wfp_ipsec_t *this,
- const FWPM_NET_EVENT1 *event)
+static void WINAPI event_callback(void *user, const FWPM_NET_EVENT1 *event)
{
+ private_kernel_wfp_ipsec_t *this = user;
traffic_selector_t *local = NULL, *remote = NULL;
u_int8_t protocol = 0;
u_int16_t from_local = 0, to_local = 65535;
DWORD res;
res = FwpmNetEventSubscribe0(this->handle, &subscription,
- (void*)event_callback, this, &this->event);
+ event_callback, this, &this->event);
if (res != ERROR_SUCCESS)
{
DBG1(DBG_KNL, "registering for WFP events failed: 0x%08x", res);
/**
* WSASendMsg function
*/
- int (*WSASendMsg)(SOCKET, LPWSAMSG, DWORD, LPDWORD,
- LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
+ int WINAPI (*WSASendMsg)(SOCKET, LPWSAMSG, DWORD, LPDWORD,
+ LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
/**
* WSARecvMsg function
*/
- int (*WSARecvMsg)(SOCKET, LPWSAMSG, LPDWORD,
- LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
+ int WINAPI (*WSARecvMsg)(SOCKET, LPWSAMSG, LPDWORD,
+ LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
};
METHOD(socket_t, receiver, status_t,
/**
* APC routine invoked by main thread on worker failure
*/
-static void set_worker_failure(ULONG_PTR dwParam)
+static void WINAPI set_worker_failure(ULONG_PTR dwParam)
{
worker_failed = TRUE;
}
/**
* Vectored exception handler
*/
-static long eh_handler(PEXCEPTION_POINTERS ei)
+static long WINAPI eh_handler(PEXCEPTION_POINTERS ei)
{
char *ename;
bool old = FALSE;
/**
* APC to cancel a thread
*/
-static void docancel(private_thread_t *this)
+static void WINAPI docancel(ULONG_PTR dwParam)
{
+ private_thread_t *this = (private_thread_t*)dwParam;
+
/* make sure cancel() does not access this anymore */
threads_lock->lock(threads_lock);
threads_lock->unlock(threads_lock);
if (!this->cancel_pending)
{
this->cancel_pending = TRUE;
- QueueUserAPC((void*)docancel, this->handle, (uintptr_t)this);
+ QueueUserAPC(docancel, this->handle, (uintptr_t)this);
if (this->condvar)
{
WakeAllConditionVariable(this->condvar);
/**
* Control handler to catch ^C
*/
-static BOOL handler(DWORD dwCtrlType)
+static BOOL WINAPI handler(DWORD dwCtrlType)
{
switch (dwCtrlType)
{
* Provided via ws2_32
*/
#ifndef InetNtop
-const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
+const char WINAPI *inet_ntop(int af, const void *src, char *dst, socklen_t size);
#endif
/**
* Provided via ws2_32
*/
#ifndef InetPton
-int inet_pton(int af, const char *src, void *dst);
+int WINAPI inet_pton(int af, const char *src, void *dst);
#endif
/**