Win32OperatingSystem.st
branchjv
changeset 18054 56594a8c6b83
parent 18045 c0c600e0d3b3
parent 15169 0cf7770d6e58
child 18057 8da7c39a6322
--- a/Win32OperatingSystem.st	Thu Apr 25 11:30:13 2013 +0100
+++ b/Win32OperatingSystem.st	Fri Apr 26 15:26:55 2013 +0100
@@ -10,8 +10,6 @@
  other person.  No title to or ownership of the software is
  hereby transferred.
 "
-'From Smalltalk/X, Version:6.2.3.0 on 10-04-2013 at 09:59:01'                   !
-
 "{ Package: 'stx:libbasic' }"
 
 AbstractOperatingSystem subclass:#Win32OperatingSystem
@@ -195,20 +193,6 @@
 
 #include "stxOSDefs.h"
 
-# ifdef COMPILE_FOR_WIN95
-/*
- * ensure that ST/X runs on NT, 95 and 98
- * (however, this disables some Win2K and XP features (sigh)
- */
-#  ifndef WINVER
-#   define WINVER 0x0400
-#  endif
-# endif
-
-#if WINVER < 0x0400
-# define NO_GETADAPTERSINFO
-#endif
-
 #define USE_H_ERRNO
 
 # if defined(i386) || defined(__i386__)
@@ -763,24 +747,15 @@
     HRESULT hres;
 
     if( ! coInitialized ) {
-#ifdef NO_NT4_0_COMPATIBILITY
-	FARPROC CoInitializeEx_entry = (FARPROC) CoInitializeEx;
-#else
-	FARPROC CoInitializeEx_entry = __get_ole32_functionAddress("CoInitializeEx");
-#endif /* NO_NT4_0_COMPATIBILITY */
-	if (CoInitializeEx_entry == NULL) {
-	    console_fprintf(stderr, "OperatingSystem [info]: no CoInitializeEx; COM not initialized\n" );
-	} else {
-	    hres = (*CoInitializeEx_entry)(NULL, COINIT_MULTITHREADED);
-	    if (! SUCCEEDED(hres)) {
-		console_fprintf(stderr, "OperatingSystem [info]: Could not open the COM library hres = %08x\n", hres );
-		goto error;
-	    }
-	    coInitialized = 1;
+        hres = CoInitializeEx(NULL, COINIT_MULTITHREADED);
+        if (! SUCCEEDED(hres)) {
+            console_fprintf(stderr, "OperatingSystem [info]: Could not open the COM library hres = %08x\n", hres );
+            goto error;
+        }
+        coInitialized = 1;
 #ifdef COM_DEBUG
-	    console_fprintf(stderr, "OperatingSystem [info]: COM initialized\n" );
-#endif
-	}
+        console_fprintf(stderr, "OperatingSystem [info]: COM initialized\n" );
+#endif
     }
     RETURN (self );
 
@@ -846,6 +821,7 @@
     "Modified: 7.1.1997 / 19:36:11 / stefan"
 ! !
 
+
 !Win32OperatingSystem class methodsFor:'OS signal constants'!
 
 sigABRT
@@ -5768,20 +5744,20 @@
     path := self primPathNameOf:pathName.
 
     path isNil ifTrue:[
-	(self isValidPath:pathName) ifFalse:[
-	    p := pathName.
-	    [(p size > 1)
-	     and:[p endsWith:(self fileSeparator)]
-	    ] whileTrue:[
-		p := p copyWithoutLast:1.
-	    ].
-	    ^ p
-	].
-
-	"/
-	"/ return the original - there is nothing else can we do
-	"/
-	path := self compressPath:pathName
+        (self isValidPath:pathName) ifFalse:[
+            p := pathName.
+            [(p size > 1)
+             and:[p endsWith:(self fileSeparator)]
+            ] whileTrue:[
+                p := p copyButLast:1.
+            ].
+            ^ p
+        ].
+
+        "/
+        "/ return the original - there is nothing else can we do
+        "/
+        path := self compressPath:pathName
     ].
     ^ path.
 
@@ -5877,124 +5853,102 @@
 
 primPathNameOf:aPathName
     "return the pathName of the argument, aPathString,
-     - thats the full pathname of the directory, starting at '/'.
-     This method here returns nil, if the OS does not provide a
-     realPath library function.
+     - thats the full pathname of the directory, starting at 'X:\'.
+     This method here returns nil, if the OS cannot perform the operation.
      Notice: if symbolic links are involved, the result may look different
      from what you expect."
 
