C# pointer with offset and vaMemory.dll - c#

So I want to try to read a value from memory using a pointer with 1 offset.
These are my value:
I tried to write some code but it does not work. It only ever reads value 0 but I see on cheat engine the value i is different.
Below is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace Trigger
{
class Program
{
static void Main(string[] args)
{
VAMemory vam = new VAMemory("test");
int LocalPlayer = vam.ReadInt32((IntPtr)0x01608310);
while (true) {
int address = LocalPlayer + 0x360;
Console.Write(vam.ReadInt32((IntPtr)address));
//Thread.sleep(500);
}
}
}
}
So can someone help me to understand?

Related

UI TestStack White Get Value from a DataCell

Does anyone know how to get Vlaue from a ""DataCell(DataGridViewTextBoxCell)"?
I need to get a value from DataCell using its "Name" = "Symbol Row 0" or "RuntimeId" = "42 1966418 3 1 0"".
My current code is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TestStack.White;
using TestStack.White.Factory;
using TestStack.White.UIItems;
using TestStack.White.UIItems.Finders;
using TestStack.White.UIItems.WindowItems;
namespace UI_006
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(System.Diagnostics.Process.GetProcessesByName("program1")[0].Id);
Application application = TestStack.White.Application.Attach(System.Diagnostics.Process.GetProcessesByName("program1")[0].Id);
Window Calcwindow = application.GetWindow(SearchCriteria.ByText("toto"), InitializeOption.NoCache);
application.WaitWhileBusy();
}
}
}
My UISpy SceenShot:

Synaptics SDK can't find device

I'm attempting to grab a device handle on the Synaptics Touchpad using the Synaptics SDK, specifically using methods in the SYNCTRLLib.
However, the SYNCTRL method failed to find it, returning -1.
Syn.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SYNCOMLib;
using SYNCTRLLib;
namespace TP_Test1
{
class Syn
{
SynAPICtrl SynTP_API = new SynAPICtrl();
SynDeviceCtrl SynTP_Dev = new SynDeviceCtrl();
SynPacketCtrl SynTP_Pack = new SynPacketCtrl();
int DeviceHandle;
//Constructor
public Syn ()
{
SynTP_API.Initialize();
SynTP_API.Activate();
//DeviceHandle == -1 ? Can't find device?
DeviceHandle = SynTP_API.FindDevice(new SynConnectionType(), new SynDeviceType(), 0);
//Below line causing Unhandled Exception
SynTP_Dev.Select(DeviceHandle);
SynTP_Dev.Activate();
SynTP_Dev.OnPacket += SynTP_Dev_OnPacket;
}
public void SynTP_Dev_OnPacket()
{
Console.WriteLine(SynTP_Pack.FingerState);
Console.WriteLine(SynTP_Pack.X);
Console.WriteLine(SynTP_Pack.Y);
}
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SYNCOMLib;
using SYNCTRLLib;
namespace TP_Test1
{
class Program
{
static void Main(string[] args)
{
Syn mySyn = new Syn();
mySyn.SynTP_Dev_OnPacket();
}
}
}
I see that you are using the C# wrappers for Synaptics SDK. Even though CPP code might be not trivial to you, you might want to take a look at the file Samples/ComTest.cpp. It contains some example logic in order to find devices, more specifically at lines 66-76:
// Find a device, preferentially a TouchPad or Styk.
ISynDevice *pDevice = 0;
long lHandle = -1;
if ((pAPI->FindDevice(SE_ConnectionAny, SE_DeviceTouchPad, &lHandle) &&
pAPI->FindDevice(SE_ConnectionAny, SE_DeviceStyk, &lHandle) &&
pAPI->FindDevice(SE_ConnectionAny, SE_DeviceAny, &lHandle)) ||
pAPI->CreateDevice(lHandle, &pDevice))
{
printf("Unable to find a Synaptics Device.\n");
exit(-1);
}
Also, make sure you have registered the dlls. According to the ReadSynSDK.txt file:
For certain purposes it may be necessary to register the dlls
that are provided with the SDK. This can be done with the windows regsvr32
utility.

Create images from PDF file pages in C#

I want to get images from PDF file pages. I know that a good solution is to use ghostscriptsharp. It has a special method to get a single page or multiple pages.
GeneratePageThumbs(string inputPath, string outputPath, int firstPage, int lastPage, int width, int height)
Here is my complete code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GhostscriptSharp;
namespace GetPages
{
class Program
{
static void Main(string[] args)
{
GhostscriptWrapper.GeneratePageThumbs(#"C:\Users\User\Downloads\English_Medium_Extra_for_WEB-2.pdf",
#"C:\Users\User\Desktop\Test", 1, 3, 130, 130);
}
}
}
But when I use this method I have exception.
ExternalException
Ghostscript conversion error
So i fix this!The problem lies in the fact that 2 parameter should be the name of your image you get as a result, not a path where to save the image!
Here is the code works correctly:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GhostscriptSharp;
namespace GetPages
{
class Program
{
static void Main(string[] args)
{
GhostscriptWrapper.GeneratePageThumbs(#"C:\Users\User\Downloads\English_Medium_Extra_for_WEB-2.pdf",
"Example.png", 1, 3, 130, 130);
}
}
}
Thank you!Question is closed.
replace "Example.png" by "Example%d.png" to get all 3 Pages.

Can't use Optimization functions with ilnumerics in c#

If I am right, there is a optimization toolbox in ilnumerics. After I successfully installed ilnumerics in my project I tried to write some examples from http://ilnumerics.net/media/ILNumericsOptimizationToolboxDocumentation.pdf in it. However anytime i use * = Optimization.* there is an error, like "Optimization" is an undefinded variable. "The name 'Optimization' does not exist in the current context"
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ILNumerics;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
class Program : ILMath
{
public static ILRetArray<double> MeyerFunc(ILInArray<double> x, ILInArray<double> t)
{
using (ILScope.Enter(x, t))
{
return x[0] * exp(x[1] / (t + x[2]));
}
}
//The computation of the minimum is done as follows:
// Minimum computation:
ILArray<double> t = linspace<double>(0, 15, 16).T;
ILArray<double> ydata = array<double>(34780.0, 28610.0, 23650.0, 19630.0, 16370.0,
13720.0, 11540.0, 9744.0, 8261.0, 7030.0,
6005.0, 5147.0, 4427.0, 3820.0, 3307.0, 2872.0);
ILArray<double> x0 = array<double>(1.0, 200.0, 100.0);
Func<ILInArray<double>, ILRetArray<double>> meyerfunction = x =>
{
using (ILScope.Enter(x))
{
return MeyerFunc(x, t);
}
};
ILArray<double> xm = Optimization.optimpdl(meyerfunction, x0, ydata);
}
}
The line
ILArray<double> xopt = Optimization.optimpdl(objfunc, zeros<double>(2, 1));
is supposed to be inside the main function, not after and outside of it.

Windows 7 clipboard copy paste operation using C#

I'm working on a Windows application where I need to use clipboard data. I am trying to copy text from clipboard by the code below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace MultiValuedClipBoard
{
class Class1
{
public String SwapClipboardHtmlText(String replacementHtmlText)
{
String returnHtmlText = "hello";
if (Clipboard.ContainsText(TextDataFormat.Html))
{
returnHtmlText = Clipboard.GetText(TextDataFormat.Html);
Clipboard.SetText(replacementHtmlText, TextDataFormat.Html);
}
return returnHtmlText;
}
}
}
Calling the above function by:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;
namespace MultiValuedClipBoard
{
class Program
{
static void Main(string[] args)
{
Class1 aas = new Class1();
string a = aas.SwapClipboardHtmlText("chetan");
Console.WriteLine(a);
Console.ReadLine();
}
}
}
When running this code it gives the output "Hello" which is the default value, not clipboard data.
Your code will not work because of two reasons:
[1] When you say:
if (Clipboard.ContainsText(TextDataFormat.Html))
Here you are basically assuming that the clipboard already contains a text and that too in HTML format, but depending on the values you are setting in the clipboard it doesn't look like you are intending to use the pre-existing clipboard value anywhere in your program. So, this if condition should not be there.
[2] Secondly, you are further trying to set the string "chetan" to the clipboard which is definitely not in HTML format. So,
Clipboard.SetText(replacementHtmlText, TextDataFormat.Html);
becomes
Clipboard.SetText(replacementHtmlText, TextDataFormat.Text);
Hence, effectively, your new code becomes something like this:
String returnHtmlText = "hello";
//if (Clipboard.ContainsText(TextDataFormat.Html))
//{
returnHtmlText = Clipboard.GetText(TextDataFormat.Text);
Clipboard.SetText(replacementHtmlText, TextDataFormat.Text);
//}
return returnHtmlText;
Clearly Clipboard.ContainsText(TextDataFormat.Html) evaluates to false. Which means that the clipboard in fact does not contain text in the format you specify.
I changed your program to prove the point:
[STAThread]
static void Main(string[] args)
{
Clipboard.SetText("boo yah!", TextDataFormat.Html);
Class1 aas = new Class1();
string a = aas.SwapClipboardHtmlText("chetan");
Console.WriteLine(a);
Console.WriteLine(Clipboard.GetText(TextDataFormat.Html));
Console.ReadLine();
}
Output:
boo yah!
chetan

Categories