Skip to content

Commit 1007eb9

Browse files
author
hdlx
committed
Logs
1 parent 537071d commit 1007eb9

4 files changed

Lines changed: 48 additions & 1 deletion

File tree

Sources/AltAppSwitcher/App.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static DWORD MainThread;
4444

4545
static void RestoreKey(WORD keyCode)
4646
{
47+
AAS_MSG("RestoreKey");
4748
{
4849
INPUT input = { };
4950
input.type = INPUT_KEYBOARD;
@@ -216,11 +217,13 @@ static void ClearInitMsgs()
216217

217218
int StartAltAppSwitcher(HINSTANCE instance)
218219
{
220+
AAS_MSG("Starting AAS instance %u", instance);
219221
SetLastError(0);
220222
AssertSingleInstance();
221223
ASSERT(SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS));
222224
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
223225

226+
AAS_MSG("CoInitialize()");
224227
CoInitialize(NULL);
225228

226229
static struct AppData appData = { };
@@ -230,6 +233,7 @@ int StartAltAppSwitcher(HINSTANCE instance)
230233
MainThread = GetCurrentThreadId();
231234
// Init. and loads config
232235
LoadConfig(&appData.Config);
236+
AAS_MSG("LoadConfig()");
233237
Cfg = &appData.Config;
234238

235239
appData.Elevated = false;
@@ -242,6 +246,7 @@ int StartAltAppSwitcher(HINSTANCE instance)
242246
appData.Elevated = elTok.TokenIsElevated;
243247
CloseHandle(tok);
244248
}
249+
AAS_MSG("Get elevation()");
245250

246251
char updater[MAX_PATH] = { };
247252
UpdaterPath(updater);
@@ -251,19 +256,24 @@ int StartAltAppSwitcher(HINSTANCE instance)
251256
CreateProcess(NULL, updater, 0, 0, false, CREATE_NEW_PROCESS_GROUP, 0, 0,
252257
&si, &pi);
253258
}
259+
AAS_MSG("Check for update");
254260

255261
CoCreateInstance(&CLSID_VirtualDesktopManager, NULL, CLSCTX_ALL, &IID_IVirtualDesktopManager, (void**)&appData.VDM);
256262
}
257263

258264
CommonInit(instance);
265+
AAS_MSG("CommonInit");
259266
AppModeInit(instance, &appData.Config, appData.VDM);
267+
AAS_MSG("AppModeInit");
260268
WinModeInit(instance, &appData.Config, appData.VDM);
269+
AAS_MSG("WinModeInit");
261270

262271
HANDLE threadKbHook = CreateThread(NULL, 0, KbHookCb, (void*)&appData, CREATE_SUSPENDED, NULL);
263272
(void)threadKbHook;
264273
SetThreadPriority(threadKbHook, THREAD_PRIORITY_TIME_CRITICAL);
265274
ResumeThread(threadKbHook);
266275
AllowSetForegroundWindow(GetCurrentProcessId());
276+
AAS_MSG("AllowSetForegroundWindow GetCurrentProcessId");
267277

268278
HANDLE token;
269279
OpenProcessToken(
@@ -287,6 +297,7 @@ int StartAltAppSwitcher(HINSTANCE instance)
287297
while (GetMessage(&msg, NULL, 0, 0) > 0) {
288298
switch (msg.message) {
289299
case MSG_INIT_APP: {
300+
AAS_MSG("MSG_INIT_APP");
290301
ClearInitMsgs();
291302
RestoreKey(appData.Config.Key.WinHold);
292303
if (IsWindow(appData.win_mode_window)) {
@@ -301,6 +312,7 @@ int StartAltAppSwitcher(HINSTANCE instance)
301312
break;
302313
}
303314
case MSG_INIT_WIN: {
315+
AAS_MSG("MSG_INIT_WIN");
304316
ClearInitMsgs();
305317
RestoreKey(appData.Config.Key.AppHold);
306318
if (IsWindow(appData.win_mode_window)) {

Sources/AltAppSwitcher/AppMode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,7 @@ void AppModeDeinit()
13761376

13771377
HWND AppModeCreateWindow()
13781378
{
1379+
AAS_MSG("AppModeCreateWindow");
13791380
DWORD curThread = GetCurrentThreadId();
13801381
DWORD fgwinthread = TryAttachToForeground();
13811382
HWND hwnd = CreateWindowEx(
@@ -1399,6 +1400,7 @@ HWND AppModeCreateWindow()
13991400
WINBOOL r = AttachThreadInput(GetCurrentThreadId(), fgwinthread, FALSE);
14001401
VERIFY(r);
14011402
}
1403+
AAS_MSG("AppModeCreateWindow End");
14021404
return hwnd;
14031405
}
14041406

Sources/Utils/Error.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,32 @@ static void GetErrStr(DWORD err, char* str, uint32_t strSize)
2222
LocalFree(msg);
2323
}
2424

25+
void AASMsg(const char* file, uint32_t line, const char* msg, ...)
26+
{
27+
va_list vaargs;
28+
va_start(vaargs, msg);
29+
30+
char logFile[MAX_PATH] = { };
31+
LogPath(logFile);
32+
33+
time_t mytime = time(NULL);
34+
char* timeStr = ctime(&mytime); // NOLINT
35+
timeStr[strlen(timeStr) - 1] = '\0';
36+
37+
FILE* f = fopen(logFile, "ab");
38+
if (f != NULL) {
39+
int r = fprintf_s(f, "%s - %s - l. %u:\n", timeStr, file, line);
40+
ASSERT(r > 0);
41+
r = vfprintf_s(f, msg, vaargs);
42+
ASSERT(r > 0);
43+
r = fprintf_s(f, "\n\n");
44+
ASSERT(r > 0);
45+
r = fclose(f);
46+
ASSERT(r == 0);
47+
}
48+
va_end(vaargs);
49+
}
50+
2551
void ASSError(const char* file, uint32_t line, const char* assertStr, ...)
2652
{
2753
va_list vaargs;

Sources/Utils/Error.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,11 @@
1919
if (!(arg)) { \
2020
ASSError(__FILE__, __LINE__, str, __VA_ARGS__); \
2121
}
22-
void ASSError(const char* file, unsigned int line, const char* assertStr, ...);
22+
23+
#if 0
24+
#define AAS_MSG(str, ...) AASMsg(__FILE__, __LINE__, str, ##__VA_ARGS__)
25+
#else
26+
#define AAS_MSG(str, ...)
27+
#endif
28+
void ASSError(const char* file, unsigned int line, const char* assertStr, ...);
29+
void AASMsg(const char* file, unsigned int line, const char* msg, ...);

0 commit comments

Comments
 (0)