/del
Последнее редактирование:
if (!hLibrary)
Hello.Good day. ran into the problem below. If you don't touch anything, it works perfectly. Designed a universal good for this case. Everything works with msjboxes, open processes, etc.
But when allocating memory with VirtualAlloc, an error occurs, which is not present with a standard call. Maybe someone knows, tell me please.
C++:LPVOID(__stdcall* MyVirtualAlloc)(LPVOID, SIZE_T, DWORD, DWORD); int(__stdcall* MyMessageBoxA)(HWND, LPCSTR, LPCSTR, UINT); FARPROC LoadFunction(const char* libraryName, const char* functionName) { HMODULE hLibrary = GetModuleHandleA(libraryName); if (!hLibrary) { hLibrary = LoadLibraryA(libraryName); if (hLibrary) { return GetProcAddress(hLibrary, functionName); } } return nullptr; } void connect() { MyVirtualAlloc = reinterpret_cast<LPVOID(__stdcall*)(LPVOID, SIZE_T, DWORD, DWORD)>(LoadFunction("kernel32.dll", "VirtualAlloc")); MyMessageBoxA = reinterpret_cast<int(__stdcall*)(HWND, LPCSTR, LPCSTR, UINT)>(LoadFunction("user32.dll", "MessageBoxA")); }
Посмотреть вложение 63274
void connect() {
MyVirtualAlloc = reinterpret_cast<LPVOID(__stdcall*)(LPVOID, SIZE_T, DWORD, DWORD)>(LoadFunction("kernel32.dll", "VirtualAlloc"));
MyMessageBoxA = reinterpret_cast<int(__stdcall*)(HWND, LPCSTR, LPCSTR, UINT)>(LoadFunction("user32.dll", "MessageBoxA"));
if(!MyVirtualAlloc || !MyMessageBoxA)
{
//handle error here
return;
}
}
BOOL IsIntelHardwareBreakpointPresent(VOID)
{
BOOL bFlag = FALSE;
PCONTEXT Context = NULL;
Context = (PCONTEXT)VirtualAlloc(NULL, sizeof(CONTEXT), MEM_COMMIT, PAGE_READWRITE);
if (Context == NULL)
return FALSE;
RtlZeroMemory(Context, sizeof(Context));
Context->ContextFlags = CONTEXT_DEBUG_REGISTERS;
if (!GetThreadContext(GetCurrentThreadNoForward(), Context))
goto EXIT_ROUTINE;
if (Context->Dr0 || Context->Dr1 || Context->Dr2 || Context->Dr3)
bFlag = TRUE;
EXIT_ROUTINE:
if (Context)
VirtualFree(Context, 0, MEM_RELEASE);
return bFlag;
}
Это хорошо что ты разобрался, но, для чего удалять было вопрос и почему не напишешь решения для других пользователей?Спасибо. разобрался. не актуально.
А короче. Я просто убрал те ифы, которые не нужны.Это хорошо что ты разобрался, но, для чего удалять было вопрос и почему не напишешь решения для других пользователей?