Using string without CRT library? Any workarounds?

277 views Asked by At

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.

1

There are 1 answers

1
kichik On

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.