• Advertisement
Sign in to follow this  

Unity Going bald here!

This topic is 4486 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The community here is super! Thus far I've never been made to feel an idiot with my trivial (to you all) problems in anyones responses! Thanks! That being said... Scenario I have a program that contains a function I need to call. I only know the address of this function, but I also know the parameters it needs as well as the datatypes. Now I inject a DLL into this other program that hooks some winsock functions. Which works fine. What i'm trying to do is call the other function from within the injected DLL via an exported procedure. While hammering on this issue, the app I use to inject/uninject my DLL is where I'm calling the exported procedure contained in the injected DLL. Providing 2 parameters. Whats happening is I get: Exception: Memory Access Violation (Program tried to read/wite and invalid memory address) I'm assuming this means my app doesn't have access to the function address in the target program. I thought however since I'm injected into the target program that I (the DLL) was 'part' of the target programs address space. How can I do this? Been working on this for 2 days and am about brain dead... I just need to be able to invoke this function in the target application from my own program. Like all my issues, I'm assuming its something stupidly simple I'm overlooking. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
So, your injecting app contains the function to be called but you're trying to call it from the DLL within the target app right? If I've got that much right, then the reason is that the two processes have different address spaces. You've injected the DLL (by the way I don't know how to do that kind of thing...) but not the rest of the program. If you need to inform the injecting app of something you'll have to use IPC (I'm assuming it's not a utility function because then you could just move it into the DLL).

Share this post


Link to post
Share on other sites
The title of this thread is lacking. You'd get more help with a title more specific to your question.

What mechanism are you using to inject the dll? If you hooked a window message proc or loop, take note that you can send messages to windows in other processes and use the WM_COPYDATA message to get info back. You won't ever be able to invoke a function in another process from outside of that process. You can, along with the injected dll, insert a message handler into the message proc of the hooked window and with that in place send that window messages and so on.

Share this post


Link to post
Share on other sites
Ok, I use MadCodeHook to do the injection.

Program1 is a program that I inject into. This program has a function I need to call but have to do so by its pointer since its compiled and I dont have the source.

InjectDll is a DLL that gets injected into Program1. Its in this DLL that I export a procedure that when invoked calls the function in program1.

If you were asking if i'm doing a callback, no. Not for the function in program1.

I'm not sure how I can put in a message handler in the injected DLL. If I place a dialog in the DLL, execution of program1 halts until an event is triggerd in that form/dialog.

I can use IPC but still comes back to allowing the handler and program1 to run simultaneously.

Share this post


Link to post
Share on other sites
Quote:
Original post by PBNut
Ok, I use MadCodeHook to do the injection.


I don't know what that means. MadCodeHook? That sounds like something someone else came up with. This might help identify the approach you're using: Three Ways to Inject Your Code into Another Process.

Quote:
Original post by PBNut
Program1 is a program that I inject into. This program has a function I need to call but have to do so by its pointer since its compiled and I dont have the source.

InjectDll is a DLL that gets injected into Program1. Its in this DLL that I export a procedure that when invoked calls the function in program1.


Ok. Let's call the program that instigates the injection Program 2. When Program 2 invokes the function exported by injectdll, it does so in it's own address space, presuming of course that injectdll is also loaded into Program 2.

Quote:
Original post by PBNut
If you were asking if i'm doing a callback, no. Not for the function in program1.


Ok.

Quote:
Original post by PBNut
I'm not sure how I can put in a message handler in the injected DLL. If I place a dialog in the DLL, execution of program1 halts until an event is triggerd in that form/dialog.


The message handler can be inserted as part of the process of hooking a window in the other process. There are a variety of hooks that can be applied, a couple of them intercept messages.

Quote:
Original post by PBNut
I can use IPC but still comes back to allowing the handler and program1 to run simultaneously.


Ok.

Share this post


Link to post
Share on other sites
To add a little more to the above, code injection is not the easiest task. My advice is to start with something simple, some sample code that you know works and works well with the compiler that you regularly use. The above link provides code for MSVC. You'll probably have to google to find code that works with other compilers. Work with whichever sample you find until you get it to work for you and so that you understand how it works as well. Understanding how the mechanism works is very important because the next step after that is to adapt it to do what you want it to.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Now

  • Advertisement
  • Similar Content

    • By eldwin11929
      We're looking for programmers for our project.
      Our project is being made in Unity
      Requirements:
      -Skills in Unity
      -C#
      -Javascript
      -Node.js
      We're looking for programmers who can perform a variety of functions on our project.
      Project is a top-down hack-and-slash pvp dungeon-crawler like game. Game is entirely multiplayer based, using randomized dungeons, and a unique combat system with emphasis on gameplay.
      We have a GDD to work off of, and a Lead Programmer you would work under.
      Assignments may include:
      -Creating new scripts of varying degrees specific to the project (mostly server-side, but sometimes client-side)
      -Assembling already created monsters/characters with existing or non-existing code.
      -Creating VFX
      -Assembling already created environment models
      If interested, please contact: eldwin11929@yahoo.com
      This project is unpaid, but with royalties.
       
      ---
      Additional Project Info:
      Summary:
      Bassetune Reapers is a Player-verus-Player, competitive dungeon crawler. This basically takes on aspects of dungeon crawling, but with a more aggressive setting. Players will have the option to play as the "dungeon-crawlers" (called the 'Knights', or "Knight Class", in-game) or as the "dungeon" itself (literally called the 'Bosses', or "Boss Class", in-game). What this means is that players can choose to play as the people invading the dungeon, or as the dungeon-holders themselves.
      Key Features:
      -Intense, fast-paced combat
      -Multiple skills, weapons, and ways to play the game
      -Tons of different Bosses, Minibosses, creatures and traps to utilize throughout the dungeon
      -Multiple unique environments
      -Interesting, detailed lore behind both the game and world
      -Intricate RPG system
      -Ladder and ranking system
      -Lots of customization for both classes s of customization for both classes
    • By RoKabium Games
      Custom coffee mugs have arrived... More caffeine!
      Have a great weekend everyone! 
      #gamedev #indiedev #sama #caffeine
    • By Atwo Studios
       
      Hey guys,

      Anthony here from Atwo Studios bringing you some new updates for the new year!
      In this video I go over our game ROY, the new games and some general updates to the company!

      If you have not checked out ROY feel free to give it a try! Many people have said they enjoyed the game thus far!
      ROY: https://goo.gl/o6JJ5P
       
    • By Affgoo
      https://play.google.com/store/apps/details?id=com.NE.Alien
      still a lot of work to do, but its pretty stable  please let me know what you think <3
      Atlas Sentry is a game of destroy everything. Using your turret, simply swivel and shoot your way to victory, upgrading your weapons to unleash destruction on the variety of spaceships. The bigger your combo’s the more score you get! Earn silver as you play and then purchase new weapons and abilities to better deal with your enemy. Different enemies use different tactics and weapons, work out your own priorities in their destruction order. 

      Features: 
      **2 different game modes 
      **A level select mode with 20 difficult levels including a final boss, can you defeat it? **Arcade mode of endless destruction, how long will you last? 
      **High scores to compete against others, see who can take the top spot. 
       
    • By Chamferbox
      Chamferbox, a mini game asset store has just opened with some nice game assets, 
      Here you can find a free greek statue asset 

      Also check their dragon, zombie dragon and scorpion monster out:



      They're running the Grand Opening Sale, it's 30% off for all items, but for gamedev member, you can use this coupon code:
      GRANDOPEN
      to get 50% off prices What are you waiting for, go to
      http://chamferbox.com
      and get those models now!

      View full story
  • Advertisement