You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/09/07 10:42:36 UTC

svn commit: r812037 - in /commons/sandbox/runtime/trunk/src/main/native: Makefile.msc.in os/win32/main.c os/win32/subsys.c

Author: mturk
Date: Mon Sep  7 08:42:36 2009
New Revision: 812037

URL: http://svn.apache.org/viewvc?rev=812037&view=rev
Log:
Add skeleton subsys helper

Added:
    commons/sandbox/runtime/trunk/src/main/native/os/win32/subsys.c   (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
    commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=812037&r1=812036&r2=812037&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Mon Sep  7 08:42:36 2009
@@ -115,6 +115,7 @@
 	$(SRCDIR)/os/win32/sema.$(OBJ) \
 	$(SRCDIR)/os/win32/shm.$(OBJ) \
 	$(SRCDIR)/os/win32/signals.$(OBJ) \
+	$(SRCDIR)/os/win32/subsys.$(OBJ) \
 	$(SRCDIR)/os/win32/syslog.$(OBJ) \
 	$(SRCDIR)/os/win32/group.$(OBJ) \
 	$(SRCDIR)/os/win32/user.$(OBJ) \

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c?rev=812037&r1=812036&r2=812037&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c Mon Sep  7 08:42:36 2009
@@ -30,6 +30,8 @@
 
 static HINSTANCE        dll_instance = NULL;
 static WCHAR            dll_file_name[ACR_HBUFF_SIZ];
+static WCHAR            mod_file_name[ACR_HBUFF_SIZ];
+static WCHAR            dos_file_name[ACR_SBUFF_SIZ];
 static DWORD            dll_tls_index = TLS_OUT_OF_INDEXES;
 HANDLE                  dll_heap_handle = NULL;
 HANDLE                  dll_psig_handle = NULL;
@@ -81,7 +83,9 @@
          */
         case DLL_PROCESS_ATTACH:
             dll_instance = instance;
-            GetModuleFileNameW(instance, dll_file_name, ACR_HBUFF_LEN);
+            GetModuleFileNameW(instance, mod_file_name, ACR_HBUFF_LEN);
+            GetLongPathNameW(mod_file_name, dll_file_name, ACR_SBUFF_LEN);
+            GetShortPathNameW(dll_file_name, dos_file_name, ACR_SBUFF_LEN);
             dll_heap_handle = HeapCreate(0, 0, 0);
             if (!dll_heap_handle) {
                 /* No point to continue if we are missing the process heap */
@@ -327,7 +331,10 @@
      */
     em = SetErrorMode(0);
     SetErrorMode(em | SEM_NOOPENFILEERRORBOX);
-
+#if defined(DEBUG)
+    fprintf(stdout, "Initialized ACR : %S\n", dll_file_name);
+    fprintf(stdout, "                : %S\n", dos_file_name);
+#endif
     return 0;
 }
 

Added: commons/sandbox/runtime/trunk/src/main/native/os/win32/subsys.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/subsys.c?rev=812037&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/subsys.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/subsys.c Mon Sep  7 08:42:36 2009
@@ -0,0 +1,95 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_clazz.h"
+#include "acr_error.h"
+#include "acr_memory.h"
+#include "acr_string.h"
+#include "acr_tlsd.h"
+#include "acr_vm.h"
+
+#ifdef ACR_ENABLE_TEST
+
+/* Rundll32 Test exports.
+ * Wide char version doesn't fill the CmdLine correctly
+ * (testes both with cmd and cmd /U, however I don't have Unicode system,
+ * so cannot tell for sure. However GetCommandLineW works as expected, with
+ * the exception that it returns full command line since we are now inside
+ * rundll32 process.
+ * Use _TestRun@16 for entry point.
+ * We could use the .def file or /EXPORT:FunctionName and have decorated names.
+ * Note:
+ * Rundll32 is missing console, so redirection must be performed, and it requires
+ * the short names for locating the .dll.
+ */
+ACR_DECLARE(void) TestRunW(HWND hwnd, HINSTANCE hinst,
+                           LPWSTR lpszCmdLine, int nCmdShow)
+{
+    int rc = 0;
+
+    if ((rc = ACR_Initialize(NULL))) {
+        fprintf(stderr, "Failed to initialize the ACR error=%d\n", rc);
+        fflush(stderr);
+        goto cleanup;
+    }
+    if ((rc = ACR_PlatformInitialize(INVALID_HANDLE_VALUE, 0))) {
+        fprintf(stderr, "Failed to initialize the ACR platform error=%d\n", rc);
+        fflush(stderr);
+        goto cleanup;
+    }
+
+    fprintf(stdout, "Running TestRunW ...\n");
+    fprintf(stdout, "    HWND   : %p\n", hwnd);
+    fprintf(stdout, "    show   : %08x\n", nCmdShow);
+    fprintf(stdout, "    cmdline: %S\n", lpszCmdLine);
+    fflush(stdout);
+
+cleanup:
+
+    ExitProcess(rc);
+}
+
+ACR_DECLARE(void) TestRunA(HWND hwnd, HINSTANCE hinst,
+                           LPSTR lpszCmdLine, int nCmdShow)
+{
+    int rc = 0;
+
+    if ((rc = ACR_Initialize(NULL))) {
+        fprintf(stderr, "Failed to initialize the ACR error=%d\n", rc);
+        fflush(stderr);
+        goto cleanup;
+    }
+    if ((rc = ACR_PlatformInitialize(INVALID_HANDLE_VALUE, 0))) {
+        fprintf(stderr, "Failed to initialize the ACR platform error=%d\n", rc);
+        fflush(stderr);
+        goto cleanup;
+    }
+
+    fprintf(stdout, "Running TestRunW ...\n");
+    fprintf(stdout, "    HWND   : %p\n", hwnd);
+    fprintf(stdout, "    show   : %08x\n", nCmdShow);
+    fprintf(stdout, "    cmdline: %s\n", lpszCmdLine);
+    fflush(stdout);
+
+cleanup:
+
+    ExitProcess(rc);
+}
+
+#endif

Propchange: commons/sandbox/runtime/trunk/src/main/native/os/win32/subsys.c
------------------------------------------------------------------------------
    svn:eol-style = native