-%{  /* xxSTACK: 16000 */
+    |error|
+
+%{
     if (__isStringLike(aPathName)) {
-	char nameBuffer[MAXPATHLEN + 1];
-	char nameBuffer2[MAXPATHLEN + 1];
-	char *returnedName = NULL;
-	int rslt;
+        char nameBuffer[MAXPATHLEN + 1];
+        char nameBuffer2[MAXPATHLEN + 1];
+        char *returnedName = NULL;
+        int rslt;
 
 #ifdef DO_WRAP_CALLS
-	char _aPathName[MAXPATHLEN+1];
-
-	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
-	do {
-	    __threadErrno = 0;
-	    rslt = STX_API_NOINT_CALL4( "GetFullPathNameA", GetFullPathNameA, _aPathName, MAXPATHLEN, nameBuffer, NULL);
-	} while ((rslt < 0) && (__threadErrno == EINTR));
-#else
-	rslt = GetFullPathNameA(__stringVal(aPathName), MAXPATHLEN, nameBuffer, NULL);
-#endif
-	returnedName = nameBuffer;
-
-	if (rslt > 0) {
-	    /*
-	     * Attention: GetLongPathName is not available on old NT4.0/W95/W98
-	     */
-	    static FARPROC GetLongPathName_entry = NULL;
-#ifdef NO_NT4_0_COMPATIBILITY
-	    GetLongPathName_entry = (FARPROC) GetLongPathNameA;
-#else
-	    if (GetLongPathName_entry == NULL) {
-		GetLongPathName_entry = __get_kernel32_functionAddress("GetLongPathNameA");
-	    }
-#endif /* NO_NT4_0_COMPATIBILITY */
-
-	    if (GetLongPathName_entry) {
+        char _aPathName[MAXPATHLEN+1];
+
+        strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
+        do {
+            __threadErrno = 0;
+            rslt = STX_API_NOINT_CALL4( "GetFullPathNameA", GetFullPathNameA, _aPathName, MAXPATHLEN, nameBuffer, NULL);
+        } while ((rslt < 0) && (__threadErrno == EINTR));
+#else
+        rslt = GetFullPathNameA(__stringVal(aPathName), MAXPATHLEN, nameBuffer, NULL);
+#endif
+        returnedName = nameBuffer;
+
+        if (rslt > 0) {
 #ifdef DO_WRAP_CALLS
-		do {
-		    __threadErrno = 0;
-		    rslt = STX_API_NOINT_CALL3( "GetLongPathNameA", GetLongPathName_entry, nameBuffer, nameBuffer2, MAXPATHLEN);
-		} while ((rslt < 0) && (__threadErrno == EINTR));
-#else
-		rslt = (*GetLongPathName_entry)(nameBuffer, nameBuffer2, MAXPATHLEN);
-#endif
-		returnedName = nameBuffer2;
-	    }
-	}
-	if (rslt > 0) {
-	    RETURN ( __MKSTRING(returnedName) );
-	}
-	__threadErrno = __WIN32_ERR(GetLastError());
-	RETURN (nil);
+            do {
+                __threadErrno = 0;
+                rslt = STX_API_NOINT_CALL3( "GetLongPathNameA", GetLongPathNameA, nameBuffer, nameBuffer2, MAXPATHLEN);
+            } while ((rslt < 0) && (__threadErrno == EINTR));
+#else
+            rslt = GetLongPathNameA(nameBuffer, nameBuffer2, MAXPATHLEN);
+#endif
+            returnedName = nameBuffer2;
+        }
+        if (rslt > 0) {
+            RETURN ( __MKSTRING(returnedName) );
+        }
+        __threadErrno = __WIN32_ERR(GetLastError());
+        RETURN (nil);
     }
     if (__isUnicode16String(aPathName)) {
-	wchar_t nameBuffer[MAXPATHLEN + 1];
-	wchar_t nameBuffer2[MAXPATHLEN + 1];
-	wchar_t *returnedName = NULL;
-	int rslt;
-	wchar_t _aPathName[MAXPATHLEN+1];
-	int i, l;
-
-	l = __unicode16StringSize(aPathName);
-	if (l > MAXPATHLEN) l = MAXPATHLEN;
-	for (i=0; i<l; i++) {
-	    _aPathName[i] = __unicode16StringVal(aPathName)[i];
-	}
-	_aPathName[i] = 0;
+        wchar_t nameBuffer[MAXPATHLEN + 1];
+        wchar_t nameBuffer2[MAXPATHLEN + 1];
+        wchar_t *returnedName = NULL;
+        int rslt;
+        wchar_t _aPathName[MAXPATHLEN+1];
+        int i, l;
+
+        l = __unicode16StringSize(aPathName);
+        if (l > MAXPATHLEN) l = MAXPATHLEN;
+        for (i=0; i<l; i++) {
+            _aPathName[i] = __unicode16StringVal(aPathName)[i];
+        }
+        _aPathName[i] = 0;
 
 #ifdef DO_WRAP_CALLS
-	do {
-	    __threadErrno = 0;
-	    rslt = STX_API_NOINT_CALL4( "GetFullPathNameW", GetFullPathNameW, _aPathName, MAXPATHLEN, nameBuffer, NULL);
-	} while ((rslt < 0) && (__threadErrno == EINTR));
-#else
-	rslt = GetFullPathNameW(_aPathName, MAXPATHLEN, nameBuffer, NULL);
-#endif
-	returnedName = nameBuffer;
-
-	if (rslt > 0) {
-	    /*
-	     * Attention: GetLongPathName is not available on old NT4.0/W95/W98
-	     */
-	    static FARPROC GetLongPathNameW_entry = NULL;
-#ifdef NO_NT4_0_COMPATIBILITY
-	    GetLongPathNameW_entry = (FARPROC) GetLongPathNameW;
-#else
-	    if (GetLongPathNameW_entry == NULL) {
-		GetLongPathNameW_entry = __get_kernel32_functionAddress("GetLongPathNameW");
-	    }
-#endif /* NO_NT4_0_COMPATIBILITY */
-
-	    if (GetLongPathNameW_entry) {
+        do {
+            __threadErrno = 0;
+            rslt = STX_API_NOINT_CALL4( "GetFullPathNameW", GetFullPathNameW, _aPathName, MAXPATHLEN, nameBuffer, NULL);
+        } while ((rslt < 0) && (__threadErrno == EINTR));
+#else
+        rslt = GetFullPathNameW(_aPathName, MAXPATHLEN, nameBuffer, NULL);
+#endif
+        returnedName = nameBuffer;
+
+        if (rslt > 0) {
 #ifdef DO_WRAP_CALLS
-		do {
-		    __threadErrno = 0;
-		    rslt = STX_API_NOINT_CALL3( "GetLongPathNameW", GetLongPathNameW_entry, nameBuffer, nameBuffer2, MAXPATHLEN);
-		} while ((rslt < 0) && (__threadErrno == EINTR));
-#else
-		rslt = (*GetLongPathNameW_entry)(nameBuffer, nameBuffer2, MAXPATHLEN);
-#endif
-		returnedName = nameBuffer2;
-	    }
-	}
-	if (rslt > 0) {
-	    RETURN ( __MKU16STRING(returnedName) );
-	}
-	__threadErrno = __WIN32_ERR(GetLastError());
-    }
-%}.
+            do {
+                __threadErrno = 0;
+                rslt = STX_API_NOINT_CALL3( "GetLongPathNameW", GetLongPathNameW, nameBuffer, nameBuffer2, MAXPATHLEN);
+            } while ((rslt < 0) && (__threadErrno == EINTR));
+#else
+            rslt = GetLongPathNameW(nameBuffer, nameBuffer2, MAXPATHLEN);
+#endif
+            returnedName = nameBuffer2;
+        }
+        if (rslt > 0) {
+            RETURN ( __MKU16STRING(returnedName) );
+        }
+        __threadErrno = __WIN32_ERR(GetLastError());
+    }
+    error = @symbol(argument);     // argument is not a string or unicode16string
+%}.
+    error notNil ifTrue:[
+        self primitiveFailed:error.
+    ].
     ^ nil
 
     "
      self primPathNameOf:'.'
      self primPathNameOf:'.' asUnicode16String
