示例#1
0
/*
 * idnGetPrgEncoding - refer to Program's Local Encoding
 *
 *      use program name as registry key
 */
BOOL
idnGetPrgEncoding(char *enc, size_t len)
{
	if (GetStringFromRegistry(IDNVAL_ENCODE, enc, len,
				  IDN_PERPROG|IDN_CURUSER) != TRUE ||
	    enc[0] == '\0') {
		sprintf(enc, "CP%d", GetACP());
	}
	idnLogPrintf(idn_log_level_trace,
		     "idnGetPrgEncoding: %-.30s\n", enc);
	return (TRUE);
}
示例#2
0
HINSTANCE
idnWinsockHandle(void) {
	static HINSTANCE dll_handle = NULL;
	static int initialized = 0;

	if (!initialized) {
		/* Get the handle of the original winsock DLL */
		idnLogPrintf(idn_log_level_trace,
			     "idnWinsockHandle: loading original DLL..\n");
		dll_handle = load_original_dll();
	}
	initialized = 1;
	return (dll_handle);
}
示例#3
0
static BOOL
check_dll(const char *name) {
	HINSTANCE hdll = NULL;

#if 1
	hdll = LoadLibrary(name);
#else
	/*
	 * Just check the existence of the named DLL, without taking
	 * the trouble of calling DllMain.
	 */
	hdll = LoadLibraryEx(name, NULL, LOAD_LIBRARY_AS_DATAFILE);
#endif
	if (hdll == NULL) {
		idnLogPrintf(idn_log_level_trace,
			     "idnGetContext: DLL %s does not exist\n");
		return (FALSE);
	} else {
		idnLogPrintf(idn_log_level_trace,
			     "idnGetContext: DLL %s exists\n");
		FreeLibrary(hdll);
		return (TRUE);
	}
}
示例#4
0
BOOL
idnConvReq(idn_resconf_t ctx, const char FAR *from, char FAR *to, size_t tolen)
{
	idn_result_t r;

	idnLogReset();

	idnLogPrintf(idn_log_level_trace, "idnConvReq(from=%-.100s)\n", from);
	if (ctx == NULL) {
		idnLogPrintf(idn_log_level_trace, "idnConvReq: ctx is NULL\n");
		if (strlen(from) >= tolen)
			return FALSE;
		strcpy(to, from);
		return TRUE;
	}

	r = idn_res_encodename(ctx, IDN_ENCODE_APP, from, to, tolen);

	if (r == idn_success) {
		return TRUE;
	} else {
		return FALSE;
	}
}
HANDLE   PASCAL
WSAAsyncGetServByName(HWND a0, u_int a1, const char* a2, const char* a3, char* a4, int a5)
{
    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, const char* a2, const char* a3, char* a4, int a5);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub WSAAsyncGetServByName() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetServByName")) == NULL) {
	    FATAL("cannot find entry WSAAsyncGetServByName (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1, a2, a3, a4, a5);
}
int   PASCAL
WSAAsyncSelect(SOCKET a0, HWND a1, u_int a2, long a3)
{
    static int   (PASCAL *fp)(SOCKET a0, HWND a1, u_int a2, long a3);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub WSAAsyncSelect() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncSelect")) == NULL) {
	    FATAL("cannot find entry WSAAsyncSelect (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1, a2, a3);
}
unsigned long   PASCAL
inet_addr(const char* a0)
{
    static unsigned long   (PASCAL *fp)(const char* a0);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub inet_addr() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "inet_addr")) == NULL) {
	    FATAL("cannot find entry inet_addr (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0);
}
int  PASCAL
Arecv(int a0, int a1, int a2, int a3)
{
    static int  (PASCAL *fp)(int a0, int a1, int a2, int a3);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub Arecv() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "Arecv")) == NULL) {
	    FATAL("cannot find entry Arecv (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1, a2, a3);
}
int  PASCAL
closesockinfo(int a0)
{
    static int  (PASCAL *fp)(int a0);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub closesockinfo() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "closesockinfo")) == NULL) {
	    FATAL("cannot find entry closesockinfo (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0);
}
int   PASCAL
__WSAFDIsSet(SOCKET a0, fd_set* a1)
{
    static int   (PASCAL *fp)(SOCKET a0, fd_set* a1);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub __WSAFDIsSet() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "__WSAFDIsSet")) == NULL) {
	    FATAL("cannot find entry __WSAFDIsSet (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1);
}
void   PASCAL
WSASetLastError(int a0)
{
    static void   (PASCAL *fp)(int a0);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub WSASetLastError() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "WSASetLastError")) == NULL) {
	    FATAL("cannot find entry WSASetLastError (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
     (*fp)(a0);
}
int   PASCAL
setsockopt(SOCKET a0, int a1, int a2, const char* a3, int a4)
{
    static int   (PASCAL *fp)(SOCKET a0, int a1, int a2, const char* a3, int a4);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub setsockopt() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "setsockopt")) == NULL) {
	    FATAL("cannot find entry setsockopt (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1, a2, a3, a4);
}
int   PASCAL
select(int a0, fd_set* a1, fd_set* a2, fd_set* a3, const struct timeval* a4)
{
    static int   (PASCAL *fp)(int a0, fd_set* a1, fd_set* a2, fd_set* a3, const struct timeval* a4);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub select() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "select")) == NULL) {
	    FATAL("cannot find entry select (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1, a2, a3, a4);
}
int   PASCAL
recvfrom(SOCKET a0, char* a1, int a2, int a3, struct sockaddr* a4, int* a5)
{
    static int   (PASCAL *fp)(SOCKET a0, char* a1, int a2, int a3, struct sockaddr* a4, int* a5);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub recvfrom() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "recvfrom")) == NULL) {
	    FATAL("cannot find entry recvfrom (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1, a2, a3, a4, a5);
}
u_short   PASCAL
ntohs(u_short a0)
{
    static u_short   (PASCAL *fp)(u_short a0);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub ntohs() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "ntohs")) == NULL) {
	    FATAL("cannot find entry ntohs (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0);
}
int   PASCAL
ioctlsocket(SOCKET a0, long a1, u_long * a2)
{
    static int   (PASCAL *fp)(SOCKET a0, long a1, u_long * a2);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub ioctlsocket() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "ioctlsocket")) == NULL) {
	    FATAL("cannot find entry ioctlsocket (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1, a2);
}
 char * PASCAL
inet_ntoa(struct in_addr a0)
{
    static  char * (PASCAL *fp)(struct in_addr a0);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub inet_ntoa() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "inet_ntoa")) == NULL) {
	    FATAL("cannot find entry inet_ntoa (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0);
}
int   PASCAL
WSACancelAsyncRequest(HANDLE a0)
{
    static int   (PASCAL *fp)(HANDLE a0);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub WSACancelAsyncRequest() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "WSACancelAsyncRequest")) == NULL) {
	    FATAL("cannot find entry WSACancelAsyncRequest (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0);
}
FARPROC   PASCAL
WSASetBlockingHook(FARPROC a0)
{
    static FARPROC   (PASCAL *fp)(FARPROC a0);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub WSASetBlockingHook() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "WSASetBlockingHook")) == NULL) {
	    FATAL("cannot find entry WSASetBlockingHook (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0);
}
SOCKET   PASCAL
socket(int a0, int a1, int a2)
{
    static SOCKET   (PASCAL *fp)(int a0, int a1, int a2);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub socket() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "socket")) == NULL) {
	    FATAL("cannot find entry socket (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1, a2);
}
int   PASCAL
WSAStartup(WORD a0, LPWSADATA a1)
{
    static int   (PASCAL *fp)(WORD a0, LPWSADATA a1);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub WSAStartup() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "WSAStartup")) == NULL) {
	    FATAL("cannot find entry WSAStartup (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1);
}
int  PASCAL
MigrateWinsockConfiguration(int a0, int a1, int a2)
{
    static int  (PASCAL *fp)(int a0, int a1, int a2);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub MigrateWinsockConfiguration() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "MigrateWinsockConfiguration")) == NULL) {
	    FATAL("cannot find entry MigrateWinsockConfiguration (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1, a2);
}
int  PASCAL
WEP(void)
{
    static int  (PASCAL *fp)(void);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub WEP() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "WEP")) == NULL) {
	    FATAL("cannot find entry WEP (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)();
}
 struct protoent * PASCAL
getprotobynumber(int a0)
{
    static  struct protoent * (PASCAL *fp)(int a0);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub getprotobynumber() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "getprotobynumber")) == NULL) {
	    FATAL("cannot find entry getprotobynumber (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0);
}
int   PASCAL
getsockname(SOCKET a0, struct sockaddr* a1, int* a2)
{
    static int   (PASCAL *fp)(SOCKET a0, struct sockaddr* a1, int* a2);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub getsockname() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "getsockname")) == NULL) {
	    FATAL("cannot find entry getsockname (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1, a2);
}
BOOL   PASCAL
AcceptEx(SOCKET a0, SOCKET a1, PVOID a2, DWORD a3, DWORD a4, DWORD a5, LPDWORD a6, LPOVERLAPPED a7)
{
    static BOOL   (PASCAL *fp)(SOCKET a0, SOCKET a1, PVOID a2, DWORD a3, DWORD a4, DWORD a5, LPDWORD a6, LPOVERLAPPED a7);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub AcceptEx() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "AcceptEx")) == NULL) {
	    FATAL("cannot find entry AcceptEx (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1, a2, a3, a4, a5, a6, a7);
}
 struct servent * PASCAL
getservbyport(int a0, const char* a1)
{
    static  struct servent * (PASCAL *fp)(int a0, const char* a1);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub getservbyport() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "getservbyport")) == NULL) {
	    FATAL("cannot find entry getservbyport (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1);
}
VOID   PASCAL
GetAcceptExSockaddrs(PVOID a0, DWORD a1, DWORD a2, DWORD a3, struct sockaddr** a4, LPINT a5, struct sockaddr** a6, LPINT a7)
{
    static VOID   (PASCAL *fp)(PVOID a0, DWORD a1, DWORD a2, DWORD a3, struct sockaddr** a4, LPINT a5, struct sockaddr** a6, LPINT a7);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub GetAcceptExSockaddrs() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "GetAcceptExSockaddrs")) == NULL) {
	    FATAL("cannot find entry GetAcceptExSockaddrs (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
     (*fp)(a0, a1, a2, a3, a4, a5, a6, a7);
}
示例#29
0
BOOL
idnConvRsp(idn_resconf_t ctx, const char FAR *from, char FAR *to, size_t tolen)
{
	idnLogReset();

	idnLogPrintf(idn_log_level_trace, "idnConvRsp(from=%-.100s)\n", from);
	if (ctx == NULL) {
		if (strlen(from) >= tolen)
			return FALSE;
		strcpy(to, from);
		return TRUE;
	} else if (idn_res_decodename(ctx, IDN_DECODE_APP,
				      from, to, tolen) == idn_success) {
		return TRUE;
	} else {
		return FALSE;
	}
}
int   PASCAL
_org_gethostname(char* a0, int a1)
{
    static int   (PASCAL *fp)(char* a0, int a1);

#ifdef DEBUG_STUB
    idnLogPrintf(idn_log_level_trace, "stub _org_gethostname() called\n");
#endif
    if (fp == NULL) {
	void *p;
	if ((p = GetProcAddress(DLLHANDLE, "gethostname")) == NULL) {
	    FATAL("cannot find entry gethostname (%d)\n", GetLastError());
	    abort();
	}
	fp = p;
    }
    return (*fp)(a0, a1);
}