Using string without CRT library? Any workarounds? - code-injection

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.

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.

Related

Creating a custom powershell module without exposing code

I want to create a custom powershell module that I can distribute without exposing the code. The script includes API calls with app specific private keys that I don't want to compromise. I've seen a lot of discussions about this over the years, but nothing that really solves my problem.
Is there a good way to create a custom powershell module without exposing the underlying code? I want to be able to distribute the powershell module, for others to import or install.
this may be what you are looking for : https://www.powershellgallery.com/packages/ps2exe/1.0.11
but be careful, the API key will still be in the compiled file at someplace. You can try and cipher it, but if it's needed for your script, it will be in your file no matter how you try to hide it. the question is why do you need to ship it inside your script in the first place ? I mean that any of your script's user will be using your private key which is likely not what you want to do

Simple API call within the context of DocFx preprocessor

I would like to know if it is possible to make a simple API call (e.g. GitHub API v3) within the context of a DocFx custom template preprocessor. I have been trying all sorts of different approaches, but nothing has fully worked so far.
My goal is to make a call to an API to retrieve some data, and then update the model accordingly to be used in the *.liquid or *.tmpl renderers.
I have tried using the http/https node modules. I have also tried using node-fetch. It results in a docfx build error something like:
Error:Error transforming model ".../index.raw.json" generated from
".../index.md" using "conceptual.html.primary.js". Error running
Transform function inside template preprocessor
According to DocFx documentation, preprocessors follow the ES 5.1 standard. My code conforms to this.
Does anyone know if this is possible?
By the way, I am able to do simple model manipulation just fine, so I understand the basic concepts here with the DocFx preprocessors.
Thanks!
For the benefit of others, I discovered DocFX uses jint which cannot require a Node library directly. Therefore, it appears the plugin route is a better way to go for this use case.

Is it possible to send HTTP GET Requests from a Simulink Block?

basically the title says it all. I'm working on a model that needs (there is no way around it) to load data from a website, parse it and pass it onto another block. I thought I could use an S-Function written in C++, which didn't properly work, then I tried to use webread()
which also didn't work in Simulink because I can't use extrinsic functions on the device this will run on.
I thought I could work around it by downloading the file externally and then reading it through fscanfbut it turned out that Matlab CODER doesn't support that as well.
After putting 2 1/2 days into this now, I'm asking myself whether it is even possible to do something like an HTTP Request through a Simulink block. That's why I went here to ask that question. Thanks for every answer!
I figured out a way to do it with a C++ S-Function by now.
I also created a GitHub Repo for it. If you're stuck with the same problem as I was, try to take a look at this. I'm pretty sure it will help you.

Not able to call form in AEM6

I have copied the Forms from the /libs/foundation/components/form to /apps/mywebsite/components/form, I made some changes to the copied form files but still the default form is getting called.
Could you let me know or provide some documentation for the forms.
Thanks in advance
The problem is that you moved things to:
/apps/mywebsite/components/form
Instead, you need to copy them to:
/apps/foundation/components/form
apps overrides libs ONLY if the path is otherwise the same
so:
/apps/something/something/somethingelse
will override:
/libs/something/something/somethingelse
if ANY part of that path is different, that overlay won't work.
In addition, if something calls a component/resource/whatever under /libs using the fully qualified name (e.g. actually including /libs/ at the beginning) then it will still use that. But this is rare.
Let me know if you have more issues.
BTW, you can change this search approach (apps before libs) in the resource resolver settings in OSGI. It comes this way by default but can be changed.
If you didn't want to overrride but extend the foundation forms, you need to make sure that you copied everything or have the inheritance to foundation right. Most important is the cq:editConfig/cq:formParameters, where you need to have sling:resourceSuperType="foundation/components/form/defaults/field". If you use a cq:template instead, you need to set the supertype parameter there.
Then you would have to use your components on the page instead of the foundation ones.

SDL.NET (VB/C#): What should the startup object and application type be?

I eventually couldn't get any further with my program due to the various shortcomings of VB.NET (bad audio support, no reading events in the middle of execution, very weak keyboard input, etc). So I tried SDL.NET 6.1.
Despite its terrible documentation, I was able to fix my code to use it and I love it!
But there's a problem. I don't know how to set up my application settings for it. The Startup Object definitely should be a class (the examples always are in classes, never modules), but a startup class specifically has to be a form! This is bad because SDL makes its own window via SetVideoMode; you don't need a form. So when the form constructor New() finishes, a useless form is created and you have two windows.
I tried placing a call to the game engine loop within New() so that the game starts up without New() ever finishing. The game runs normally, and this solves the "second window" problem... but it can't be closed! X button does nothing, calls to Events.QuitApplication or Me.Close are blatantly ignored, etc.
I'm stumped. It seems I need to set a non-form class as the startup object, but it won't let me.
Oh, by the way, it seems that there are two things called "SDL NET". To clarify, I'm using this one, which exists in the SdlDotNet namespace.
Oh, I forgot to mention, I also noticed that a lot of the examples have a line that says "[STAThread]". Is this is important?
EDIT:
I've already received and accepted an answer for my question, but I want to tell other people what the problem is with exiting/closing the app, even though that wasn't my question:
While SDL.NET allows you to receive input and run other events without having to stop running logic, the application still cannot quit while logic is being run. So I find the best way to tell your SDL.NET application to Quit in the middle of running logic is to use the following TWO lines:
SdlDotNet.Core.Events.QuitApplication
End
Place these in the handler for the SdlDotNet.Core.Events.Quit event, as well as anywhere else you want your program to quit.
The Startup Object definitely should be a class (the examples always are in classes, never modules)
Here's your mistake. There's no real difference between a class and a VB module from CLR perspective. So just make it a module with Main and go on. There is no need for a class. I suspect you're looking at C# examples, which use classes - but that's because there is no such thing as a module in C#.
[STAThread] probably won't make any difference for SDL. It is important for UI applications (both WinForms and WPF require it), but I don't think that SDL does any COM calls, so it shouldn't care whether your thread is STA or not. It's just something that Visual Studio puts on Main in new projects by default.