+     self primPathNameOf:5555
     "
 !
 
@@ -7822,8 +7776,8 @@
 
 getNetworkMACAddresses
     "return a dictionary filled with
-	key -> name of interface
-	value -> the MAC adress (as ByteArray)
+        key -> name of interface
+        value -> the MAC adress (as ByteArray)
      for each interface
     "
 
@@ -7832,7 +7786,6 @@
 
     rawData := Array new:50.
 %{
-#ifndef NO_GETADAPTERSINFO
 /*
  * temporary undef String to avoid a #define-conflict
  * between ST/X's String and Windows String typedef
@@ -7843,36 +7796,23 @@
     IP_ADAPTER_INFO AdapterInfo[32];
     DWORD dwBufLen = sizeof(AdapterInfo);
     DWORD dwStatus;
-    static FARPROC GetAdaptersInfo_entry = NULL;
-
-    /*
-     * Attention: GetAdaptersInfo is not available on old NT4.0/W95/W98
-     */
-#ifdef NO_NT4_0_COMPATIBILITY
-    GetAdaptersInfo_entry = (FARPROC) GetAdaptersInfo;
-#else
-    if (GetAdaptersInfo_entry == NULL) {
-	GetAdaptersInfo_entry = __get_iphlpapi_functionAddress("GetAdaptersInfo");
-    }
-#endif /* NO_NT4_0_COMPATIBILITY */
-
-    if (GetAdaptersInfo_entry) {
-	dwStatus = (*GetAdaptersInfo_entry)(
-				AdapterInfo,                 // [out] buffer to receive data
-				&dwBufLen);                  // [in] size of receive data buffer
-	if (dwStatus == ERROR_SUCCESS) {
-	    PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;
-	    unsigned char *bP;
-	    int nA = 0;
-
-	    bP = __byteArrayVal(rawData);
-	    do {
-		name = __MKSTRING(pAdapterInfo->AdapterName);
-		description = __MKSTRING(pAdapterInfo->Description);
-		macAddress = __MKBYTEARRAY(pAdapterInfo->Address, 6);
-		ipAddress = __MKSTRING(pAdapterInfo->IpAddressList.IpAddress.String);
-		ipAddressMask = __MKSTRING(pAdapterInfo->IpAddressList.IpMask.String);
-		entry = __ARRAY_NEW_INT(5);
+
+    dwStatus = GetAdaptersInfo(
+                            AdapterInfo,                 // [out] buffer to receive data
+                            &dwBufLen);                  // [in] size of receive data buffer
+    if (dwStatus == ERROR_SUCCESS) {
+        PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;
+        unsigned char *bP;
+        int nA = 0;
+
+        bP = __byteArrayVal(rawData);
+        do {
+            name = __MKSTRING(pAdapterInfo->AdapterName);
+            description = __MKSTRING(pAdapterInfo->Description);
+            macAddress = __MKBYTEARRAY(pAdapterInfo->Address, 6);
+            ipAddress = __MKSTRING(pAdapterInfo->IpAddressList.IpAddress.String);
+            ipAddressMask = __MKSTRING(pAdapterInfo->IpAddressList.IpMask.String);
+            entry = __ARRAY_NEW_INT(5);
 /*
  * back to ST/X's String definition
  */
@@ -7882,33 +7822,32 @@
 # ifdef __DEF_String
 #  define Context __DEF_Context
 # endif
-		__ArrayInstPtr(entry)->a_element[0] = name; __STORE(entry, name);
-		__ArrayInstPtr(entry)->a_element[1] = description; __STORE(entry, description);
-		__ArrayInstPtr(entry)->a_element[2] = macAddress; __STORE(entry, macAddress);
-		__ArrayInstPtr(entry)->a_element[3] = ipAddress; __STORE(entry, ipAddress);
-		__ArrayInstPtr(entry)->a_element[4] = ipAddressMask; __STORE(entry, ipAddressMask);
-
-		__ArrayInstPtr(rawData)->a_element[nA] = entry; __STORE(rawData, entry);
-		nA++;
-		pAdapterInfo = pAdapterInfo->Next;
-	    } while(pAdapterInfo);
-	    nAdapters = __mkSmallInteger(nA);
-	}
-    }
-#endif /* NO_GETADAPTERSINFO */
-%}.
-    info := Dictionary new.
+            __ArrayInstPtr(entry)->a_element[0] = name; __STORE(entry, name);
+            __ArrayInstPtr(entry)->a_element[1] = description; __STORE(entry, description);
+            __ArrayInstPtr(entry)->a_element[2] = macAddress; __STORE(entry, macAddress);
+            __ArrayInstPtr(entry)->a_element[3] = ipAddress; __STORE(entry, ipAddress);
+            __ArrayInstPtr(entry)->a_element[4] = ipAddressMask; __STORE(entry, ipAddressMask);
+
+            __ArrayInstPtr(rawData)->a_element[nA] = entry; __STORE(rawData, entry);
+            nA++;
+            pAdapterInfo = pAdapterInfo->Next;
+        } while(pAdapterInfo);
+        nAdapters = __mkSmallInteger(nA);
+    }
+%}.
+    "Keep the order as reurned by the OS"
+    info := OrderedDictionary new:nAdapters.
     nAdapters notNil ifTrue:[
-	1 to:nAdapters do:[:i |
-	    |entry name description macAddr ipAddr|
-
-	    entry := rawData at:i.
-	    name := entry at:1.
-	    "/ description := entry at:2.
-	    macAddr := entry at:3.
-	    "/ ipAddr := entry at:4.
-	    info at:name put:macAddr.
-	].
+        1 to:nAdapters do:[:i |
+            |entry name description macAddr ipAddr|
+
+            entry := rawData at:i.
+            name := entry at:1.
+            "/ description := entry at:2.
+            macAddr := entry at:3.
+            "/ ipAddr := entry at:4.
+            info at:name put:macAddr.
+        ].
     ].
     ^ info
 
