Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Cant build DLL injection when assembly contain push

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
LongBeardedLion
Expert Cheater
Reputation: 0

Joined: 10 Apr 2020
Posts: 174

PostPosted: Sun May 31, 2020 6:07 pm    Post subject: Cant build DLL injection when assembly contain push Reply with quote

Is this not possible?
So basically i suceeded at compiling and injecting in many instances. The only thing that intrigues me is why in the world an assembly code injection that has push cant compile in Visual Studio.
I know this is not cheat engine related. But its General Gamehacking. And i wouldn't be anywhere near doing this if it wasn't for cheat engine.
Please help me.

I get this error:


Error C2414 illegal number of operands hook C:\Source.cpp 29

Error C2400 inline assembler syntax error in 'first operand'; found ',' hook C:\Source.cpp 29

This is the full code of my dll injection, pls skip to function void __declspec(naked) ourFunct() or line 29 to see where the error is :

PASTEBIN:

https:// pastebin. com/HGZbxcj6

Code:


Code:
#include <Windows.h>

bool Hook(void* toHook, void* ourFunct, int len) {
   if (len < 5) {
      return false;
   }

   DWORD curProtection;
   VirtualProtect(toHook, len, PAGE_EXECUTE_READWRITE, &curProtection);

   memset(toHook, 0x90, len);

   DWORD relativeAddress = ((DWORD)ourFunct - (DWORD)toHook) - 5;

   *(BYTE*)toHook = 0xE9;
   *(DWORD*)((DWORD)toHook + 1) = relativeAddress;

   DWORD temp;
   VirtualProtect(toHook, len, curProtection, &temp);

   return true;
}

DWORD jmpBackAddy;
void __declspec(naked) ourFunct() {
   __asm {
      mov ebp, dword ptr[esp + 0x10]
      xor eax, eax
      push, esi
      push, edi
   }
}

DWORD WINAPI MainThread(LPVOID param) {
   int hookLength = 8;
   DWORD hookAddress = 0x43C6E3;
   jmpBackAddy = hookAddress + hookLength;
   Hook((void*)hookAddress, ourFunct, hookLength);

   while (true) {
      if (GetAsyncKeyState(VK_ESCAPE)) break;
      Sleep(50);
   }

   FreeLibraryAndExitThread((HMODULE)param, 0);

   return 0;
}

BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) {
   switch (dwReason) {
   case DLL_PROCESS_ATTACH:
      CreateThread(0, 0, MainThread, hModule, 0, 0);
      break;
   }

   return TRUE;
}
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun May 31, 2020 7:21 pm    Post subject: Reply with quote

The syntax format is wrong, the error clearly tells you what the problem is.

I would suggest not just copy-pasting things and understand what you are doing.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
LongBeardedLion
Expert Cheater
Reputation: 0

Joined: 10 Apr 2020
Posts: 174

PostPosted: Sun May 31, 2020 7:56 pm    Post subject: Reply with quote

damn. this is embarassing. Its that little comma that shouldnt be in there.

it should be push esi. without comma.

damn. im retarded
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites