如何将值存储在BYTE变量的内存中。 [英] how to store the value at the memory loaction of a BYTE variable.

查看:85
本文介绍了如何将值存储在BYTE变量的内存中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

导致错误的代码附于此处。



The code that causes error is attached here.

BOOL EncryptFile(
                PCHAR szSource, 
                PCHAR szDestination,
                BYTE* KeyBlob); 

BOOL DecryptFile(
                PCHAR szSource, 
                PCHAR szDestination,
                BYTE* KeyBlob);
int main()
{
BYTE  KeyBlob = NULL;
EncryptFile(szSource, szDestination, &KeyBlob);
DecryptFile(szDestination, szSource, &KeyBlob);
}



,KeyBLob为空,并且在函数中设置了值。如何调用keyBlob变量以便将其复制到内存位置


when the EncryptFile is returned, the KeyBLob is empty and in the function it has the value set. How to call the keyBlob variable so that it is copied to the memory location

推荐答案

这很简单,但是将界面更改为PBYTE以便澄清

it is really easy, but change the interface to PBYTE for clarification
BOOL EncryptFile(
                PBYTE szSource, 
                PBYTE szDestination,
                BYTE* KeyBlob)
{
  for( int i = 0; i < size; i++ ) {   //ensure that i is valid
    szDestination[i]  = szSource[i] & KeayBlob[i]; //some real crypto mechanism is needed
  }
} 



深入了解指针教程。提示:使用调试器运行代码


Take a dive into a good pointers tutorial. Tip: run the code with the debugger


这篇关于如何将值存储在BYTE变量的内存中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