@@ -12256,157 +12195,157 @@
 
     //iterate all following objetcs
     for (objectIterator=0; objectIterator<numObjectTypes; objectIterator++) {
-	//add the st_perObject dictionary to st_objectArray
-	st_perObject = __SSEND0(@global(Dictionary), @symbol(new), 0);
-	__AT_PUT_(st_objectArray, __mkSmallInteger(objectIterator+1), st_perObject);
-
-	//get the object data
-	__AT_PUT_(st_perObject, @symbol(ObjectNameTitleIndex), __mkSmallInteger(perfObjectPtr->ObjectNameTitleIndex));
-	__AT_PUT_(st_perObject, @symbol(DetailLevel), __mkSmallInteger(perfObjectPtr->DetailLevel));
-	__AT_PUT_(st_perObject, @symbol(NumCounters), __mkSmallInteger(perfObjectPtr->NumCounters));
-	__AT_PUT_(st_perObject, @symbol(NumInstances), __mkSmallInteger(perfObjectPtr->NumInstances));
-
-	//setup counter array and initialize its pointer
-	st_counterArray = __ARRAY_NEW_INT(perfObjectPtr->NumCounters);
-	perfCounterPtr = (PERF_COUNTER_DEFINITION *)((char *)perfObjectPtr + perfObjectPtr->HeaderLength);
-
-	//add the st_counterArray to st_perObject dictionary
-	__AT_PUT_(st_perObject, @symbol(Counters), st_counterArray);
-
-	//iterate all following counter definition
-	for (counterIterator=0; counterIterator<perfObjectPtr->NumCounters; counterIterator++) {
-	    //add the st_perCounter dictionary to st_counterArray
-	    st_perCounter = __SSEND0(@global(Dictionary), @symbol(new), 0);
-	    __AT_PUT_(st_counterArray, __mkSmallInteger(counterIterator+1), st_perCounter);
-
-	    //get the counter data
-	    __AT_PUT_(st_perCounter, @symbol(CounterNameTitleIndex), __mkSmallInteger(perfCounterPtr->CounterNameTitleIndex));
-	    __AT_PUT_(st_perCounter, @symbol(CounterTypeBits), __mkSmallInteger(perfCounterPtr->CounterType));
-	    __AT_PUT_(st_perCounter, @symbol(CounterSize), __mkSmallInteger(perfCounterPtr->CounterSize));
-	    __AT_PUT_(st_perCounter, @symbol(CounterOffset), __mkSmallInteger(perfCounterPtr->CounterOffset));
-
-	    //put the counter type size
-	    switch (perfCounterPtr->CounterType & PERF_SIZE_MASK) {
-		case PERF_SIZE_DWORD:
-		    __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(DWORD));
-		    break;
-		case PERF_SIZE_LARGE:
-		    __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(LARGE));
-		    break;
-		case PERF_SIZE_ZERO:
-		    __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(ZERO));
-		    break;
-		case PERF_SIZE_VARIABLE_LEN:
-		    __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(VARIABLE_LEN));
-		    break;
-	    }
-	    switch (perfCounterPtr->CounterType & PERF_TYPE_MASK) {
-		case PERF_TYPE_NUMBER:
-		    __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(NUMBER));
-		    switch (perfCounterPtr->CounterType & PERF_NUMBERTYPE_MASK) {
-			case PERF_NUMBER_HEX:
-			    __AT_PUT_(st_perCounter, @symbol(NUMBER),@symbol(HEX));
-			    break;
-			case PERF_NUMBER_DECIMAL:
-			    __AT_PUT_(st_perCounter, @symbol(NUMBER),@symbol(DECIMAL));
-			    break;
-			case PERF_NUMBER_DEC_1000:
-			    __AT_PUT_(st_perCounter, @symbol(NUMBER),@symbol(DEC_1000));
-			    break;
-		    }
-		    break;
-		case PERF_TYPE_COUNTER:
-		    __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(COUNTER));
-		    switch (perfCounterPtr->CounterType & PERF_COUNTERTYPE_MASK) {
-			case PERF_COUNTER_VALUE:
-			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(VALUE));
-			    break;
-			case PERF_COUNTER_RATE:
-			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(RATE));
-			    break;
-			case PERF_COUNTER_FRACTION:
-			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(FRACTION));
-			    break;
-			case PERF_COUNTER_BASE:
-			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(BASE));
-			    break;
-			case PERF_COUNTER_ELAPSED:
-			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(ELAPSED));
-			    break;
-			case PERF_COUNTER_QUEUELEN:
-			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(QUEUELEN));
-			    break;
-			case PERF_COUNTER_HISTOGRAM:
-			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(HISTOGRAM));
-			    break;
+        //add the st_perObject dictionary to st_objectArray
+        st_perObject = __SSEND0(@global(Dictionary), @symbol(new), 0);
+        __AT_PUT_(st_objectArray, __mkSmallInteger(objectIterator+1), st_perObject);
+
+        //get the object data
+        __AT_PUT_(st_perObject, @symbol(ObjectNameTitleIndex), __mkSmallInteger(perfObjectPtr->ObjectNameTitleIndex));
+        __AT_PUT_(st_perObject, @symbol(DetailLevel), __mkSmallInteger(perfObjectPtr->DetailLevel));
+        __AT_PUT_(st_perObject, @symbol(NumCounters), __mkSmallInteger(perfObjectPtr->NumCounters));
+        __AT_PUT_(st_perObject, @symbol(NumInstances), __mkSmallInteger(perfObjectPtr->NumInstances));
+
+        //setup counter array and initialize its pointer
+        st_counterArray = __ARRAY_NEW_INT(perfObjectPtr->NumCounters);
+        perfCounterPtr = (PERF_COUNTER_DEFINITION *)((char *)perfObjectPtr + perfObjectPtr->HeaderLength);
+
+        //add the st_counterArray to st_perObject dictionary
+        __AT_PUT_(st_perObject, @symbol(Counters), st_counterArray);
+
+        //iterate all following counter definition
+        for (counterIterator=0; counterIterator<perfObjectPtr->NumCounters; counterIterator++) {
+            //add the st_perCounter dictionary to st_counterArray
+            st_perCounter = __SSEND0(@global(Dictionary), @symbol(new), 0);
+            __AT_PUT_(st_counterArray, __mkSmallInteger(counterIterator+1), st_perCounter);
+
+            //get the counter data
+            __AT_PUT_(st_perCounter, @symbol(CounterNameTitleIndex), __mkSmallInteger(perfCounterPtr->CounterNameTitleIndex));
+            __AT_PUT_(st_perCounter, @symbol(CounterTypeBits), __mkSmallInteger(perfCounterPtr->CounterType));
+            __AT_PUT_(st_perCounter, @symbol(CounterSize), __mkSmallInteger(perfCounterPtr->CounterSize));
+            __AT_PUT_(st_perCounter, @symbol(CounterOffset), __mkSmallInteger(perfCounterPtr->CounterOffset));
+
+            //put the counter type size
+            switch (perfCounterPtr->CounterType & PERF_SIZE_MASK) {
+                case PERF_SIZE_DWORD:
+                    __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(DWORD));
+                    break;
+                case PERF_SIZE_LARGE:
+                    __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(LARGE));
+                    break;
+                case PERF_SIZE_ZERO:
+                    __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(ZERO));
+                    break;
+                case PERF_SIZE_VARIABLE_LEN:
+                    __AT_PUT_(st_perCounter, @symbol(SIZE),@symbol(VARIABLE_LEN));
+                    break;
+            }
+            switch (perfCounterPtr->CounterType & PERF_TYPE_MASK) {
+                case PERF_TYPE_NUMBER:
+                    __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(NUMBER));
+                    switch (perfCounterPtr->CounterType & PERF_NUMBERTYPE_MASK) {
+                        case PERF_NUMBER_HEX:
+                            __AT_PUT_(st_perCounter, @symbol(NUMBER),@symbol(HEX));
+                            break;
+                        case PERF_NUMBER_DECIMAL:
+                            __AT_PUT_(st_perCounter, @symbol(NUMBER),@symbol(DECIMAL));
+                            break;
+                        case PERF_NUMBER_DEC_1000:
+                            __AT_PUT_(st_perCounter, @symbol(NUMBER),@symbol(DEC_1000));
+                            break;
+                    }
+                    break;
+                case PERF_TYPE_COUNTER:
+                    __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(COUNTER));
+                    switch (perfCounterPtr->CounterType & PERF_COUNTERTYPE_MASK) {
+                        case PERF_COUNTER_VALUE:
+                            __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(VALUE));
+                            break;
+                        case PERF_COUNTER_RATE:
+                            __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(RATE));
+                            break;
+                        case PERF_COUNTER_FRACTION:
+                            __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(FRACTION));
+                            break;
+                        case PERF_COUNTER_BASE:
+                            __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(BASE));
+                            break;
+                        case PERF_COUNTER_ELAPSED:
+                            __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(ELAPSED));
+                            break;
+                        case PERF_COUNTER_QUEUELEN:
+                            __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(QUEUELEN));
+                            break;
+                        case PERF_COUNTER_HISTOGRAM:
+                            __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(HISTOGRAM));
+                            break;
 #ifdef PERF_COUNTER_PRECISION
