Author: eliot Date: 2011-09-09 15:36:04 -0700 (Fri, 09 Sep 2011) New Revision: 2492 Modified: branches/Cog/nscogsrc/plugins/Win32OSProcessPlugin/Win32OSProcessPlugin.c branches/Cog/platforms/Cross/vm/sqSCCSVersion.h branches/Cog/platforms/win32/vm/sqWin32Intel.c branches/Cog/src/plugins/Win32OSProcessPlugin/Win32OSProcessPlugin.c Log: In the Newspeak VM, don't cd to the image's directory on win32. Fix off-by-one error in Win32OSProcessPlugin>primitiveGetCurrentWorkingDirectory so it doesn't include an erroneous trailing null. Modified: branches/Cog/nscogsrc/plugins/Win32OSProcessPlugin/Win32OSProcessPlugin.c =================================================================== --- branches/Cog/nscogsrc/plugins/Win32OSProcessPlugin/Win32OSProcessPlugin.c 2011-09-06 23:44:23 UTC (rev 2491) +++ branches/Cog/nscogsrc/plugins/Win32OSProcessPlugin/Win32OSProcessPlugin.c 2011-09-09 22:36:04 UTC (rev 2492) @@ -1,9 +1,9 @@ /* Automatically generated by - VMPluginCodeGenerator VMMaker.oscog-eem.105 uuid: 79234f80-ee6a-404c-9e5c-2134e3b76463 + VMPluginCodeGenerator * VMMaker.oscog-eem.123 uuid: 9c524903-b0c7-46a8-a37a-5dfda6fcd1f3 from - Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.31 uuid: b7c551ed-5e67-4774-9285-3f4a291fccb9 + Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.32 uuid: 7395e1c3-1315-4e31-ba5d-cced5f3f9565 */ -static char __buildInfo[] = "Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.31 uuid: b7c551ed-5e67-4774-9285-3f4a291fccb9 " __DATE__ ; +static char __buildInfo[] = "Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.32 uuid: 7395e1c3-1315-4e31-ba5d-cced5f3f9565 " __DATE__ ; @@ -158,9 +158,9 @@ struct VirtualMachine* interpreterProxy; static const char *moduleName = #ifdef SQUEAK_BUILTIN_PLUGIN - "Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.31 (i)" + "Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.32 (i)" #else - "Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.31 (e)" + "Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.32 (e)" #endif ; static int osprocessSandboxSecurity; @@ -298,7 +298,7 @@ ptr = ((char **) flattenedArrayOfStrings); idx = 0; while (idx < count) { - ptr[idx] = (flattenedArrayOfStrings + (((offsetArray[idx]) >> 1))); + ptr[idx] = (flattenedArrayOfStrings + (interpreterProxy->integerValueOf(offsetArray[idx]))); idx += 1; } } @@ -939,7 +939,7 @@ ptr = ((char **) flattenedArrayOfStrings); idx = 0; while (idx < count) { - ptr[idx] = (flattenedArrayOfStrings + (((offsets[idx]) >> 1))); + ptr[idx] = (flattenedArrayOfStrings + (interpreterProxy->integerValueOf(offsets[idx]))); idx += 1; } interpreterProxy->pop(4); @@ -973,32 +973,25 @@ DWORD requiredLen; - /* Allocate a dummy buffer buffer with no space (force a failure to GetCurrentDirectory) */ + /* Determine required size of result buffer (this form counts the terminating null) */ charSize = sizeof(TCHAR); - cwdString = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), 0); - - /* Determine required size of result buffer */ - - buffer = interpreterProxy->arrayValueOf(cwdString); - requiredLen = GetCurrentDirectory(0, buffer); + requiredLen = GetCurrentDirectory(0, 0); if (requiredLen == 0) { return interpreterProxy->primitiveFail(); } - cwdString = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), requiredLen * charSize); - /* Call GetCurrentDirectory() again to get the actual result */ + /* Call GetCurrentDirectory() again to get the actual result (which does not count the terminating null (!!)) */ - buffer = interpreterProxy->arrayValueOf(cwdString); + buffer = alloca(requiredLen * charSize); cwdLen = GetCurrentDirectory(requiredLen, buffer); - if (cwdLen == 0) { + if ((cwdLen == 0) + || (cwdLen > requiredLen)) { return interpreterProxy->primitiveFail(); } - if (cwdLen > requiredLen) { - return interpreterProxy->primitiveFail(); - } - interpreterProxy->pop(1); - interpreterProxy->push(cwdString); + cwdString = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), cwdLen * charSize); + strncpy(interpreterProxy->arrayValueOf(cwdString), buffer, cwdLen * charSize); + interpreterProxy->popthenPush(1, cwdString); } @@ -1316,11 +1309,11 @@ result = interpreterProxy->nilObject(); } else { - result = (((readCharBufferArray[index]) << 1) | 1); + result = interpreterProxy->integerObjectOf(readCharBufferArray[index]); } } else { - result = ((-1 << 1) | 1); + result = interpreterProxy->integerObjectOf(-1); } interpreterProxy->popthenPush(2, result); } @@ -1348,18 +1341,18 @@ index = interpreterProxy->stackIntegerValue(1); resultArray = interpreterProxy->stackValue(0); interpreterProxy->stObjectatput(resultArray, 1, interpreterProxy->positive32BitIntegerFor(readCharStatusArray[index])); - interpreterProxy->stObjectatput(resultArray, 2, (((readCharBufferArray[index]) << 1) | 1)); - interpreterProxy->stObjectatput(resultArray, 3, (((readCharCountArray[index]) << 1) | 1)); + interpreterProxy->stObjectatput(resultArray, 2, interpreterProxy->integerObjectOf(readCharBufferArray[index])); + interpreterProxy->stObjectatput(resultArray, 3, interpreterProxy->integerObjectOf(readCharCountArray[index])); if (readCharStatusArray[index]) { if ((readCharCountArray[index]) < 1) { result = interpreterProxy->nilObject(); } else { - result = (((readCharBufferArray[index]) << 1) | 1); + result = interpreterProxy->integerObjectOf(readCharBufferArray[index]); } } else { - result = ((-1 << 1) | 1); + result = interpreterProxy->integerObjectOf(-1); } interpreterProxy->popthenPush(3, result); } Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h ___________________________________________________________________ Modified: checkindate - Tue Sep 6 16:43:59 PDT 2011 + Fri Sep 9 15:34:39 PDT 2011 Modified: branches/Cog/platforms/win32/vm/sqWin32Intel.c =================================================================== --- branches/Cog/platforms/win32/vm/sqWin32Intel.c 2011-09-06 23:44:23 UTC (rev 2491) +++ branches/Cog/platforms/win32/vm/sqWin32Intel.c 2011-09-09 22:36:04 UTC (rev 2492) @@ -916,7 +916,9 @@ MessageBox(stWindow,crashInfo,TEXT("Fatal VM error"), MB_OK | MB_APPLMODAL | MB_ICONSTOP); +#if !NewspeakVM SetCurrentDirectoryW(vmLogDirW); +#endif /* print the above information */ f = fopen_for_append("crash.dmp"); if(f){ @@ -1002,7 +1004,9 @@ MessageBox(stWindow,crashInfo,TEXT("Fatal VM error"), MB_OK | MB_APPLMODAL | MB_ICONSTOP); +#if !NewspeakVM SetCurrentDirectoryW(vmLogDirW); +#endif /* print the above information */ f = fopen_for_append("crash.dmp"); if(f){ @@ -1399,6 +1403,8 @@ __try { # endif #endif /* !NO_FIRST_LEVEL_EXCEPTION_HANDLER */ + +#if !NewspeakVM /* set the CWD to the image location */ if(*imageName) { char path[MAX_PATH+1], *ptr; @@ -1409,6 +1415,7 @@ SetCurrentDirectory(path); } } +#endif /* !NewspeakVM */ /* display the splash screen */ ShowSplashScreen(); Modified: branches/Cog/src/plugins/Win32OSProcessPlugin/Win32OSProcessPlugin.c =================================================================== --- branches/Cog/src/plugins/Win32OSProcessPlugin/Win32OSProcessPlugin.c 2011-09-06 23:44:23 UTC (rev 2491) +++ branches/Cog/src/plugins/Win32OSProcessPlugin/Win32OSProcessPlugin.c 2011-09-09 22:36:04 UTC (rev 2492) @@ -1,9 +1,9 @@ /* Automatically generated by - VMPluginCodeGenerator VMMaker.oscog-eem.97 uuid: e5a88d4c-b638-4228-8a1d-39d5af02c8d8 + VMPluginCodeGenerator * VMMaker.oscog-eem.123 uuid: 9c524903-b0c7-46a8-a37a-5dfda6fcd1f3 from - Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.31 uuid: b7c551ed-5e67-4774-9285-3f4a291fccb9 + Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.32 uuid: 7395e1c3-1315-4e31-ba5d-cced5f3f9565 */ -static char __buildInfo[] = "Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.31 uuid: b7c551ed-5e67-4774-9285-3f4a291fccb9 " __DATE__ ; +static char __buildInfo[] = "Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.32 uuid: 7395e1c3-1315-4e31-ba5d-cced5f3f9565 " __DATE__ ; @@ -158,9 +158,9 @@ struct VirtualMachine* interpreterProxy; static const char *moduleName = #ifdef SQUEAK_BUILTIN_PLUGIN - "Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.31 (i)" + "Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.32 (i)" #else - "Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.31 (e)" + "Win32OSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.32 (e)" #endif ; static int osprocessSandboxSecurity; @@ -298,7 +298,7 @@ ptr = ((char **) flattenedArrayOfStrings); idx = 0; while (idx < count) { - ptr[idx] = (flattenedArrayOfStrings + (((offsetArray[idx]) >> 1))); + ptr[idx] = (flattenedArrayOfStrings + (interpreterProxy->integerValueOf(offsetArray[idx]))); idx += 1; } } @@ -939,7 +939,7 @@ ptr = ((char **) flattenedArrayOfStrings); idx = 0; while (idx < count) { - ptr[idx] = (flattenedArrayOfStrings + (((offsets[idx]) >> 1))); + ptr[idx] = (flattenedArrayOfStrings + (interpreterProxy->integerValueOf(offsets[idx]))); idx += 1; } interpreterProxy->pop(4); @@ -973,32 +973,25 @@ DWORD requiredLen; - /* Allocate a dummy buffer buffer with no space (force a failure to GetCurrentDirectory) */ + /* Determine required size of result buffer (this form counts the terminating null) */ charSize = sizeof(TCHAR); - cwdString = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), 0); - - /* Determine required size of result buffer */ - - buffer = interpreterProxy->arrayValueOf(cwdString); - requiredLen = GetCurrentDirectory(0, buffer); + requiredLen = GetCurrentDirectory(0, 0); if (requiredLen == 0) { return interpreterProxy->primitiveFail(); } - cwdString = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), requiredLen * charSize); - /* Call GetCurrentDirectory() again to get the actual result */ + /* Call GetCurrentDirectory() again to get the actual result (which does not count the terminating null (!!)) */ - buffer = interpreterProxy->arrayValueOf(cwdString); + buffer = alloca(requiredLen * charSize); cwdLen = GetCurrentDirectory(requiredLen, buffer); - if (cwdLen == 0) { + if ((cwdLen == 0) + || (cwdLen > requiredLen)) { return interpreterProxy->primitiveFail(); } - if (cwdLen > requiredLen) { - return interpreterProxy->primitiveFail(); - } - interpreterProxy->pop(1); - interpreterProxy->push(cwdString); + cwdString = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classString(), cwdLen * charSize); + strncpy(interpreterProxy->arrayValueOf(cwdString), buffer, cwdLen * charSize); + interpreterProxy->popthenPush(1, cwdString); } @@ -1316,11 +1309,11 @@ result = interpreterProxy->nilObject(); } else { - result = (((readCharBufferArray[index]) << 1) | 1); + result = interpreterProxy->integerObjectOf(readCharBufferArray[index]); } } else { - result = ((-1 << 1) | 1); + result = interpreterProxy->integerObjectOf(-1); } interpreterProxy->popthenPush(2, result); } @@ -1348,18 +1341,18 @@ index = interpreterProxy->stackIntegerValue(1); resultArray = interpreterProxy->stackValue(0); interpreterProxy->stObjectatput(resultArray, 1, interpreterProxy->positive32BitIntegerFor(readCharStatusArray[index])); - interpreterProxy->stObjectatput(resultArray, 2, (((readCharBufferArray[index]) << 1) | 1)); - interpreterProxy->stObjectatput(resultArray, 3, (((readCharCountArray[index]) << 1) | 1)); + interpreterProxy->stObjectatput(resultArray, 2, interpreterProxy->integerObjectOf(readCharBufferArray[index])); + interpreterProxy->stObjectatput(resultArray, 3, interpreterProxy->integerObjectOf(readCharCountArray[index])); if (readCharStatusArray[index]) { if ((readCharCountArray[index]) < 1) { result = interpreterProxy->nilObject(); } else { - result = (((readCharBufferArray[index]) << 1) | 1); + result = interpreterProxy->integerObjectOf(readCharBufferArray[index]); } } else { - result = ((-1 << 1) | 1); + result = interpreterProxy->integerObjectOf(-1); } interpreterProxy->popthenPush(3, result); } |
Free forum by Nabble | Edit this page |