-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathqubes-gui-agent-windows-mingw-fragments.patch
3848 lines (3693 loc) · 129 KB
/
qubes-gui-agent-windows-mingw-fragments.patch
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff -pruN a/gui-agent/main.c b/gui-agent/main.c
--- a/gui-agent/main.c 2018-07-11 19:29:59.000000000 +0300
+++ b/gui-agent/main.c 2020-01-17 13:56:26.899126801 +0300
@@ -72,7 +72,7 @@ HWND g_DesktopWindow = NULL;
HANDLE g_ShutdownEvent = NULL;
-ULONG ProcessUpdatedWindows(IN HDC screenDC);
+static ULONG ProcessUpdatedWindows(IN HDC screenDC);
#ifdef DEBUG
// diagnostic: dump all watched windows
@@ -199,19 +199,19 @@ ULONG AddWindowWithInfo(IN HWND window,
{
status = SendWindowCreate(entry);
if (ERROR_SUCCESS != status)
- return perror2(status, "SendWindowCreate");
+ return win_perror2(status, "SendWindowCreate");
// map (show) the window if it's visible and not minimized
if (!entry->IsIconic)
{
status = SendWindowMap(entry);
if (ERROR_SUCCESS != status)
- return perror2(status, "SendWindowMap");
+ return win_perror2(status, "SendWindowMap");
}
status = SendWindowName(window, entry->Caption);
if (ERROR_SUCCESS != status)
- return perror2(status, "SendWindowName");
+ return win_perror2(status, "SendWindowName");
}
if (windowEntry)
@@ -236,13 +236,13 @@ ULONG RemoveWindow(IN OUT WINDOW_DATA *e
{
status = SendWindowUnmap(entry->WindowHandle);
if (ERROR_SUCCESS != status)
- return perror2(status, "SendWindowUnmap");
+ return win_perror2(status, "SendWindowUnmap");
if (entry->WindowHandle) // never destroy screen "window"
{
status = SendWindowDestroy(entry->WindowHandle);
if (ERROR_SUCCESS != status)
- return perror2(status, "SendWindowDestroy");
+ return win_perror2(status, "SendWindowDestroy");
}
}
@@ -262,7 +262,7 @@ static BOOL CALLBACK AddWindowsProc(IN H
wi.cbSize = sizeof(wi);
if (!GetWindowInfo(window, &wi))
{
- perror("GetWindowInfo");
+ win_perror("GetWindowInfo");
LogWarning("Skipping window %x", window);
return TRUE;
}
@@ -273,7 +273,7 @@ static BOOL CALLBACK AddWindowsProc(IN H
status = AddWindowWithInfo(window, &wi, NULL);
if (ERROR_SUCCESS != status)
{
- perror2(status, "AddWindowWithInfo");
+ win_perror2(status, "AddWindowWithInfo");
return FALSE; // stop enumeration, fatal error occurred (should probably exit process at this point)
}
@@ -306,7 +306,7 @@ static ULONG AddAllWindows(void)
// Enum top-level windows and add all that are not filtered.
if (!EnumWindows(AddWindowsProc, 0))
- return perror("EnumWindows");
+ return win_perror("EnumWindows");
return ERROR_SUCCESS;
}
@@ -335,7 +335,7 @@ static ULONG ResetWatch(BOOL seamlessMod
if (ERROR_SUCCESS != status)
{
LeaveCriticalSection(&g_csWatchedWindows);
- return perror2(status, "RemoveWindow");
+ return win_perror2(status, "RemoveWindow");
}
entry = nextEntry;
@@ -385,7 +385,7 @@ ULONG SetSeamlessMode(IN BOOL seamlessMo
// show the screen window
status = SendWindowMap(NULL);
if (ERROR_SUCCESS != status)
- return perror2(status, "SendWindowMap(NULL)");
+ return win_perror2(status, "SendWindowMap(NULL)");
}
else // seamless mode
{
@@ -399,14 +399,14 @@ ULONG SetSeamlessMode(IN BOOL seamlessMo
// hide the screen window
status = SendWindowUnmap(NULL);
if (ERROR_SUCCESS != status)
- return perror2(status, "SendWindowUnmap(NULL)");
+ return win_perror2(status, "SendWindowUnmap(NULL)");
}
// ResetWatch removes all watched windows.
// If seamless mode is on, top-level windows are added to watch list.
status = ResetWatch(seamlessMode);
if (ERROR_SUCCESS != status)
- return perror2(status, "ResetWatch");
+ return win_perror2(status, "ResetWatch");
g_SeamlessMode = seamlessMode;
@@ -445,7 +445,7 @@ BOOL ShouldAcceptWindow(IN HWND window,
{
if (!GetWindowInfo(window, &wi))
{
- perror("GetWindowInfo");
+ win_perror("GetWindowInfo");
return FALSE;
}
windowInfo = &wi;
@@ -600,11 +600,11 @@ static ULONG UpdateWindowData(IN OUT WIN
modalWindow->ModalParent = wd->WindowHandle;
status = SendWindowUnmap(modalWindow->WindowHandle);
if (ERROR_SUCCESS != status)
- return perror2(status, "SendWindowUnmap");
+ return win_perror2(status, "SendWindowUnmap");
status = SendWindowMap(modalWindow);
if (ERROR_SUCCESS != status)
- return perror2(status, "SendWindowMap");
+ return win_perror2(status, "SendWindowMap");
}
}
}
@@ -715,7 +715,7 @@ static ULONG ProcessUpdatedWindows(IN HD
if (ERROR_SUCCESS != status)
{
- perror2(status, "SendWindowDamageEvent");
+ win_perror2(status, "SendWindowDamageEvent");
goto cleanup;
}
}
@@ -728,7 +728,7 @@ static ULONG ProcessUpdatedWindows(IN HD
if (ERROR_SUCCESS != status)
{
- perror2(status, "SendWindowDamageEvent");
+ win_perror2(status, "SendWindowDamageEvent");
goto cleanup;
}
}
@@ -816,7 +816,7 @@ static ULONG WINAPI WatchForEvents(void)
signaledEvent = WaitForMultipleObjects(eventCount, watchedEvents, FALSE, INFINITE);
if (signaledEvent >= MAXIMUM_WAIT_OBJECTS)
{
- status = perror("WaitForMultipleObjects");
+ status = win_perror("WaitForMultipleObjects");
break;
}
@@ -862,7 +862,7 @@ static ULONG WINAPI WatchForEvents(void)
updatePending = TRUE;
// fire a delayed damage event to ensure we won't miss anything in case no damages follow
if (!timeSetEvent(1000 / g_MaxFps, 0, (LPTIMECALLBACK)watchedEvents[6], 0, TIME_ONESHOT | TIME_CALLBACK_EVENT_SET))
- perror("timeSetEvent");
+ win_perror("timeSetEvent");
}
continue;
}
@@ -881,7 +881,7 @@ static ULONG WINAPI WatchForEvents(void)
status = SetSeamlessMode(FALSE, FALSE);
if (ERROR_SUCCESS != status)
{
- perror2(status, "SetSeamlessMode(FALSE)");
+ win_perror2(status, "SetSeamlessMode(FALSE)");
exitLoop = TRUE;
}
break;
@@ -890,7 +890,7 @@ static ULONG WINAPI WatchForEvents(void)
status = SetSeamlessMode(TRUE, FALSE);
if (ERROR_SUCCESS != status)
{
- perror2(status, "SetSeamlessMode(TRUE)");
+ win_perror2(status, "SetSeamlessMode(TRUE)");
exitLoop = TRUE;
}
break;
@@ -900,7 +900,7 @@ static ULONG WINAPI WatchForEvents(void)
status = ChangeResolution(&screenDC, windowDamageEvent);
if (ERROR_SUCCESS != status)
{
- perror2(status, "ChangeResolution");
+ win_perror2(status, "ChangeResolution");
exitLoop = TRUE;
}
break;
@@ -936,7 +936,7 @@ static ULONG WINAPI WatchForEvents(void)
status = QvRegisterWatchedDC(screenDC, windowDamageEvent);
if (ERROR_SUCCESS != status)
{
- perror2(status, "QvRegisterWatchedDC");
+ win_perror2(status, "QvRegisterWatchedDC");
exitLoop = TRUE;
break;
}
@@ -945,7 +945,7 @@ static ULONG WINAPI WatchForEvents(void)
status = SendWindowCreate(NULL);
if (ERROR_SUCCESS != status)
{
- perror2(status, "SendWindowCreate(NULL)");
+ win_perror2(status, "SendWindowCreate(NULL)");
exitLoop = TRUE;
break;
}
@@ -953,7 +953,7 @@ static ULONG WINAPI WatchForEvents(void)
status = SendScreenMfns();
if (ERROR_SUCCESS != status)
{
- perror2(status, "SendScreenMfns");
+ win_perror2(status, "SendScreenMfns");
exitLoop = TRUE;
break;
}
@@ -962,7 +962,7 @@ static ULONG WINAPI WatchForEvents(void)
status = SetSeamlessMode(g_SeamlessMode, TRUE);
if (ERROR_SUCCESS != status)
{
- perror2(status, "SetSeamlessMode");
+ win_perror2(status, "SetSeamlessMode");
exitLoop = TRUE;
break;
}
@@ -1022,7 +1022,7 @@ static DWORD GetDomainName(OUT char *nam
qdb = qdb_open(NULL);
if (!qdb)
- return perror("qdb_open");
+ return win_perror("qdb_open");
domainName = qdb_read(qdb, "/name", NULL);
if (!domainName)
@@ -1035,7 +1035,7 @@ static DWORD GetDomainName(OUT char *nam
LogDebug("%S", domainName);
status = StringCchCopyA(nameBuffer, nameLength, domainName);
if (FAILED(status))
- perror2(status, "StringCchCopyA");
+ win_perror2(status, "StringCchCopyA");
cleanup:
qdb_free(domainName);
@@ -1099,7 +1099,7 @@ static ULONG Init(void)
status = IncreaseProcessWorkingSetSize(1024 * 1024 * 100, 1024 * 1024 * 1024);
if (ERROR_SUCCESS != status)
{
- perror("IncreaseProcessWorkingSetSize");
+ win_perror("IncreaseProcessWorkingSetSize");
// try to continue
}
@@ -1132,16 +1132,20 @@ static ULONG Init(void)
return ERROR_SUCCESS;
}
+#ifdef __MINGW32__
+int CALLBACK wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, WCHAR *lpCmdLine, int nCmdShow)
+#else
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+#endif
{
if (ERROR_SUCCESS != Init())
- return perror("Init");
+ return win_perror("Init");
InitializeCriticalSection(&g_VchanCriticalSection);
// Call the thread proc directly.
if (ERROR_SUCCESS != WatchForEvents())
- return perror("WatchForEvents");
+ return win_perror("WatchForEvents");
DeleteCriticalSection(&g_VchanCriticalSection);
diff -pruN a/gui-agent/qvcontrol.c b/gui-agent/qvcontrol.c
--- a/gui-agent/qvcontrol.c 2018-07-11 19:29:59.000000000 +0300
+++ b/gui-agent/qvcontrol.c 2020-01-17 13:56:26.899126801 +0300
@@ -93,7 +93,7 @@ ULONG QvSupportVideoMode(
qvideoDc = CreateDC(NULL, qubesDisplayDeviceName, NULL, NULL);
if (!qvideoDc)
- return perror("CreateDC");
+ return win_perror("CreateDC");
input.Magic = QVIDEO_MAGIC;
input.Width = width;
@@ -128,7 +128,7 @@ ULONG QvGetWindowData(
qvideoDc = GetDC(window);
if (!qvideoDc)
- return perror("GetDC");
+ return win_perror("GetDC");
input.Magic = QVIDEO_MAGIC;
@@ -171,7 +171,7 @@ ULONG QvReleaseWindowData(
qvideoDc = GetDC(window);
if (!qvideoDc)
- return perror("GetDC");
+ return win_perror("GetDC");
input.Magic = QVIDEO_MAGIC;
diff -pruN a/gui-agent/resolution.c b/gui-agent/resolution.c
--- a/gui-agent/resolution.c 2018-07-11 19:29:59.000000000 +0300
+++ b/gui-agent/resolution.c 2020-01-17 13:56:26.899126801 +0300
@@ -70,7 +70,7 @@ static DWORD WINAPI ResolutionChangeThre
// We can change the resolution now.
LogInfo("resolution change: %dx%d", g_ResolutionChangeParams.Width, g_ResolutionChangeParams.Height);
if (!SetEvent(g_ResolutionChangeEvent)) // handled in WatchForEvents, actual resolution change
- return perror("SetEvent");
+ return win_perror("SetEvent");
}
return ERROR_SUCCESS;
}
@@ -92,7 +92,7 @@ void RequestResolutionChange(IN LONG wid
g_ResolutionChangeParams.X = x;
g_ResolutionChangeParams.Y = y;
if (!SetEvent(g_ResolutionChangeRequestedEvent))
- perror("SetEvent");
+ win_perror("SetEvent");
}
// Actually set video mode through qvideo calls.
@@ -113,17 +113,17 @@ static ULONG SetVideoModeInternal(IN ULO
AttachToInputDesktop();
if (ERROR_SUCCESS != QvFindQubesDisplayDevice(&device))
- return perror("QvFindQubesDisplayDevice");
+ return win_perror("QvFindQubesDisplayDevice");
deviceName = (WCHAR *)&device.DeviceName[0];
LogDebug("DeviceName: %s", deviceName);
if (ERROR_SUCCESS != QvSupportVideoMode(deviceName, width, height, bpp))
- return perror("QvSupportVideoMode");
+ return win_perror("QvSupportVideoMode");
if (ERROR_SUCCESS != ChangeVideoMode(deviceName, width, height, bpp))
- return perror("ChangeVideoMode");
+ return win_perror("ChangeVideoMode");
return ERROR_SUCCESS;
}
diff -pruN a/gui-agent/send.c b/gui-agent/send.c
--- a/gui-agent/send.c 2018-07-11 19:29:59.000000000 +0300
+++ b/gui-agent/send.c 2020-01-17 13:56:26.900126803 +0300
@@ -56,7 +56,7 @@ static ULONG PrepareShmCmd(OUT struct sh
// this will map driver-managed pfn list into the process, user address is in the response struct
status = QvGetWindowData(NULL, &surfaceData);
if (ERROR_SUCCESS != status)
- return perror2(status, "QvGetWindowData");
+ return win_perror2(status, "QvGetWindowData");
width = surfaceData.Width;
height = surfaceData.Height;
@@ -90,7 +90,7 @@ static ULONG PrepareShmCmd(OUT struct sh
// unmap the pfn array
status = QvReleaseWindowData(NULL);
if (ERROR_SUCCESS != status)
- perror2(status, "QvReleaseWindowData");
+ win_perror2(status, "QvReleaseWindowData");
return status;
}
@@ -106,7 +106,7 @@ ULONG SendScreenMfns(void)
status = PrepareShmCmd(&shmCmd);
if (ERROR_SUCCESS != status)
- return perror2(status, "PrepareShmCmd");
+ return win_perror2(status, "PrepareShmCmd");
if (shmCmd->num_mfn == 0 || shmCmd->num_mfn > MAX_MFN_COUNT)
{
@@ -125,13 +125,13 @@ ULONG SendScreenMfns(void)
if (!VCHAN_SEND(header, L"MSG_MFNDUMP"))
{
LeaveCriticalSection(&g_VchanCriticalSection);
- return perror2(ERROR_UNIDENTIFIED_ERROR, "VCHAN_SEND(header)");
+ return win_perror2(ERROR_UNIDENTIFIED_ERROR, "VCHAN_SEND(header)");
}
status = VchanSendBuffer(g_Vchan, shmCmd, sizeof(struct shm_cmd) + size, L"shm_cmd");
LeaveCriticalSection(&g_VchanCriticalSection);
if (!status)
- return perror2(status, "VchanSendBuffer");
+ return win_perror2(status, "VchanSendBuffer");
free(shmCmd);
@@ -161,7 +161,7 @@ ULONG SendWindowCreate(IN const WINDOW_D
status = QvGetWindowData(NULL, &surfaceData);
if (ERROR_SUCCESS != status)
- return perror2(status, "QvGetWindowData");
+ return win_perror2(status, "QvGetWindowData");
wi.rcWindow.right = surfaceData.Width;
wi.rcWindow.bottom = surfaceData.Height;
@@ -527,7 +527,7 @@ ULONG SendWindowName(IN HWND window, IN
{
if (0 == GetWindowTextA(window, nameMsg.data, RTL_NUMBER_OF(nameMsg.data)))
{
- perror("GetWindowTextA");
+ win_perror("GetWindowTextA");
return ERROR_SUCCESS; // whatever
}
}
diff -pruN a/gui-agent/util.c b/gui-agent/util.c
--- a/gui-agent/util.c 2018-07-11 19:29:59.000000000 +0300
+++ b/gui-agent/util.c 2020-01-17 13:56:26.900126803 +0300
@@ -38,7 +38,7 @@ static SID *BuildLocalSid(void)
SID *sid = NULL;
if (!AllocateAndInitializeSid(&sia, 1, SECURITY_AUTHENTICATED_USER_RID, 0, 0, 0, 0, 0, 0, 0, &sid))
{
- perror("AllocateAndInitializeSid");
+ win_perror("AllocateAndInitializeSid");
}
return sid;
}
@@ -63,26 +63,26 @@ static ULONG CreatePublicAcl(IN DWORD ac
status = SetEntriesInAcl(1, &ea, NULL, &acl);
if (status != ERROR_SUCCESS)
{
- perror2(status, "SetEntriesInAcl");
+ win_perror2(status, "SetEntriesInAcl");
goto cleanup;
}
sd = (SECURITY_DESCRIPTOR *) LocalAlloc(LMEM_ZEROINIT, sizeof(SECURITY_DESCRIPTOR));
if (!sd)
{
- status = perror("LocalAlloc");
+ status = win_perror("LocalAlloc");
goto cleanup;
}
if (!InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION))
{
- status = perror("InitializeSecurityDescriptor");
+ status = win_perror("InitializeSecurityDescriptor");
goto cleanup;
}
if (!SetSecurityDescriptorDacl(sd, TRUE, acl, FALSE))
{
- perror("SetSecurityDescriptorDacl");
+ win_perror("SetSecurityDescriptorDacl");
goto cleanup;
}
@@ -121,7 +121,7 @@ HANDLE CreateNamedEvent(IN const WCHAR *
status = CreatePublicAcl(EVENT_MODIFY_STATE | READ_CONTROL | SYNCHRONIZE, &sa);
if (ERROR_SUCCESS != status)
{
- perror2(status, "CreatePublicAcl");
+ win_perror2(status, "CreatePublicAcl");
return NULL;
}
@@ -135,7 +135,7 @@ HANDLE CreateNamedEvent(IN const WCHAR *
LocalFree(sa);
if (!event)
- perror2(status, "CreateEvent");
+ win_perror2(status, "CreateEvent");
return event;
}
@@ -152,7 +152,7 @@ HANDLE CreateNamedMailslot(IN const WCHA
status = CreatePublicAcl(GENERIC_READ | GENERIC_WRITE | READ_CONTROL | SYNCHRONIZE, &sa);
if (ERROR_SUCCESS != status)
{
- perror2(status, "CreatePublicAcl");
+ win_perror2(status, "CreatePublicAcl");
return NULL;
}
@@ -165,7 +165,7 @@ HANDLE CreateNamedMailslot(IN const WCHA
LocalFree(sa);
if (!slot)
- perror2(status, "CreateMailslot");
+ win_perror2(status, "CreateMailslot");
return slot;
}
@@ -184,7 +184,7 @@ ULONG StartProcess(IN const WCHAR *execu
//si.wShowWindow = SW_HIDE;
//si.dwFlags = STARTF_USESHOWWINDOW;
if (!CreateProcess(NULL, exePath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
- return perror("CreateProcess");
+ return win_perror("CreateProcess");
CloseHandle(pi.hThread);
*processHandle = pi.hProcess;
@@ -196,10 +196,10 @@ ULONG StartProcess(IN const WCHAR *execu
ULONG IncreaseProcessWorkingSetSize(IN SIZE_T minimumSize, IN SIZE_T maximumSize)
{
if (!SetProcessWorkingSetSize(GetCurrentProcess(), minimumSize, maximumSize))
- return perror("SetProcessWorkingSetSize");
+ return win_perror("SetProcessWorkingSetSize");
if (!GetProcessWorkingSetSize(GetCurrentProcess(), &minimumSize, &maximumSize))
- return perror("GetProcessWorkingSetSize");
+ return win_perror("GetProcessWorkingSetSize");
LogDebug("New working set size: %d pages\n", maximumSize >> 12);
@@ -236,7 +236,7 @@ ULONG HideCursors(void)
blankCursor = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDC_BLANK), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE);
if (!blankCursor)
- return perror("LoadImage");
+ return win_perror("LoadImage");
for (i = 0; i < RTL_NUMBER_OF(cursorsToHide); i++)
{
@@ -246,14 +246,14 @@ ULONG HideCursors(void)
// the CopyCursor function, then pass the copy to SetSystemCursor.
blankCursorCopy = CopyCursor(blankCursor);
if (!blankCursorCopy)
- return perror("CopyCursor");
+ return win_perror("CopyCursor");
if (!SetSystemCursor(blankCursorCopy, cursorsToHide[i]))
- return perror("SetSystemCursor");
+ return win_perror("SetSystemCursor");
}
if (!DestroyCursor(blankCursor))
- return perror("DestroyCursor");
+ return win_perror("DestroyCursor");
return ERROR_SUCCESS;
}
@@ -264,13 +264,13 @@ ULONG DisableEffects(void)
LogDebug("start");
if (!SystemParametersInfo(SPI_SETDROPSHADOW, 0, (void *) FALSE, SPIF_UPDATEINIFILE))
- return perror("SystemParametersInfo(SPI_SETDROPSHADOW)");
+ return win_perror("SystemParametersInfo(SPI_SETDROPSHADOW)");
animationInfo.cbSize = sizeof(animationInfo);
animationInfo.iMinAnimate = FALSE;
if (!SystemParametersInfo(SPI_SETANIMATION, sizeof(animationInfo), &animationInfo, SPIF_UPDATEINIFILE))
- return perror("SystemParametersInfo(SPI_SETANIMATION)");
+ return win_perror("SystemParametersInfo(SPI_SETANIMATION)");
return ERROR_SUCCESS;
}
@@ -296,14 +296,14 @@ ULONG AttachToInputDesktop(void)
if (!desktop)
{
- status = perror("OpenInputDesktop");
+ status = win_perror("OpenInputDesktop");
goto cleanup;
}
#ifdef DEBUG
if (!GetUserObjectInformation(desktop, UOI_NAME, name, sizeof(name), &needed))
{
- perror("GetUserObjectInformation");
+ win_perror("GetUserObjectInformation");
}
else
{
@@ -321,7 +321,7 @@ ULONG AttachToInputDesktop(void)
oldDesktop = GetThreadDesktop(GetCurrentThreadId());
if (!SetThreadDesktop(desktop))
{
- status = perror("SetThreadDesktop");
+ status = win_perror("SetThreadDesktop");
goto cleanup;
}
@@ -330,7 +330,7 @@ ULONG AttachToInputDesktop(void)
cleanup:
if (oldDesktop)
if (!CloseDesktop(oldDesktop))
- perror("CloseDesktop(previous)");
+ win_perror("CloseDesktop(previous)");
return status;
}
diff -pruN a/gui-agent/vchan-handlers.c b/gui-agent/vchan-handlers.c
--- a/gui-agent/vchan-handlers.c 2018-07-11 19:29:59.000000000 +0300
+++ b/gui-agent/vchan-handlers.c 2020-01-17 13:56:26.900126803 +0300
@@ -41,7 +41,7 @@ static void SignalSASEvent(void)
{
sasEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, QGA_SAS_EVENT_NAME);
if (!sasEvent)
- perror("OpenEvent");
+ win_perror("OpenEvent");
}
if (sasEvent)
@@ -118,7 +118,7 @@ static DWORD HandleKeymapNotify(void)
if (!SendInput(1, &inputEvent, sizeof(inputEvent)))
{
- return perror("SendInput");
+ return win_perror("SendInput");
}
LogDebug("unsetting key VK=0x%x (keycode=0x%x)", virtualKey, modifierKeys[i]);
}
@@ -156,7 +156,7 @@ static DWORD SynthesizeKeycode(IN UINT k
if (!SendInput(1, &inputEvent, sizeof(inputEvent)))
{
- return perror("SendInput");
+ return win_perror("SendInput");
}
return ERROR_SUCCESS;
@@ -194,12 +194,12 @@ static DWORD HandleKeypress(IN HWND wind
inputEvent.ki.dwFlags = 0;
if (!SendInput(1, &inputEvent, sizeof(inputEvent)))
{
- return perror("SendInput(VK_CAPITAL)");
+ return win_perror("SendInput(VK_CAPITAL)");
}
inputEvent.ki.dwFlags = KEYEVENTF_KEYUP;
if (!SendInput(1, &inputEvent, sizeof(inputEvent)))
{
- return perror("SendInput(KEYEVENTF_KEYUP)");
+ return win_perror("SendInput(KEYEVENTF_KEYUP)");
}
}
@@ -267,7 +267,7 @@ static DWORD HandleButton(IN HWND window
LogDebug("window 0x%x, (%d,%d), flags 0x%x", window, inputEvent.mi.dx, inputEvent.mi.dy, inputEvent.mi.dwFlags);
if (!SendInput(1, &inputEvent, sizeof(inputEvent)))
{
- return perror("SendInput");
+ return win_perror("SendInput");
}
return ERROR_SUCCESS;
@@ -301,7 +301,7 @@ static DWORD HandleMotion(IN HWND window
if (!SendInput(1, &inputEvent, sizeof(inputEvent)))
{
- return perror("SendInput");
+ return win_perror("SendInput");
}
return ERROR_SUCCESS;
diff -pruN a/gui-agent/wm.c b/gui-agent/wm.c
--- a/gui-agent/wm.c 2018-07-11 19:29:59.000000000 +0300
+++ b/gui-agent/wm.c 2020-01-17 13:56:26.901126805 +0300
@@ -19,7 +19,7 @@
*
*/
-#include <Windows.h>
+#include <windows.h>
// Debug helper functions
diff -pruN a/include/mingw/customddkinc.h b/include/mingw/customddkinc.h
--- a/include/mingw/customddkinc.h 1970-01-01 03:00:00.000000000 +0300
+++ b/include/mingw/customddkinc.h 2020-01-17 13:56:26.901126805 +0300
@@ -0,0 +1,72 @@
+#include <devpropdef.h>
+#include <strsafe.h>
+#include <sal.h>
+
+#define __field_bcount_part(size,init) SAL__notnull SAL__byte_writableTo(size) SAL__byte_readableTo(init)
+
+DEFINE_DEVPROPKEY(DEVPKEY_Device_HardwareIds, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 3); // DEVPROP_TYPE_STRING_LIST
+DEFINE_DEVPROPKEY(DEVPKEY_Device_Class, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 9); // DEVPROP_TYPE_STRING
+DEFINE_DEVPROPKEY(DEVPKEY_Device_LocationInfo, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 15); // DEVPROP_TYPE_STRING
+#define IOCTL_DISK_SET_DISK_ATTRIBUTES CTL_CODE(IOCTL_DISK_BASE, 0x003d, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
+
+#define DISK_ATTRIBUTE_OFFLINE 0x0000000000000001
+#define DISK_ATTRIBUTE_READ_ONLY 0x0000000000000002
+
+//
+// IOCTL_DISK_SET_DISK_ATTRIBUTES
+//
+// Input Buffer:
+// Structure of type SET_DISK_ATTRIBUTES
+//
+// Output Buffer:
+// None
+//
+
+typedef struct _SET_DISK_ATTRIBUTES {
+
+ //
+ // Specifies the size of the
+ // structure for versioning.
+ //
+ ULONG Version;
+
+ //
+ // Indicates whether to remember
+ // these settings across reboots
+ // or not.
+ //
+ BOOLEAN Persist;
+
+ //
+ // Indicates whether the ownership
+ // taken earlier is being released.
+ //
+ BOOLEAN RelinquishOwnership;
+
+ //
+ // For alignment purposes.
+ //
+ BOOLEAN Reserved1[2];
+
+ //
+ // Specifies the new attributes.
+ //
+ ULONGLONG Attributes;
+
+ //
+ // Specifies the attributes
+ // that are being modified.
+ //
+ ULONGLONG AttributesMask;
+
+ //
+ // Specifies an identifier to be
+ // associated with the caller.
+ // This setting is not persisted
+ // across reboots.
+ //
+ GUID Owner;
+
+} SET_DISK_ATTRIBUTES, *PSET_DISK_ATTRIBUTES;
+
+
diff -pruN a/include/mingw/d3dnthal.h b/include/mingw/d3dnthal.h
--- a/include/mingw/d3dnthal.h 1970-01-01 03:00:00.000000000 +0300
+++ b/include/mingw/d3dnthal.h 2020-01-17 13:56:26.901126805 +0300
@@ -0,0 +1,258 @@
+/*
+ * d3dnthal.h
+ *
+ * Direct3D NT driver interface
+ *
+ * Contributors:
+ * Created by Ge van Geldorp
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAIMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#ifndef __DDK_D3DNTHAL_H
+#define __DDK_D3DNTHAL_H
+
+#include <ddrawint.h>
+#include <d3dtypes.h>
+#include <d3dcaps.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+DEFINE_GUID(GUID_D3DCallbacks, 0x7BF06990, 0x8794, 0x11D0, 0x91, 0x39, 0x08, 0x00, 0x36, 0xD2, 0xEF, 0x02);
+DEFINE_GUID(GUID_D3DCallbacks3, 0xDDF41230, 0xEC0A, 0x11D0, 0xA9, 0xB6, 0x00, 0xAA, 0x00, 0xC0, 0x99, 0x3E);
+DEFINE_GUID(GUID_D3DExtendedCaps, 0x7DE41F80, 0x9D93, 0x11D0, 0x89, 0xAB, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x29);
+DEFINE_GUID(GUID_D3DParseUnknownCommandCallback, 0x2E04FFA0, 0x98E4, 0x11D1, 0x8C, 0xE1, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8);
+DEFINE_GUID(GUID_ZPixelFormats, 0x93869880, 0x36CF, 0x11D1, 0x9B, 0x1B, 0x00, 0xAA, 0x00, 0xBB, 0xB8, 0xAE);
+DEFINE_GUID(GUID_DDStereoMode, 0xF828169C, 0xA8E8, 0x11D2, 0xA1, 0xF2, 0x00, 0xA0, 0xC9, 0x83, 0xEA, 0xF6);
+
+typedef struct _D3DNTHAL_CONTEXTCREATEDATA {
+ __GNU_EXTENSION union {
+ PDD_DIRECTDRAW_GLOBAL lpDDGbl;
+ PDD_DIRECTDRAW_LOCAL lpDDLcl;
+ };
+ __GNU_EXTENSION union {
+ PDD_SURFACE_LOCAL lpDDS;
+ PDD_SURFACE_LOCAL lpDDSLcl;
+ };
+ __GNU_EXTENSION union {
+ PDD_SURFACE_LOCAL lpDDSZ;
+ PDD_SURFACE_LOCAL lpDDSZLcl;
+ };
+ DWORD dwPID;
+ ULONG_PTR dwhContext;
+ HRESULT ddrval;
+} D3DNTHAL_CONTEXTCREATEDATA, *LPD3DNTHAL_CONTEXTCREATEDATA;
+
+typedef struct _D3DNTHAL_CONTEXTDESTROYDATA {
+ ULONG_PTR dwhContext;
+ HRESULT ddrval;
+} D3DNTHAL_CONTEXTDESTROYDATA, *LPD3DNTHAL_CONTEXTDESTROYDATA;
+
+typedef struct _D3DNTHAL_CONTEXTDESTROYALLDATA {
+ DWORD dwPID;
+ HRESULT ddrval;
+} D3DNTHAL_CONTEXTDESTROYALLDATA, *LPD3DNTHAL_CONTEXTDESTROYALLDATA;
+
+typedef struct _D3DNTHAL_SCENECAPTUREDATA {
+ ULONG_PTR dwhContext;
+ DWORD dwFlag;
+ HRESULT ddrval;
+} D3DNTHAL_SCENECAPTUREDATA, *LPD3DNTHAL_SCENECAPTUREDATA;
+
+typedef struct _D3DNTHAL_TEXTURECREATEDATA {
+ ULONG_PTR dwhContext;
+ HANDLE hDDS;
+ ULONG_PTR dwHandle;
+ HRESULT ddrval;
+} D3DNTHAL_TEXTURECREATEDATA, *LPD3DNTHAL_TEXTURECREATEDATA;
+
+typedef struct _D3DNTHAL_TEXTUREDESTROYDATA {
+ ULONG_PTR dwhContext;
+ ULONG_PTR dwHandle;
+ HRESULT ddrval;
+} D3DNTHAL_TEXTUREDESTROYDATA, *LPD3DNTHAL_TEXTUREDESTROYDATA;
+
+typedef struct _D3DNTHAL_TEXTURESWAPDATA {
+ ULONG_PTR dwhContext;
+ ULONG_PTR dwHandle1;
+ ULONG_PTR dwHandle2;
+ HRESULT ddrval;
+} D3DNTHAL_TEXTURESWAPDATA, *LPD3DNTHAL_TEXTURESWAPDATA;
+
+typedef struct _D3DNTHAL_TEXTUREGETSURFDATA {
+ ULONG_PTR dwhContext;
+ HANDLE hDDS;
+ ULONG_PTR dwHandle;
+ HRESULT ddrval;
+} D3DNTHAL_TEXTUREGETSURFDATA, *LPD3DNTHAL_TEXTUREGETSURFDATA;
+
+typedef DWORD (APIENTRY *LPD3DNTHAL_CONTEXTCREATECB)(LPD3DNTHAL_CONTEXTCREATEDATA);
+typedef DWORD (APIENTRY *LPD3DNTHAL_CONTEXTDESTROYCB)(LPD3DNTHAL_CONTEXTDESTROYDATA);
+typedef DWORD (APIENTRY *LPD3DNTHAL_CONTEXTDESTROYALLCB)(LPD3DNTHAL_CONTEXTDESTROYALLDATA);
+typedef DWORD (APIENTRY *LPD3DNTHAL_SCENECAPTURECB)(LPD3DNTHAL_SCENECAPTUREDATA);
+typedef DWORD (APIENTRY *LPD3DNTHAL_TEXTURECREATECB)(LPD3DNTHAL_TEXTURECREATEDATA);
+typedef DWORD (APIENTRY *LPD3DNTHAL_TEXTUREDESTROYCB)(LPD3DNTHAL_TEXTUREDESTROYDATA);
+typedef DWORD (APIENTRY *LPD3DNTHAL_TEXTURESWAPCB)(LPD3DNTHAL_TEXTURESWAPDATA);
+typedef DWORD (APIENTRY *LPD3DNTHAL_TEXTUREGETSURFCB)(LPD3DNTHAL_TEXTUREGETSURFDATA);
+
+typedef struct _D3DNTHALDeviceDesc_V1 {
+ DWORD dwSize;
+ DWORD dwFlags;
+ D3DCOLORMODEL dcmColorModel;
+ DWORD dwDevCaps;
+ D3DTRANSFORMCAPS dtcTransformCaps;
+ WINBOOL bClipping;
+ D3DLIGHTINGCAPS dlcLightingCaps;
+ D3DPRIMCAPS dpcLineCaps;
+ D3DPRIMCAPS dpcTriCaps;
+ DWORD dwDeviceRenderBitDepth;
+ DWORD dwDeviceZBufferBitDepth;
+ DWORD dwMaxBufferSize;
+ DWORD dwMaxVertexCount;
+} D3DNTHALDEVICEDESC_V1, *LPD3DNTHALDEVICEDESC_V1;
+
+typedef struct _D3DNTHAL_GLOBALDRIVERDATA {
+ DWORD dwSize;
+ D3DNTHALDEVICEDESC_V1 hwCaps;
+ DWORD dwNumVertices;
+ DWORD dwNumClipVertices;
+ DWORD dwNumTextureFormats;
+ LPDDSURFACEDESC lpTextureFormats;
+} D3DNTHAL_GLOBALDRIVERDATA, *LPD3DNTHAL_GLOBALDRIVERDATA;
+
+typedef struct _D3DNTHAL_CALLBACKS {
+ DWORD dwSize;
+ LPD3DNTHAL_CONTEXTCREATECB ContextCreate;
+ LPD3DNTHAL_CONTEXTDESTROYCB ContextDestroy;
+ LPD3DNTHAL_CONTEXTDESTROYALLCB ContextDestroyAll;
+ LPD3DNTHAL_SCENECAPTURECB SceneCapture;
+ LPVOID dwReserved10;
+ LPVOID dwReserved11;
+ LPVOID dwReserved22;
+ LPVOID dwReserved23;
+ ULONG_PTR dwReserved;
+ LPD3DNTHAL_TEXTURECREATECB TextureCreate;
+ LPD3DNTHAL_TEXTUREDESTROYCB TextureDestroy;
+ LPD3DNTHAL_TEXTURESWAPCB TextureSwap;
+ LPD3DNTHAL_TEXTUREGETSURFCB TextureGetSurf;
+ LPVOID dwReserved12;
+ LPVOID dwReserved13;
+ LPVOID dwReserved14;
+ LPVOID dwReserved15;
+ LPVOID dwReserved16;
+ LPVOID dwReserved17;
+ LPVOID dwReserved18;
+ LPVOID dwReserved19;
+ LPVOID dwReserved20;
+ LPVOID dwReserved21;
+ LPVOID dwReserved24;
+ ULONG_PTR dwReserved0;
+ ULONG_PTR dwReserved1;
+ ULONG_PTR dwReserved2;
+ ULONG_PTR dwReserved3;
+ ULONG_PTR dwReserved4;
+ ULONG_PTR dwReserved5;
+ ULONG_PTR dwReserved6;
+ ULONG_PTR dwReserved7;
+ ULONG_PTR dwReserved8;
+ ULONG_PTR dwReserved9;
+} D3DNTHAL_CALLBACKS, *LPD3DNTHAL_CALLBACKS;
+
+
+typedef struct _D3DNTHAL_SETRENDERTARGETDATA {
+ ULONG_PTR dwhContext;
+ PDD_SURFACE_LOCAL lpDDS;
+ PDD_SURFACE_LOCAL lpDDSZ;
+ HRESULT ddrval;
+} D3DNTHAL_SETRENDERTARGETDATA;
+typedef D3DNTHAL_SETRENDERTARGETDATA *LPD3DNTHAL_SETRENDERTARGETDATA;
+
+typedef DWORD (APIENTRY *LPD3DNTHAL_SETRENDERTARGETCB)(LPD3DNTHAL_SETRENDERTARGETDATA);
+
+
+typedef struct _D3DNTHAL_CALLBACKS2 {
+ DWORD dwSize;
+ DWORD dwFlags;
+
+ LPD3DNTHAL_SETRENDERTARGETCB SetRenderTarget;
+ LPVOID dwReserved1;
+ LPVOID dwReserved2;
+ LPVOID dwReserved3;
+ LPVOID dwReserved4;
+} D3DNTHAL_CALLBACKS2, *LPD3DNTHAL_CALLBACKS2;
+
+
+typedef struct _D3DNTHAL_CLEAR2DATA {
+ ULONG_PTR dwhContext;
+ DWORD dwFlags;
+ DWORD dwFillColor;
+ D3DVALUE dvFillDepth;
+ DWORD dwFillStencil;
+ LPD3DRECT lpRects;
+ DWORD dwNumRects;
+ HRESULT ddrval;
+} D3DNTHAL_CLEAR2DATA;
+typedef D3DNTHAL_CLEAR2DATA FAR *LPD3DNTHAL_CLEAR2DATA;
+
+typedef struct _D3DNTHAL_VALIDATETEXTURESTAGESTATEDATA {
+ ULONG_PTR dwhContext;
+ DWORD dwFlags;
+ ULONG_PTR dwReserved;
+ DWORD dwNumPasses;
+ HRESULT ddrval;
+} D3DNTHAL_VALIDATETEXTURESTAGESTATEDATA, FAR *LPD3DNTHAL_VALIDATETEXTURESTAGESTATEDATA;
+
+typedef struct _D3DNTHAL_DRAWPRIMITIVES2DATA {
+ ULONG_PTR dwhContext;
+ DWORD dwFlags;
+ DWORD dwVertexType;
+ PDD_SURFACE_LOCAL lpDDCommands;
+ DWORD dwCommandOffset;
+ DWORD dwCommandLength;
+ __GNU_EXTENSION union {
+ PDD_SURFACE_LOCAL lpDDVertex;
+ LPVOID lpVertices;
+ };
+ DWORD dwVertexOffset;
+ DWORD dwVertexLength;
+ DWORD dwReqVertexBufSize;
+ DWORD dwReqCommandBufSize;
+ LPDWORD lpdwRStates;
+ __GNU_EXTENSION union {
+ DWORD dwVertexSize;
+ HRESULT ddrval;
+ };
+ DWORD dwErrorOffset;
+} D3DNTHAL_DRAWPRIMITIVES2DATA, FAR *LPD3DNTHAL_DRAWPRIMITIVES2DATA;
+
+typedef DWORD (APIENTRY *LPD3DNTHAL_CLEAR2CB)(LPD3DNTHAL_CLEAR2DATA);
+typedef DWORD (APIENTRY *LPD3DNTHAL_VALIDATETEXTURESTAGESTATECB)(LPD3DNTHAL_VALIDATETEXTURESTAGESTATEDATA);
+typedef DWORD (APIENTRY *LPD3DNTHAL_DRAWPRIMITIVES2CB)(LPD3DNTHAL_DRAWPRIMITIVES2DATA);
+
+typedef struct _D3DNTHAL_CALLBACKS3 {
+ DWORD dwSize;
+ DWORD dwFlags;