summaryrefslogtreecommitdiffstats
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-18 02:11:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-18 02:11:42 +0000
commitf7e67c947ed271b865268c21d6c6666991577d20 (patch)
treec94abcd5bd53916f888c8dde27227df3353df3cd /ruby.c
parentcda9d3c5df05019703cd34b639819f6394e3a144 (diff)
downloadruby-f7e67c947ed271b865268c21d6c6666991577d20.tar.gz
ruby-f7e67c947ed271b865268c21d6c6666991577d20.tar.xz
ruby-f7e67c947ed271b865268c21d6c6666991577d20.zip
* ruby.c (DllMain, ruby_init_loadpath): use DLL instance handle given
to DllMain instead of VirtualQuery so that loadpath becomes relative from the DLL on WinCE too. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/ruby.c b/ruby.c
index 045697c89..6dec7a2c8 100644
--- a/ruby.c
+++ b/ruby.c
@@ -259,6 +259,18 @@ translate_char(char *p, int from, int to)
}
#endif
+#if defined _WIN32 || defined __CYGWIN__
+static HMODULE libruby;
+
+BOOL WINAPI
+DllMain(HINSTANCE dll, DWORD reason, LPVOID reserved)
+{
+ if (reason == DLL_PROCESS_ATTACH)
+ libruby = dll;
+ return TRUE;
+}
+#endif
+
void
ruby_init_loadpath(void)
{
@@ -266,16 +278,8 @@ ruby_init_loadpath(void)
char libpath[MAXPATHLEN + 1];
char *p;
int rest;
+
#if defined _WIN32 || defined __CYGWIN__
- HMODULE libruby = NULL;
- MEMORY_BASIC_INFORMATION m;
-
-#ifndef _WIN32_WCE
- memset(&m, 0, sizeof(m));
- if (VirtualQuery(ruby_init_loadpath, &m, sizeof(m))
- && m.State == MEM_COMMIT)
- libruby = (HMODULE) m.AllocationBase;
-#endif
GetModuleFileName(libruby, libpath, sizeof libpath);
#elif defined(DJGPP)
extern char *__dos_argv0;