interop

Capturing data from a window in a closed-source third-party Win32 application

╄→гoц情女王★ 提交于 2019-11-30 15:44:04
I'm planning on creating a C# Windows Forms app as an extension for a third-party Win32 application but I'm stumped as to how to do this right now. The farthest I've gotten is knowing it involves Win32 Hooking and that there's this open source project called EasyHook that's supposed to allow me to do this. I'd like to know how I can get the text from a textbox or some other data from a control in a third-party Win32 application. The text/data in a control is to be captured from the external application's running window the moment the user presses a button. I guess the question can be summed up

C#: marshalling a struct that contains arrays

北慕城南 提交于 2019-11-30 14:44:46
I am doing some C# interop work. I have the following struct: #pragma pack(push,1) typedef struct { unsigned __int64 Handle; LinkType_t Type; LinkState_t State; unsigned __int64 Settings; signed __int8 Name[MAX_LINK_NAME]; unsigned __int8 DeviceInfo[MAX_LINK_DEVINFO]; unsigned __int8 Reserved[40]; } LinkInfo_t; This is my attempt to convert it into a C# struct: [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct LinkInfo_t { [MarshalAs(UnmanagedType.U8)] public UInt64 Handle; MarshalAs(UnmanagedType.I4)] public LinkType_t Type; [MarshalAs(UnmanagedType.I4)] public LinkState_t State;

Asynchronous Pluggable Protocols

左心房为你撑大大i 提交于 2019-11-30 14:33:54
问题 Using this as reference, I'm trying to create an asynchronous pluggable protocol that is only temporarily available to my app (and not registered systemwide). I'm using CoInternetGetSession and then calling RegisterNameSpace to do it. However, when I make the call to RegisterNameSpace I get an AccessViolation exception: Attempting to read or write protected memory . Any idea what's going on? My code looks like this: [ComImport] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid(

Accessing Delphi DLL throwing ocasional exception

流过昼夜 提交于 2019-11-30 13:33:28
问题 When I'm calling a Dll method it sometimes throws an exception, and sometimes doesn't. I'm calling it like this: public class DllTest { [DllImport(@"MyDll.dll")] public extern static string MyMethod(string someStringParam); } class Program { static void Main(string[] args) { DllTest.MyMethod("SomeString"); } } And the exception I get sometimes is this: AccessViolationException Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Does anyone

Setting dllimport programmatically in C#

冷暖自知 提交于 2019-11-30 13:21:24
问题 I am using DllImport in my solution. My problem is that I have two versions of the same DLL one built for 32 bit and another for 64 bit. They both expose the same functions with identical names and identical signatures. My problem is that I have to use two static methods which expose these and then at run time use IntPtr size to determine the correct one to invoke. private static class Ccf_32 { [DllImport(myDllName32)] public static extern int func1(); } private static class Ccf_64 {

How to marshal a variable sized array of structs? C# and C++ interop help

孤街醉人 提交于 2019-11-30 13:15:43
问题 I have the following C++ structs struct InnerStruct { int A; int B; }; struct OuterStruct { int numberStructs; InnerStruct* innerStructs; }; And a C++ function OuterStruct getStructs(); How can I marshal this to C#? Where the C# definitions is struct OuterStruct { InnerStruct[] innerStructs; }; 回答1: You'll have to do this manually, since there's no way to tell the P/Invoke layer how much data to marshal from your C++ return value. struct OuterStruct { int numberStructs; IntPtr innerStructs; }

How to pass a typed collection from clojure to java?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 12:53:18
问题 I know the basics of clojure/java interop: calling java from clojure and vice versa. However, I was not able to return a typed collection from clojure to java. I am trying to see something of that nature List<TypedObject> from the java code which is calling into clojure. Java Object: public class TypedObject { private OtherType1 _prop1; public OtherType1 getProp1() { return _prop1; } public void setProp1(OtherType1 prop1) { _prop1 = prop1; } } CLojure method: (defn -createListOfTypedObjects

C++/CLI Resource Management Confusion

北城余情 提交于 2019-11-30 11:36:20
I am extremely confused about resource management in C++/CLI. I thought I had a handle (no pun intended) on it, but I stumbled across the auto_gcroot<T> class while looking through header files, which led to a google search, then the better part of day reading documentation, and now confusion. So I figured I'd turn to the community. My questions concern the difference between auto_handle/stack semantics, and auto_gcroot/gcroot. auto_handle: My understanding is that this will clean up a managed object created in a managed function. My confusion is that isn't the garbage collector supposed to do

How do I create an JS Object with methods and constructor in ClojureScript

扶醉桌前 提交于 2019-11-30 10:51:16
问题 Imagine the task is to create some utility lib in clojurescript so it can be used from JS. For example, let's say I want to produce an equivalent of: var Foo = function(a, b, c){ this.a = a; this.b = b; this.c = c; } Foo.prototype.bar = function(x){ return this.a + this.b + this.c + x; } var x = new Foo(1,2,3); x.bar(3); // >> 9 One way to achieve it I came with is: (deftype Foo [a b c]) (set! (.bar (.prototype Foo)) (fn [x] (this-as this (+ (.a this) (.b this) (.c this) x)))) (def x (Foo. 1

Asynchronous Pluggable Protocols

寵の児 提交于 2019-11-30 10:21:56
Using this as reference, I'm trying to create an asynchronous pluggable protocol that is only temporarily available to my app (and not registered systemwide). I'm using CoInternetGetSession and then calling RegisterNameSpace to do it. However, when I make the call to RegisterNameSpace I get an AccessViolation exception: Attempting to read or write protected memory . Any idea what's going on? My code looks like this: [ComImport] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("00000001-0000-0000-C000-000000000046")] [ComVisible(true)] public interface IClassFactory { void