-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinrttests.msr
200 lines (163 loc) · 4.74 KB
/
winrttests.msr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
var time = sys.time();
print "startup";
import("rt/Windows.Foundation");
import("rt/Windows.Foundation.Collections");
import("rt/Windows.Storage");
import("rt/Windows.Storage.Streams");
import("rt/Windows.Web.Http");
import("rt/Windows.Security.Cryptography");
import("rt/Windows.Security.Cryptography.Core");
import("rt/Windows.Security.Cryptography.Certificates");
import("rt/Windows.System.Threading");
import("promise");
import("winrt");
print "runtime loaded " + (sys.time()-time);
extern from "User32.dll" {
long DefWindowProcA( ptr, uint, ptr, ptr) as DefWindowProc;
ushort RegisterClassA( ptr ) as RegisterClass;
ptr CreateWindowExA( int, str, str, int, int ,int, int, int,ptr,ptr,ptr,ptr) as CreateWindowEx;
int ShowWindow( ptr, int);
int GetMessageA( ptr, ptr, uint, uint ) as GetMessage;
int TranslateMessage( ptr );
long DispatchMessageA( ptr ) as DispatchMessage;
void PostQuitMessage(int);
ptr BeginPaint( ptr, ptr );
int EndPaint( ptr, ptr );
int DrawTextA( ptr, str, int, ptr, uint) as DrawText;
ptr CreateMenu();
ptr CreatePopupMenu();
int AppendMenuA( ptr, uint, ptr, str) as AppendMenu;
int SetMenu( ptr, ptr);
}
extern struct POINT {
int x,
int y
}
extern struct MSG {
ptr hwnd,
uint message,
ptr wParam,
ptr lParam,
int time,
POINT pt,
int lPrivate
}
print "start call " + (sys.time()-time);
Windows.Storage.StorageFile
.GetFileFromPathAsync( "C:\\Windows\\win.ini")
.then( fun( file )
{
print "async1 " + (sys.time()-time);
print file;
Windows.Storage.FileIO
.ReadTextAsync( file )
.then( fun( content)
{
print "async2 " + (sys.time()-time);
print content;
var httpClient = Windows.Web.Http.HttpClient.Create();
print httpClient;
print httpClient.comPtr;
var requestUri = Windows.Foundation.Uri.CreateUri("http://www.amazon.de/");
print requestUri;
print requestUri.comPtr;
var p = httpClient.GetStringAsync(requestUri);
print p;
p.then( fun(content)
{
print content;
PostQuitMessage(0);
})
.otherwise(fun(status)
{
print "E: " + status;
});
});
});
/*
Windows.Storage.StorageFile
.GetFileFromPathAsync( "C:\\Log Files\\moc.txt", /*Windows.Storage.CreationCollisionOption.ReplaceExisting,* / fun(status, file)
{
print "file: " + file;
print status;
Windows.Storage.FileIO.WriteTextAsync( file, "some text from moc\r\n", fun( status)
{
print "writeasync2 " + (sys.time()-time);
print status;
Windows.Storage.StorageFolder
.GetFolderFromPathAsync("C:\\Log Files", fun(status,folder)
{
print "writeasync3 " + (sys.time()-time);
print status;
folder.CreateFileAsync( "moc.txt", Windows.Storage.CreationCollisionOption.OpenIfExists, fun(status,file)
{
Windows.Storage.FileIO.WriteTextAsync( file, "some more text from moc\r\n", fun( status)
{
print "done done";
});
});
});
});
});
*/
/*
var strAlgName = Windows.Security.Cryptography.Core.HashAlgorithmNames.get_Md5();
var enc = Windows.Security.Cryptography.BinaryStringEncoding.Utf8;
var buffUtf8Msg = Windows.Security.Cryptography.CryptographicBuffer.ConvertStringToBinary("HELLO WORLD\r\n", enc);
var objAlgProv = Windows.Security.Cryptography.Core.HashAlgorithmProvider.OpenAlgorithm(strAlgName);
var strAlgNameUsed = objAlgProv.get_AlgorithmName();
var buffHash = objAlgProv.HashData(buffUtf8Msg);
print buffHash.get_Length();
if (buffHash.get_Length() != objAlgProv.get_HashLength())
{
print "e";
throw "There was an error creating the hash";
}
var hex = Windows.Security.Cryptography.CryptographicBuffer.EncodeToHexString(buffHash);
print hex;
*/
/*
var store = Windows.Security.Cryptography.Certificates.CertificateStores.get_TrustedRootCertificationAuthorities();
var query = Windows.Security.Cryptography.Certificates.CertificateQuery.Create();
print query;
query.put_StoreName(store.get_Name());
Windows.Security.Cryptography.Certificates.CertificateStores.FindAllWithQueryAsync( query, fun(status, certs)
{
print status;
print certs;
var len = certs.get_Size();
print len;
for(var i = 0; i < len; i++)
{
var cert = certs.GetAt(i);
print cert;
print cert.get_StoreName();
print cert.get_FriendlyName();
print cert.get_Subject();
//print cert.get_SubjectAlternativeName();
}
//PostQuitMessage(0);
});
*/
var timespan = Windows.Foundation.TimeSpan();
timespan.Duration = 5 * 10000000;
print timespan;
fun f()
{
print "callback!";
//PostQuitMessage(0);
}
var cb = Windows.System.Threading.TimerElapsedHandler.Create( f);
print cb;
var timer = Windows.System.Threading.ThreadPoolTimer.CreateTimer(
f,
5 * 10000000 //timespan
);
print "start msg loop" + (sys.time()-time);
var msg = MSG();
while (GetMessage(msg, 0, 0, 0))
{
TranslateMessage(msg);
DispatchMessage(msg);
}
print "done" + (sys.time()-time);