Ulysse31 Posted February 17, 2015 Share Posted February 17, 2015 (edited) Hi, I'd like to point out that I did days of searching because being a newb to c++ and autoit I still got pretty far into this process. Idea was to write memory with AutoIt and nomadmemory didn't work out for me so i created my DLL in c++ and I called it, no problem so far. C++ code : DECLDIR int changeparametre(int newdata) { HWND hWnd = FindWindow(0, "Caduciel"); // Nom de la fenêtre dont vous voulez modifier les variables if (hWnd == 0) { MessageBox(0, "Erreur impossible de trouver la fenêtre.", "Erreur", MB_OK | MB_ICONERROR); } else { DWORD proccess_ID; GetWindowThreadProcessId(hWnd, &proccess_ID); HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proccess_ID); if (!hProcess) { MessageBox(0, "Erreur impossible d'ouvrir le processus!", "Erreur!", MB_OK | MB_ICONERROR); } else { int newdata = 500; // La nouvelle valeur qui remplaçera l'ancienne DWORD newdatasize = sizeof(newdata); if (WriteProcessMemory(hProcess, (LPVOID)0xF742119C, &newdata, newdatasize, NULL)) // 0x57C2A4 Correspond à l'adresse qui sera modifier { MessageBox(NULL, "Ecriture dans la mémoire à réussis.", "Réussis", MB_OK + MB_ICONINFORMATION); } else { MessageBox(NULL, "L'écriture dans la mémoire à échouer!", "Erreur", MB_OK + MB_ICONERROR); } CloseHandle(hProcess); } } return 0; } Autoit call code : $dll = DllOpen("caduciel1.dll") DllCall($dll, "none", "changeparametre", "int", 3) Header file : #ifndef _DLL_TUTORIAL_H_ #define _DLL_TUTORIAL_H_ // This is basically to tell compiler that we want to include this code only once(incase duplication occurs), you include it in .cpp file(which we will soon do) #include <iostream> // Inlcude basic c++ standard library output header(this is used for output text on the screen in our code) #include <windows.h> #define DECLDIR __declspec(dllexport) // We #define __declspec(dllexport) as DECLDIR macro so when compiler sees DECLDIR it will just take it as __declspec(dllexport)(say that DECLDIR is for readability) // Note that there is also __declspec(dllimport) for internal linking with others programs but since we just need to export our functions so we can use them with Autoit, thats all we need! extern "C" // this extern just wraps things up to make sure things work with C and not only C++ { // Here we declare our functions(as we do with normal functions in c header files, our cpp file will define them(later). Remember that DECLDIR is just a shortcut for __declspec(dllexport) DECLDIR int changeparametre(int); } #endif // closing #ifndef _DLL_TUTORIAL_H_ it does the job (edits the memory). However, the memory is correctly edited instantly and autoit is stuck "searching" 7-9 seconds after the job was done, I m wondering why and if i can change that, all help would be greatly apreciated. Computer processor is i7 4790k Edit : solved : DllCall($dll, "int:cdecl", "caduciel", "int", 3) Edited February 17, 2015 by Ulysse31 Link to comment Share on other sites More sharing options...
Solution funkey Posted February 17, 2015 Solution Share Posted February 17, 2015 Try to use the cdecl calling convention in DllCall. Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Ulysse31 Posted February 17, 2015 Author Share Posted February 17, 2015 Try to use the cdecl calling convention in DllCall. So first you help me there And now you solve my problem in less than half a second. I am starting to owe you a lot Thanks a lot, thread solved ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now