-			case PERF_COUNTER_PRECISION:
-			    __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(PRECISION));
-			    break;
-#endif
-		    }
-		    break;
-		case PERF_TYPE_TEXT:
-		    __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(TEXT));
-		    switch (perfCounterPtr->CounterType & PERF_TEXTTYPE_MASK) {
-			case PERF_TEXT_UNICODE:
-			    __AT_PUT_(st_perCounter, @symbol(TEXT),@symbol(UNICODE));
-			    break;
-			case PERF_TEXT_ASCII:
-			    __AT_PUT_(st_perCounter, @symbol(TEXT),@symbol(ASCII));
-			    break;
-		    }
-		    break;
-		case PERF_TYPE_ZERO:
-		    __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(ZERO));
-		    break;
-	    }
-
-	    //setup the counter pointer to the next counter definition
-	    perfCounterPtr = (PERF_COUNTER_DEFINITION *)((char *)perfCounterPtr + perfCounterPtr->ByteLength);
-	}
-
-	//goon dependent on the count of instances
-	if (perfObjectPtr->NumInstances < 1) {
-	    perfCounterBlockPtr = (PERF_COUNTER_BLOCK *)(perfCounterPtr);
-	    __AT_PUT_(st_perObject, @symbol(RawData), __MKBYTEARRAY(perfCounterBlockPtr, perfCounterBlockPtr->ByteLength));
-	} else {
-	    //setup the instance pointer to the end of all counters
-	    perfInstancePtr = (PERF_INSTANCE_DEFINITION *)(perfCounterPtr);
-
-	    //setup st_instanceArray and add it to st_perObject
-	    st_instanceArray = __ARRAY_NEW_INT(perfObjectPtr->NumInstances);
-	    __AT_PUT_(st_perObject, @symbol(Instances), st_instanceArray);
-
-	    //iterate the instances
-	    for (instanceIterator=0; instanceIterator<perfObjectPtr->NumInstances; instanceIterator++) {
-		//setup st_perInstance and add it to st_instanceArray
-		st_perInstance = __SSEND0(@global(Dictionary), @symbol(new), 0);
-		__AT_PUT_(st_instanceArray, __mkSmallInteger(instanceIterator+1), st_perInstance);
-
-		//get the instance data
-		__AT_PUT_(st_perInstance, @symbol(Name), __MKBYTEARRAY((wchar_t *)((BYTE *)perfInstancePtr + perfInstancePtr->NameOffset),perfInstancePtr->NameLength));
-		__AT_PUT_(st_perInstance, @symbol(ParentObjectTitleIndex), __mkSmallInteger(perfInstancePtr->ParentObjectTitleIndex));
-		__AT_PUT_(st_perInstance, @symbol(ParentObjectInstance), __mkSmallInteger(perfInstancePtr->ParentObjectInstance));
-		__AT_PUT_(st_perInstance, @symbol(NameOffset), __mkSmallInteger(perfInstancePtr->NameOffset));
-		__AT_PUT_(st_perInstance, @symbol(NameLength), __mkSmallInteger(perfInstancePtr->NameLength));
-
-		//setup the instance pointer to the its end
-		perfInstancePtr = (PERF_INSTANCE_DEFINITION *)((char *)perfInstancePtr + perfInstancePtr->ByteLength);
-
-		//setup the counter block pointer
-		perfCounterBlockPtr = (PERF_COUNTER_BLOCK *)(perfInstancePtr);
-
-		//get the instance raw data
-		__AT_PUT_(st_perInstance, @symbol(RawData), __MKBYTEARRAY(perfCounterBlockPtr, perfCounterBlockPtr->ByteLength));
-
-		//setup the instance pointer to the next instance
-		perfInstancePtr = (PERF_INSTANCE_DEFINITION *)((char *)perfCounterBlockPtr + perfCounterBlockPtr->ByteLength);
-	    }
-	}
-
-	//setup the object pointer to the next object
-	perfObjectPtr = (PERF_OBJECT_TYPE *)((char *)perfObjectPtr + perfObjectPtr->TotalByteLength);
+                        case PERF_COUNTER_PRECISION:
+                            __AT_PUT_(st_perCounter, @symbol(COUNTER),@symbol(PRECISION));
+                            break;
+#endif
+                    }
+                    break;
+                case PERF_TYPE_TEXT:
+                    __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(TEXT));
+                    switch (perfCounterPtr->CounterType & PERF_TEXTTYPE_MASK) {
+                        case PERF_TEXT_UNICODE:
+                            __AT_PUT_(st_perCounter, @symbol(TEXT),@symbol(UNICODE));
+                            break;
+                        case PERF_TEXT_ASCII:
+                            __AT_PUT_(st_perCounter, @symbol(TEXT),@symbol(ASCII));
+                            break;
+                    }
+                    break;
+                case PERF_TYPE_ZERO:
+                    __AT_PUT_(st_perCounter, @symbol(TYPE),@symbol(ZERO));
+                    break;
+            }
+
+            //setup the counter pointer to the next counter definition
+            perfCounterPtr = (PERF_COUNTER_DEFINITION *)((char *)perfCounterPtr + perfCounterPtr->ByteLength);
+        }
+
+        //goon dependent on the count of instances
+        if (perfObjectPtr->NumInstances < 1) {
+            perfCounterBlockPtr = (PERF_COUNTER_BLOCK *)(perfCounterPtr);
+            __AT_PUT_(st_perObject, @symbol(RawData), __MKBYTEARRAY(perfCounterBlockPtr, perfCounterBlockPtr->ByteLength));
+        } else {
+            //setup the instance pointer to the end of all counters
+            perfInstancePtr = (PERF_INSTANCE_DEFINITION *)(perfCounterPtr);
+
+            //setup st_instanceArray and add it to st_perObject
+            st_instanceArray = __ARRAY_NEW_INT(perfObjectPtr->NumInstances);
+            __AT_PUT_(st_perObject, @symbol(Instances), st_instanceArray);
+
+            //iterate the instances
+            for (instanceIterator=0; instanceIterator<perfObjectPtr->NumInstances; instanceIterator++) {
+                //setup st_perInstance and add it to st_instanceArray
+                st_perInstance = __SSEND0(@global(Dictionary), @symbol(new), 0);
+                __AT_PUT_(st_instanceArray, __mkSmallInteger(instanceIterator+1), st_perInstance);
+
+                //get the instance data
+                __AT_PUT_(st_perInstance, @symbol(Name), __MKBYTEARRAY((wchar_t *)((BYTE *)perfInstancePtr + perfInstancePtr->NameOffset),perfInstancePtr->NameLength));
+                __AT_PUT_(st_perInstance, @symbol(ParentObjectTitleIndex), __mkSmallInteger(perfInstancePtr->ParentObjectTitleIndex));
+                __AT_PUT_(st_perInstance, @symbol(ParentObjectInstance), __mkSmallInteger(perfInstancePtr->ParentObjectInstance));
+                __AT_PUT_(st_perInstance, @symbol(NameOffset), __mkSmallInteger(perfInstancePtr->NameOffset));
+                __AT_PUT_(st_perInstance, @symbol(NameLength), __mkSmallInteger(perfInstancePtr->NameLength));
+
+                //setup the instance pointer to the its end
+                perfInstancePtr = (PERF_INSTANCE_DEFINITION *)((char *)perfInstancePtr + perfInstancePtr->ByteLength);
+
+                //setup the counter block pointer
+                perfCounterBlockPtr = (PERF_COUNTER_BLOCK *)(perfInstancePtr);
+
+                //get the instance raw data
+                __AT_PUT_(st_perInstance, @symbol(RawData), __MKBYTEARRAY(perfCounterBlockPtr, perfCounterBlockPtr->ByteLength));
+
+                //setup the instance pointer to the next instance
+                perfInstancePtr = (PERF_INSTANCE_DEFINITION *)((char *)perfCounterBlockPtr + perfCounterBlockPtr->ByteLength);
+            }
+        }
+
+        //setup the object pointer to the next object
+        perfObjectPtr = (PERF_OBJECT_TYPE *)((char *)perfObjectPtr + perfObjectPtr->TotalByteLength);
     }
 %}.
     objectArray := st_objectArray.
