* win32/win32.c (get_proc_address): refactoring.
* win32/win32.c (get_wsa_exetinsion_function): refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7b5e9245ac
commit
877e90f17a
@ -1,3 +1,9 @@
|
|||||||
|
Mon Nov 8 11:02:21 2010 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
|
* win32/win32.c (get_proc_address): refactoring.
|
||||||
|
|
||||||
|
* win32/win32.c (get_wsa_exetinsion_function): refactoring.
|
||||||
|
|
||||||
Mon Nov 8 09:45:35 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
Mon Nov 8 09:45:35 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* enc/trans/gbk-tbl.rb: Add euro sign. [ruby-core:33094]
|
* enc/trans/gbk-tbl.rb: Add euro sign. [ruby-core:33094]
|
||||||
|
@ -450,18 +450,37 @@ regulate_path(WCHAR *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FARPROC
|
||||||
|
get_proc_address(const char *module, const char *func, HANDLE *mh)
|
||||||
|
{
|
||||||
|
HANDLE h;
|
||||||
|
FARPROC ptr;
|
||||||
|
|
||||||
|
if (mh)
|
||||||
|
h = LoadLibrary(module);
|
||||||
|
else
|
||||||
|
h = GetModuleHandle(module);
|
||||||
|
if (!h)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ptr = GetProcAddress(h, func);
|
||||||
|
if (mh) {
|
||||||
|
if (ptr)
|
||||||
|
*mh = h;
|
||||||
|
else
|
||||||
|
FreeLibrary(h);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
static UINT
|
static UINT
|
||||||
get_system_directory(WCHAR *path, UINT len)
|
get_system_directory(WCHAR *path, UINT len)
|
||||||
{
|
{
|
||||||
HANDLE hKernel = GetModuleHandle("kernel32.dll");
|
|
||||||
|
|
||||||
if (hKernel) {
|
|
||||||
typedef UINT WINAPI wgetdir_func(WCHAR*, UINT);
|
typedef UINT WINAPI wgetdir_func(WCHAR*, UINT);
|
||||||
FARPROC ptr = GetProcAddress(hKernel, "GetSystemWindowsDirectoryW");
|
FARPROC ptr =
|
||||||
if (ptr) {
|
get_proc_address("kernel32", "GetSystemWindowsDirectoryW", NULL);
|
||||||
|
if (ptr)
|
||||||
return (*(wgetdir_func *)ptr)(path, len);
|
return (*(wgetdir_func *)ptr)(path, len);
|
||||||
}
|
|
||||||
}
|
|
||||||
return GetWindowsDirectoryW(path, len);
|
return GetWindowsDirectoryW(path, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,8 +588,7 @@ static void
|
|||||||
init_func(void)
|
init_func(void)
|
||||||
{
|
{
|
||||||
if (!cancel_io)
|
if (!cancel_io)
|
||||||
cancel_io = (cancel_io_t)GetProcAddress(GetModuleHandle("kernel32"),
|
cancel_io = (cancel_io_t)get_proc_address("kernel32", "CancelIo", NULL);
|
||||||
"CancelIo");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_stdhandle(void);
|
static void init_stdhandle(void);
|
||||||
@ -2663,6 +2681,19 @@ rb_w32_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FARPROC
|
||||||
|
get_wsa_exetinsion_function(SOCKET s, GUID *guid)
|
||||||
|
{
|
||||||
|
DWORD dmy;
|
||||||
|
FARPROC ptr = NULL;
|
||||||
|
|
||||||
|
WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, guid, sizeof(*guid),
|
||||||
|
&ptr, sizeof(ptr), &dmy, NULL, NULL);
|
||||||
|
if (!ptr)
|
||||||
|
errno = ENOSYS;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
#undef accept
|
#undef accept
|
||||||
|
|
||||||
int WSAAPI
|
int WSAAPI
|
||||||
@ -3002,14 +3033,10 @@ recvmsg(int fd, struct msghdr *msg, int flags)
|
|||||||
|
|
||||||
if (!pWSARecvMsg) {
|
if (!pWSARecvMsg) {
|
||||||
static GUID guid = WSAID_WSARECVMSG;
|
static GUID guid = WSAID_WSARECVMSG;
|
||||||
DWORD dmy;
|
pWSARecvMsg = (WSARecvMsg_t)get_wsa_exetinsion_function(s, &guid);
|
||||||
WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid, sizeof(guid),
|
if (!pWSARecvMsg)
|
||||||
&pWSARecvMsg, sizeof(pWSARecvMsg), &dmy, NULL, NULL);
|
|
||||||
if (!pWSARecvMsg) {
|
|
||||||
errno = ENOSYS;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
msghdr_to_wsamsg(msg, &wsamsg);
|
msghdr_to_wsamsg(msg, &wsamsg);
|
||||||
wsamsg.dwFlags |= flags;
|
wsamsg.dwFlags |= flags;
|
||||||
@ -3095,14 +3122,10 @@ sendmsg(int fd, const struct msghdr *msg, int flags)
|
|||||||
|
|
||||||
if (!pWSASendMsg) {
|
if (!pWSASendMsg) {
|
||||||
static GUID guid = WSAID_WSASENDMSG;
|
static GUID guid = WSAID_WSASENDMSG;
|
||||||
DWORD dmy;
|
pWSASendMsg = (WSASendMsg_t)get_wsa_exetinsion_function(s, &guid);
|
||||||
WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid, sizeof(guid),
|
if (!pWSASendMsg)
|
||||||
&pWSASendMsg, sizeof(pWSASendMsg), &dmy, NULL, NULL);
|
|
||||||
if (!pWSASendMsg) {
|
|
||||||
errno = ENOSYS;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
msghdr_to_wsamsg(msg, &wsamsg);
|
msghdr_to_wsamsg(msg, &wsamsg);
|
||||||
|
|
||||||
@ -3847,17 +3870,10 @@ wlink(const WCHAR *from, const WCHAR *to)
|
|||||||
if (!pCreateHardLinkW && !myerrno) {
|
if (!pCreateHardLinkW && !myerrno) {
|
||||||
HANDLE hKernel;
|
HANDLE hKernel;
|
||||||
|
|
||||||
hKernel = GetModuleHandle("kernel32.dll");
|
pCreateHardLinkW = (BOOL (WINAPI *)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES))get_proc_address("kernel32", "CreateHardLinkW", NULL);
|
||||||
if (hKernel) {
|
if (!pCreateHardLinkW)
|
||||||
pCreateHardLinkW = (BOOL (WINAPI *)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES))GetProcAddress(hKernel, "CreateHardLinkW");
|
|
||||||
if (!pCreateHardLinkW) {
|
|
||||||
myerrno = ENOSYS;
|
myerrno = ENOSYS;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
myerrno = map_errno(GetLastError());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!pCreateHardLinkW) {
|
if (!pCreateHardLinkW) {
|
||||||
errno = myerrno;
|
errno = myerrno;
|
||||||
return -1;
|
return -1;
|
||||||
@ -4701,12 +4717,8 @@ rb_w32_getppid(void)
|
|||||||
rb_pid_t ppid = 0;
|
rb_pid_t ppid = 0;
|
||||||
|
|
||||||
if (!IsWin95() && rb_w32_osver() >= 5) {
|
if (!IsWin95() && rb_w32_osver() >= 5) {
|
||||||
if (!pNtQueryInformationProcess) {
|
if (!pNtQueryInformationProcess)
|
||||||
HANDLE hNtDll = GetModuleHandle("ntdll.dll");
|
pNtQueryInformationProcess = (long (WINAPI *)(HANDLE, int, void *, ULONG, ULONG *))get_proc_address("ntdll.dll", "NtQueryInformationProcess", NULL);
|
||||||
if (hNtDll) {
|
|
||||||
pNtQueryInformationProcess = (long (WINAPI *)(HANDLE, int, void *, ULONG, ULONG *))GetProcAddress(hNtDll, "NtQueryInformationProcess");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pNtQueryInformationProcess) {
|
if (pNtQueryInformationProcess) {
|
||||||
struct {
|
struct {
|
||||||
long ExitStatus;
|
long ExitStatus;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user