i hate this

This commit is contained in:
Brady McDermott
2023-10-28 22:15:24 -06:00
parent f1e0a17b3d
commit 7dd1875e1d
3 changed files with 40 additions and 11 deletions

View File

@@ -392,6 +392,7 @@ BOOL LoadItems(_In_ HWND hWndGroup)
\* * * */ \* * * */
BOOL RemoveItem(_In_ PITEM pi) BOOL RemoveItem(_In_ PITEM pi)
{ {
// TODO: implement this
// return NULL if we can't get to the group // return NULL if we can't get to the group
if (pi == NULL) if (pi == NULL)
return FALSE; return FALSE;
@@ -456,6 +457,40 @@ VOID UpdateGroup(_In_ PGROUP pg)
return; return;
} }
/* * * *\
VerifyGroup -
Verifies that a group contains the
correct information about itself.
ABSTRACT -
This function will check the checksum,
verify the number of items, check other
parts of the strucutre. If requested,
it will repair the group if it is damaged.
RETURNS -
TRUE if group appears to be fine
FALSE if the group is damaged
\* * * */
BOOL VerifyGroup(_In_ PGROUP pg, _In_ BOOL bRepair)
{
if (pg->dwSignature != GRP_SIGNATURE)
return FALSE;
// if (pg->wVersion != GRP_VERSION)
// some sort of version difference handling
if (pg->wChecksum == 1234)
// TODO: calculate checksum function
return FALSE;
// TODO: use ftlastwrite to throw an error
// if system clock is in the future
// calculate the size of the group based on item of numbers
// TODO: change to return a dword error value
return TRUE;
}
/* * * *\ /* * * *\
CalculateGroupMemory - CalculateGroupMemory -
Calculates the memory needed by a group. Calculates the memory needed by a group.
@@ -472,9 +507,7 @@ UINT CalculateGroupMemory(_In_ PGROUP pGroup, _In_ UINT cItems, _In_ BOOL bLean)
// first add the size of a group strucutre // first add the size of a group strucutre
cbGroupSize += sizeof(GROUP); cbGroupSize += sizeof(GROUP);
// calculate the total amount of items wanted, set // calculate the total amount of items wanted
// to 16 if there's less than 16 items so we always
// have some memory ready
cItemBlock = pGroup->cItemArray + cItems; cItemBlock = pGroup->cItemArray + cItems;
if (!bLean) if (!bLean)

View File

@@ -85,6 +85,7 @@ BOOL RemoveItem(_In_ PITEM pi);
BOOL ExecuteItem(_In_ PITEM pi); BOOL ExecuteItem(_In_ PITEM pi);
// Save/Load helper functions // Save/Load helper functions
VOID UpdateGroup(_In_ PGROUP pg); VOID UpdateGroup(_In_ PGROUP pg);
BOOL VerifyGroup(_In_ PGROUP pg, _In_ BOOL bRepair);
// Helper functions // Helper functions
UINT CalculateGroupMemory(_In_ PGROUP pGroup, _In_ UINT cItems, _In_ BOOL bLean); UINT CalculateGroupMemory(_In_ PGROUP pGroup, _In_ UINT cItems, _In_ BOOL bLean);
// Group Window // Group Window

View File

@@ -129,7 +129,7 @@ DWORD RegistrySaveGroup(_In_ PGROUP pg)
// Save group // Save group
UpdateGroup(pg); UpdateGroup(pg);
if (!RegSetValueEx(hKeyProgramGroups, pg->szName, 0, REG_BINARY, if (!RegSetValueEx(hKeyProgramGroups, pg->szName, 0, REG_BINARY,
(const BYTE*)pg, sizeof(*pg)) == ERROR_SUCCESS) (LPBYTE)pg, CalculateGroupMemory(pg, 0, 1)) == ERROR_SUCCESS)
dwConfigStatus = dwConfigStatus && RCE_GROUPS; dwConfigStatus = dwConfigStatus && RCE_GROUPS;
return dwConfigStatus; return dwConfigStatus;
@@ -148,8 +148,6 @@ DWORD RegistryLoadGroup(_Inout_ PGROUP pg, _Out_ DWORD dwBufferSize)
dwBufferSize = 0; dwBufferSize = 0;
// TODO: rethink this
// If the pointers are invalid then fail out // If the pointers are invalid then fail out
if (pg == NULL) if (pg == NULL)
return RCE_FAILURE; return RCE_FAILURE;
@@ -209,10 +207,7 @@ DWORD SaveConfig(_In_ BOOL bSettings, _In_ BOOL bPos, _In_ BOOL bGroups, _In_ BO
{ {
HWND hWndGroup = NULL; HWND hWndGroup = NULL;
// TODO: Get list of groups, iterate through, // Save each group that exists as a window
// save each one as an individual subkey based
// on the name of the group
EnumChildWindows(hWndMDIClient, &SaveWindowEnumProc, (LPARAM)bExit); EnumChildWindows(hWndMDIClient, &SaveWindowEnumProc, (LPARAM)bExit);
} }
@@ -348,7 +343,7 @@ DWORD LoadConfig(_In_ BOOL bSettings, _In_ BOOL bPos, _In_ BOOL bGroups)
// get the group // get the group
dwTemp = RegQueryValueEx(hKeyProgramGroups, szValueName, NULL, dwTemp = RegQueryValueEx(hKeyProgramGroups, szValueName, NULL,
&dwType, pGroup, &cbGroup); &dwType, (LPBYTE)pGroup, &cbGroup);
// verify part of the group is valid // verify part of the group is valid
// TODO: use checksums instead of/alongside signatures // TODO: use checksums instead of/alongside signatures