@@ -12415,61 +12354,61 @@
     perfTime100nSec := st_perfTime100nSec.
 
     getNameBlock := [:i|
-	self class counterIndexTextDictionary at:i ifAbsent:['<<no name>>'].
+        self class counterIndexTextDictionary at:i ifAbsent:['<<no name>>'].
     ].
 
     getCounterValueBlock := [:counter :rawData|
-	|offset counterValue|
-
-	offset := counter at:#CounterOffset.
-	offset >= rawData size ifTrue:[
-	    counterValue := nil.
-	] ifFalse:[
-	    (counter at:#SIZE) == #LARGE ifTrue:[
-		counterValue := rawData unsignedLongLongAt:offset + 1 bigEndian:false.
-	    ] ifFalse:[
-		(counter at:#SIZE) == #DWORD ifTrue:[
-		    counterValue := rawData unsignedLongAt:offset + 1 bigEndian:false.
-		] ifFalse:[
-		    self halt.
-		].
-	    ].
-	].
-
-	counterValue
+        |offset counterValue|
+
+        offset := counter at:#CounterOffset.
+        offset >= rawData size ifTrue:[
+            counterValue := nil.
+        ] ifFalse:[
+            (counter at:#SIZE) == #LARGE ifTrue:[
+                counterValue := rawData unsignedLongLongAt:offset + 1 bigEndian:false.
+            ] ifFalse:[
+                (counter at:#SIZE) == #DWORD ifTrue:[
+                    counterValue := rawData unsignedLongAt:offset + 1 bigEndian:false.
+                ] ifFalse:[
+                    self halt.
+                ].
+            ].
+        ].
+
+        counterValue
     ].
 
     objectArray do:[:anObject|
-	"setup the object name"
-	anObject at:#ObjectNameTitle put:(getNameBlock value:(anObject at:#ObjectNameTitleIndex)).
-
-	"setup the name and a counter value array to each counter"
-	(anObject at:#Counters) do:[:aCounter|
-	    aCounter at:#CounterNameTitle put:(getNameBlock value:(aCounter at:#CounterNameTitleIndex)).
-	    aCounter at:#CounterValueArray put:OrderedCollection new.
-	].
-
-	(anObject at:#NumInstances) < 1 ifTrue:[
-	    |rawData|
-
-	    rawData := anObject at:#RawData.
-
-	    (anObject at:#Counters) do:[:aCounter|
-		(aCounter at:#CounterValueArray) add:(getCounterValueBlock value:aCounter value:rawData).
-	    ].
-	] ifFalse:[
-	    (anObject at:#Instances) do:[:anInstance|
-		|rawData|
-
-		rawData := anInstance at:#RawData.
-
-		anInstance at:#Name put:((Unicode16String fromBytes:(anInstance at:#Name) copy swapBytes) copyWithoutLast:1).
-
-		(anObject at:#Counters) do:[:aCounter|
-		    (aCounter at:#CounterValueArray) add:(getCounterValueBlock value:aCounter value:rawData).
-		].
-	    ].
-	].
+        "setup the object name"
+        anObject at:#ObjectNameTitle put:(getNameBlock value:(anObject at:#ObjectNameTitleIndex)).
+
+        "setup the name and a counter value array to each counter"
+        (anObject at:#Counters) do:[:aCounter|
+            aCounter at:#CounterNameTitle put:(getNameBlock value:(aCounter at:#CounterNameTitleIndex)).
+            aCounter at:#CounterValueArray put:OrderedCollection new.
+        ].
+
+        (anObject at:#NumInstances) < 1 ifTrue:[
+            |rawData|
+
+            rawData := anObject at:#RawData.
+
+            (anObject at:#Counters) do:[:aCounter|
+                (aCounter at:#CounterValueArray) add:(getCounterValueBlock value:aCounter value:rawData).
+            ].
+        ] ifFalse:[
+            (anObject at:#Instances) do:[:anInstance|
+                |rawData|
+
+                rawData := anInstance at:#RawData.
+
+                anInstance at:#Name put:((Unicode16String fromBytes:(anInstance at:#Name) copy swapBytes) copyButLast:1).
+
+                (anObject at:#Counters) do:[:aCounter|
+                    (aCounter at:#CounterValueArray) add:(getCounterValueBlock value:aCounter value:rawData).
+                ].
+            ].
+        ].
     ].
 
     ^ self
@@ -17166,11 +17105,11 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.459 2013-04-10 08:04:37 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.460 2013-04-25 14:11:57 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.459 2013-04-10 08:04:37 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.460 2013-04-25 14:11:57 stefan Exp $'
 !
 
 version_SVN