EXCEPTION_ACCESS_VIOLATION when scanning for a pattern in a C++ DLL

I'm trying to scan for a pattern to a function I found using IDA Pro, but every time I try to use FindPattern I get an ACCESS_VIOLATION_EXCEPTION on the first loop.

FindPattern Func:

DWORD FindPattern(char* module, char* pattern, char* mask)
    MODULEINFO mInfo = GetModuleInfo(module);
    DWORD base = (DWORD)mInfo.lpBaseOfDll;
    DWORD size = (DWORD)mInfo.SizeOfImage;
    DWORD patternLength = (DWORD)strlen(mask);

    for (DWORD i = 0; i < size - patternLength; i++)
        bool found = true;
        for (DWORD j = 0; j < patternLength; j++)
            found &= mask[j] == '?' || pattern[j] == *(char*)(base + i + j);
        if (found)
            return base + i;
    return NULL;

Use of the function:

    DWORD ScannedAddress = FindPattern((char*)("Program.exe"), 

I'm relatively new to C++ so I'm trying my best here, but not sure what I messed up. Only thing I can see is this warning from VS, but I read that it's just a bug in VS2019 (https://theentirecirc.us/9b62f53eabae6ba32efab72b95738c66.png (Apparently can't inline image because you need reputation)).

Exception Details: https://theentirecirc.us/69d9d52935432cc7b836f2fed504b59f.png

At the point of the exception both i and j are 0. (https://theentirecirc.us/8c1909ef75ed2cddc285ad9f45186254.png)

I then want to reroute this function using MinHook, to change the return value, but I can't seem to get the Pattern Scan working in the first place