c - Error when writing to memory from DLL -


I am trying to change my MessageBox display to a program. I will apply a DLL injection And trying to jump on my DLL with the MessageBox function which causes my MessageBox to be displayed instead of regular one. / P>

I have written the following code which also writes the address of MessageBox and my message box in memory, I'm trying to calculate the Opododes I have to prepare already but unfortunately every time I inject DLL, I get the " Access violation " error, here is the code:

  DWORD OldProtect; PVOID MessageboxArc = GetModuleHandle ("User32.dll"), "Messagebox A"); PVID Message BoxHooksAuthor = & amp; Hookedmessage box; DWORD relJmp = (DWORD) messagebox assistant- ((DWORD) message box hooked + 5); Virtual Protote (Message Box Assistant, Size (BYTE) * 5, PAGE_EXECUTE_READWRITE, and Older Preserve); // This line precedes the small Debian method and is caused by error (PBETE Messagebox Assistant) [0] = 0xe9; (PBETE messaging) [1] = relJmp ^ 0x000000ff; (PBETE messboxbox) [2] = (relJmp ^ 0x0000ff00) & gt; & Gt; 8; (PBETE messaging) [3] = (relJmp ^ 0x00ff0000) & gt; & Gt; 16; (PBETE messaging) [4] = (relJmp ^ 0xff000000) & gt; & Gt; 24; Virtual Protocol (Message Box Assistant, Size (BYTE) * 5, PAGE_EXECUTE_READ, and Older Protected); Return 0;     

In a user 32, a function like MessageBox is not. Dll

messagebox is actually a macro that determines whether the preprocessor is based on either the MessageBoxA or MessageBoxW Flag Unicode is set.

So you can either target MessageBoxA or MessageBoxW , but GetProcAddress (.., "MessageBox" ) Will return NULL , VirtualProtect > NULL is trying to change the usage of the page on the pointer and that is why you have a Access violation is occurring.

Alternatively, you may want to use the Microsoft Detours library instead of rolling your own code.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -