Making This Work As DLL

Posts 1–3 of 3 · Page 1 of 1
Making This Work As DLL
Ok so you've maybe seen my other thread. But now, I want to make it a DLL that you have to inject, for learning purposes. So the old code works and writes memory fine in a console application. Is there something wrong with my DLL code that'd make it not work? It injects with Winject but the effect is not apparent in game at all. I tried commenting out VirtualProtectEx just in case for some reason that might affect it, but that didn't work. Any ideas?

Code:
// main.cpp

#include "main.h"

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    if(fdwReason == DLL_PROCESS_ATTACH)
    {
        byte NoSpread[] = {
            0x74,
            0x15
        };

        byte NoRecoil[] = {
            0x75,
            0x08
        };

        HWND hWnd = FindWindow(NULL, TEXT("Call of Duty 4"));
        DWORD pId;
        GetWindowThreadProcessId(hWnd, &pId);
        HANDLE hProc = OpenProcess(PROCESS_VM_WRITE | PROCESS_VM_OPERATION, FALSE, pId);
        WriteProcessMemory(hProc, (void*)0x00416C7B, &NoSpread, 2, 0);
        WriteProcessMemory(hProc, (void*)0x0041A7BD, &NoRecoil, 2, 0);
        VirtualProtectEx(hProc, (void*)0x00416C7B, 2, 0x01, (DWORD*)&NoSpread);
        VirtualProtectEx(hProc, (void*)0x0041A7BD, 2, 0x01, (DWORD*)&NoRecoil);
        CloseHandle(hProc);
        return 0;
    }
}
Code:
// main.h

#ifndef __MAIN_H__
#define __MAIN_H__

#include <windows.h>

/*  To use this exported function of dll, include this header
 *  in your project.
 */

#ifdef BUILD_DLL
    #define DLL_EXPORT __declspec(dllexport)
#else
    #define DLL_EXPORT __declspec(dllimport)
#endif


#ifdef __cplusplus
extern "C"
{
#endif

void DLL_EXPORT SomeFunction(const LPCSTR sometext);

#ifdef __cplusplus
}
#endif

#endif // __MAIN_H__
im bored so i decided to post something

about your codez, i see bullshit here and da

Quote Originally Posted by LEGiiTxCHAOTiiC
Code:
   
        HWND hWnd = FindWindow(NULL, TEXT("Call of Duty 4"));
        DWORD pId;
        GetWindowThreadProcessId(hWnd, &pId);
        HANDLE hProc = OpenProcess(PROCESS_VM_WRITE | PROCESS_VM_OPERATION, FALSE, pId);
wow dude

Quote Originally Posted by LEGiiTxCHAOTiiC
Code:
 WriteProcessMemory(hProc, (void*)0x00416C7B, &NoSpread, 2, 0);
        WriteProcessMemory(hProc, (void*)0x0041A7BD, &NoRecoil, 2, 0);
        VirtualProtectEx(hProc, (void*)0x00416C7B, 2, 0x01, (DWORD*)&NoSpread);
        VirtualProtectEx(hProc, (void*)0x0041A7BD, 2, 0x01, (DWORD*)&NoRecoil);
whats wrong with you

however, i give your one tip
click me

now go and read a book
Quote Originally Posted by King-Orgy View Post
im bored so i decided to post something

about your codez, i see bullshit here and da



wow dude



whats wrong with you

however, i give your one tip
click me

now go and read a book
I've never worked with DLL's, and also it's just my console application code converted to DLL...
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us