CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Aug 2013
    Posts
    3

    DLL Injection Question( Not for a malicious purpose)

    First post on these forums, I have written plenty of code for *nix systems using c. Unfortunately I never got into windows programming which leads me to my question.

    I'm attempting to write a dll injector which is already called upon by the program. So i'm not 100% sure if i need to get the proc id or not. If i do I have already found code that will do that. In short all I want this program to do is inject do one thing to a memory offset. I just want it to make it do nothing. Just a basic example or something would help. I had to dig out to offset on my own but i know its right I just don't know where to start.

    Basically the program loads dsetup.dll by default which is perfect because its not used by the program. The memory offset is 0x850BFC i just want to NULL it out so it does nothing.

    This is not for anything fishy its for a game I'm currently working on. Its an emulated game. I hope someone can help its been driving me bonkers.

    Thanks

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: DLL Injection Question( Not for a malicious purpose)

    I read this twice. And got no idea what you are after. To be helped you have to explain your problem/design in more clear/simple language. Now it sounds just gibberish.
    Best regards,
    Igor

  3. #3
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: DLL Injection Question( Not for a malicious purpose)

    The best resource for DLL injection IMO is the book 'Windows via c/c++' by Richter
    http://www.amazon.co.uk/Windows-via-...dp_ob_title_bk

    Note that earlier versions of this book also cover DLL injection and Amazon have them used from 1p!
    http://www.amazon.co.uk/Advanced-Win...5436966&sr=1-4
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: DLL Injection Question( Not for a malicious purpose)

    Is the program to which you want to inject the DLL written by you or you have the source and can recompile it? If you do then there is no need to use DLL injection, you can do this by IPC. DLL injection should be the last avenue to explore if it can't be done any other way. You also nee to be carreful about hard coded memory offsets. Just because it is currently this value on your systems doesn't mean its always this value.
    Last edited by 2kaud; August 2nd, 2013 at 05:00 AM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  5. #5
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: DLL Injection Question( Not for a malicious purpose)

    Quote Originally Posted by Brentx View Post
    This is not for anything fishy...
    It sure does sound fishy

    Quote Originally Posted by Brentx View Post
    The memory offset is 0x850BFC i just want to NULL it out so it does nothing.
    You don't need to inject your DLL for that.
    Just use WriteProcessMemory()
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  6. #6
    Join Date
    Aug 2013
    Posts
    3

    Re: DLL Injection Question( Not for a malicious purpose)

    Its actually for a Everquest emulator. I do not have the client source but the server source. Which unfortunately you can't control if the map comes on or not. Basically all I'm looking to do is inject so the map doesn't come on to better an earlier player experience. Now there is a program called Macroquest 2 which lists all the known offsets for the client. Another server already does this to prevent hacking etc we are looking to do something similiar down the road right now all we want to do is control the map.

    Its probably only about 10 lines of code. I just didn't have any knowledge of windows based programming until yesterday, its more or less a big project for a newbie. From what i'm seeing so far it looks like detours is the way to go. I'm working on it just taking me longer than it would someone else. Guess I was hoping for a quick answer.

    But one question I would like to ask you guys. This is all hypothetical can I use detours to inject at that point in memory, and put my own function in. Or even if I do that will the original data from the program still work anyways. Just need to know if I need to figure out the programs functions prototypes or not.

  7. #7
    Join Date
    Aug 2013
    Posts
    3

    Re: DLL Injection Question( Not for a malicious purpose)

    Quote Originally Posted by VladimirF View Post
    It sure does sound fishy


    You don't need to inject your DLL for that.
    Just use WriteProcessMemory()
    Thanks I'll give it a try today. Also its not fishy, its for a emu server making the game with a more classic look and feel. There was no map in the ERA we are setting the game.

  8. #8
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: DLL Injection Question( Not for a malicious purpose)

    Quote Originally Posted by VladimirF View Post
    You don't need to inject your DLL for that.
    Just use WriteProcessMemory()
    Yes, but WriteProcessMemory requires that the target process must have PROCESS_VM_WRITE and PROCESS_VM_OPERATION access.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  9. #9
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: DLL Injection Question( Not for a malicious purpose)

    Quote Originally Posted by 2kaud View Post
    Yes, but WriteProcessMemory requires that the target process must have PROCESS_VM_WRITE and PROCESS_VM_OPERATION access.
    Yes, but it's less than PROCESS_CREATE_THREAD, PROCESS_QUERY_INFORMATION, PROCESS_VM_OPERATION, PROCESS_VM_WRITE, and PROCESS_VM_READ required for dll injection
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  10. #10
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: DLL Injection Question( Not for a malicious purpose)

    Well I know that I'm injecting a thread into dll's that don't have those process accesses - so I've dusted off the cobwebs from VS6 and found some source code from way back when. The program I'm using has to run as an administrator and grabs the SeDebugPrivilege right.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  11. #11
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: DLL Injection Question( Not for a malicious purpose)

    Quote Originally Posted by 2kaud View Post
    The program I'm using has to run as an administrator and grabs the SeDebugPrivilege right.
    Then it will have no problems calling WriteProcessMemory(). Right?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  12. #12
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: DLL Injection Question( Not for a malicious purpose)

    Right. I had to figure out what I'd written all those years ago as I'd forgotten.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured