From c1dd3ae99995f5b96048563217a608c71208c52f Mon Sep 17 00:00:00 2001 From: Brady McDermott Date: Wed, 25 Oct 2023 11:49:37 -0600 Subject: [PATCH] GROUPS LOAD --- progmgr/group.c | 6 +++++- progmgr/registry.c | 13 +++++-------- progmgr/wndproc.c | 5 ----- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/progmgr/group.c b/progmgr/group.c index 4804b3c..3d6c004 100644 --- a/progmgr/group.c +++ b/progmgr/group.c @@ -77,8 +77,12 @@ BOOL InitializeGroups(VOID) if (!RegisterClassEx(&wce)) return FALSE; + + // Now we can create the groups + if(LoadConfig(FALSE, FALSE, TRUE) != RCE_SUCCESS) + return FALSE; - // TODO: go thru registry and load all saved groups here + // TODO: if loading groups fails, throw an error return TRUE; } diff --git a/progmgr/registry.c b/progmgr/registry.c index 9d2b389..02290b1 100644 --- a/progmgr/registry.c +++ b/progmgr/registry.c @@ -331,14 +331,15 @@ DWORD LoadConfig(_In_ BOOL bSettings, _In_ BOOL bPos, _In_ BOOL bGroups) while (cGroupKeys >= cGroupIndex) { WCHAR szValueName[MAX_TITLE_LENGTH] = TEXT(""); - UINT cbValueName = 0; + UINT cbValueName = sizeof(szValueName); + DWORD dwTemp = 0; // TODO: figure out where i'm really going to store the // group name, if not in the group structure then in // the name of the registry key (val 3 here) // get the size of the group - RegEnumValue(hKeyProgramGroups, cGroupIndex, (LPWSTR)szValueName, + RegEnumValue(hKeyProgramGroups, cGroupIndex, szValueName, &cbValueName, NULL, &dwType, NULL, &cbGroup); // allocate and zero memory for the group @@ -346,12 +347,8 @@ DWORD LoadConfig(_In_ BOOL bSettings, _In_ BOOL bPos, _In_ BOOL bGroups) ZeroMemory(pGroup, cbGroup); // get the group - RegQueryValueEx(hKeyProgramGroups, (LPWSTR)szValueName, NULL, - &dwType, (LPBYTE)pGroup, &cbGroup); - /* - RegGetValue(hKeyProgramGroups, NULL, (LPWSTR)szValueName, - RRF_RT_REG_BINARY, &dwType, (LPBYTE)pGroup, &cbGroup); - */ + dwTemp = RegQueryValueEx(hKeyProgramGroups, szValueName, NULL, + &dwType, pGroup, &cbGroup); // verify part of the group is valid // TODO: use checksums instead of/alongside signatures diff --git a/progmgr/wndproc.c b/progmgr/wndproc.c index 5bd99d8..79b4db9 100644 --- a/progmgr/wndproc.c +++ b/progmgr/wndproc.c @@ -35,11 +35,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_CREATE: { - // Now we can create the groups - if(LoadConfig(FALSE, FALSE, TRUE) != RCE_SUCCESS) - return FALSE; - - // TODO: if loading groups fails, throw an error return TRUE; }