1

Here's a little code I'm working on: http://pastebin.com/92Nzc6pG

I basically inject code into a running process, but the problem is, that CRT library is no longer valid, so I can't use strings for example. Is there any workarounds for that? Rest of my program requires creating/modifying strings as well, so I really need to get this sorted out.

I managed to get it working with passing a char pointer, like this: http://pastebin.com/T1qdjfRK

However using strings is still kind of a "must" for me, so any workarounds, ideas and whatsoever are welcome.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94

1 Answers1

0

An easier way to do this would be to inject minimal code that just loads a DLL with proper imports and relocations. All of your imports are going to be satisfied by the loader once the DLL is loaded.

If you really must inject code and not a DLL for some reason, you'd have to make sure your code is compiled against the same CRT the process was compiled against. If it doesn't use CRT at all, you can use static CRT, or not use CRT at all. Windows has built-in string functions like lstrlen() and friends.

By far the simplest method is injecting an entire DLL and not just code. It will be a bit more complicated because it's two steps, but once you're fully loaded, you can do pretty much everything the same way you would have done it in your own process.

kichik
  • 33,220
  • 7
  • 94
  • 114
  • I indeed need to inject code not a DLL, but using char string instead of std::string won't be that big of a problem now that I think about it. However I still need to use some math functions from CRT lib. Luckily Visual Studio has distributed source files, so I can just directly link them in my application. Another option would be asm or numberical libraries. If anyone has the same problem, list of them can be found here: https://en.wikipedia.org/wiki/List_of_numerical_libraries –  Aug 13 '15 at 05:23