小编Joh*_* P.的帖子

使用模块基址读取内存

如何读取带有模块基址的内存?例如,如何读取此内存:"winCap64.dll"+ 0x123456 +偏移量.

我已经添加了一些示例代码,说明了我在研究后可以生成的内容,但我仍然无法在C#中读取任何内容.但是地址非常好,因为当我在Cheat Engine上添加它们时它们会返回正确的值.

编辑:添加了samle代码

    [DllImport("kernel32.dll")]
    static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Boolean bInheritHandle, UInt32 dwProcessId);
    [DllImport("kernel32.dll")]
    static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress,
    byte[] lpBuffer, UIntPtr nSize, uint lpNumberOfBytesWritten);

    static IntPtr Handle;

    static void Main(string[] args)
    {
        Process[] Processes = Process.GetProcessesByName("process");
        Process nProcess = Processes[0];
        Handle = OpenProcess(0x10, false, (uint)nProcess.Id);
        IntPtr pointer = IntPtr.Add(nProcess.Modules[125].BaseAddress, 0x020C5150);
        int curhp = ReadOffset(pointer, 0x4D8);
        int curhp2 = ReadOffset((IntPtr)curhp, 0x0);
        int curhp3 = ReadOffset((IntPtr)curhp2, 0x1c0);
        Console.WriteLine(curhp3.ToString());
        Console.ReadKey();
    }

    public static int ReadOffset(IntPtr pointer, uint …
Run Code Online (Sandbox Code Playgroud)

c# memory module memory-address

14
推荐指数
1
解决办法
2904
查看次数

文件读取外来字符

我试图从.ini文件中读取外来字符.这是我正在使用的方法

[DllImport("kernel32")]
public static extern int GetPrivateProfileString(string Section, 
                                                 int Key,
                                                 string Value,
                                                 [MarshalAs(UnmanagedType.LPArray)] byte[] Result,
                                                 int Size, 
                                                 string FileName);

public static string[] GetEntryNames(string section, string iniPath)
    {
        for (int maxsize = 500; true; maxsize *= 2)
        {
            byte[] bytes = new byte[maxsize];
            int size = Imports.GetPrivateProfileString(section, 0, "", bytes, maxsize, iniPath);
            if (size < maxsize - 2)
            {
                string entries = Encoding.ASCII.GetString(bytes, 0,
                                          size - (size > 0 ? 1 : 0));
                Console.WriteLine("Entries: " + entries.Split(new char[] { '\0' })[3]); …
Run Code Online (Sandbox Code Playgroud)

c# encoding byte file char

7
推荐指数
1
解决办法
206
查看次数

使用隐藏的WindowStyle启动Process.Start url

我有一个在服务器上验证我的凭据的URL.有没有办法让它看不见?简单的代码看起来完全像这样:

public void DoAuth()
    {
        String uri = GetUri();
        ProcessStartInfo startInfo = new ProcessStartInfo(uri);
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        Process.Start(startInfo);

    }
Run Code Online (Sandbox Code Playgroud)

ProcessWindowStyle.Hidden似乎没有做到这一点.如果我设置UseShellExecute为false然后我收到Win32Exception消息The system cannot find the file specified 该url是Spotify服务器上的身份验证以获取播放列表,它看起来像这样https://accounts.spotify.com/authorize/client_id=26d287105as12315e12ds56e31491889f3cd293..

还有其他方法可以使这个过程不可见吗?

编辑:http示例

public void DoAuth()
    {
        String uri = GetUri();

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
        HttpWebResponse webResponse;
        try
        {
            webResponse = (HttpWebResponse)request.GetResponse();
            Console.WriteLine("Error code: {0}", webResponse.StatusCode);
            using (Stream data = webResponse.GetResponseStream())
            using (var reader = new StreamReader(data))
            {
                //do what here?
            }
        }
        catch (Exception e) …
Run Code Online (Sandbox Code Playgroud)

c# url styles webclient process

6
推荐指数
1
解决办法
652
查看次数

WPF ScrollBar样式

是否可以像这张图片一样创建滚动条? 在此输入图像描述

这张照片来自这个链接:http://codesdirectory.blogspot.be/2013/01/wpf-scrollviewer-control-style.html.我在帖子中尝试了这个例子但结果看起来像这样:在此输入图像描述

这个帖子是3岁,所以这可能是正常的.

是否可以像第一张图片一样创建滚动条?我一直在寻找能够找到模板的时间,这是我能得到的最接近的模板.我正在将Windows窗体应用程序转换为WPF,主要原因是滚动条!这是上面图片中的xaml:

<Window x:Class="iBlock.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="WPF ScrollViewer" SizeToContent="WidthAndHeight">

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="ScrollBar.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Grid>

        <ScrollViewer Background="#F7F7F7"

                      BorderBrush="#C7C7C7"

                      Height="300"

                      HorizontalScrollBarVisibility="Auto"

                      Margin="10"

                      Style="{DynamicResource ResourceKey=styleScrollViewer}"

                      VerticalScrollBarVisibility="Auto"

                      Width="400">

            <StackPanel Background="Red" Height="400" Width="500"></StackPanel>

        </ScrollViewer>

    </Grid>

</Window>
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml scrollbar winforms

6
推荐指数
1
解决办法
1万
查看次数

将WebClient转换为HttpClient

我正在尝试将WebClient过去用于Win7项目的A转换为HttpClientWin8.1系统上使用的A。

WenClient:

public static void PastebinSharp(string Username, string Password)
        {
            NameValueCollection IQuery = new NameValueCollection();

            IQuery.Add("api_dev_key", IDevKey);
            IQuery.Add("api_user_name", Username);
            IQuery.Add("api_user_password", Password);

            using (WebClient wc = new WebClient())
            {
                byte[] respBytes = wc.UploadValues(ILoginURL, IQuery);
                string resp = Encoding.UTF8.GetString(respBytes);

                if (resp.Contains("Bad API request"))
                {
                    throw new WebException("Bad Request", WebExceptionStatus.SendFailure);
                }
                Console.WriteLine(resp);
                //IUserKey = resp;
            }
        }
Run Code Online (Sandbox Code Playgroud)

这是我对HttpClient的第一枪

public static async Task<string> PastebinSharp(string Username, string Password)
        {
            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("api_dev_key", …
Run Code Online (Sandbox Code Playgroud)

c# webclient http httpclient request

2
推荐指数
1
解决办法
1136
查看次数