Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual c++ 如何泛化“数据”;mov";指示_Visual C++_Assembly_Inline Assembly - Fatal编程技术网

Visual c++ 如何泛化“数据”;mov";指示

Visual c++ 如何泛化“数据”;mov";指示,visual-c++,assembly,inline-assembly,Visual C++,Assembly,Inline Assembly,我只需要理解一条指令,相应地,我需要泛化这些东西 我需要在运行时使用以下汇编代码传递结构(用户定义数据类型的对象) 其中,以下是用户定义的数据类型,即上下文: typedef struct CWESContext { BSTR UserName; BSTR MachineIP; BSTR Certificate; BSTR BrowserClienthandle;//Its the handle of the BrowserClient or Jav

我只需要理解一条指令,相应地,我需要泛化这些东西

我需要在运行时使用以下汇编代码传递结构(用户定义数据类型的对象)

其中,以下是用户定义的数据类型,即上下文:

 typedef struct CWESContext
 {

     BSTR UserName;
     BSTR MachineIP;
     BSTR Certificate;
     BSTR BrowserClienthandle;//Its the handle of the BrowserClient or Java Application   Level Object
     BSTR SessionID;
     BSTR TaskID;// name of the original task

     long LocaleID;//The location of the ultimate Caller
     long FeatureID;//The feature ID mapping to some feature available in WESFW
     long SessionTypeID;//Itmay be; Browser CLient Session, OPC Client Session,              Authenticated OPC Clients session(as they have more rights), WESFWSystemClient.

     SYSTEMTIME TimeStamp;//the time the original task was executed
     DWORD Priority; //task priority of the original task

     struct WESProductCategory
     {
         BSTR ProductCategoryName;
         int serialNo;

         struct WESDimensions
         {
            int weight;        
            struct WESVolume
            {
                int length;
                int heigth;
                int width;
            } oVolume;

            BSTR tempHeight;
            BSTR otherUnknownDimensions;
        } oDimensions;       
    } oWESProductCategory;
} CWESContext;
我已经创建了足够大小的块,并用示例数据填充了它

      int sizeOfWESContext = sizeof(CWESContext);

      void *pWESContext = malloc(sizeOfWESContext); 
      void *pGenericPtr = pWESContext;
      memset(pWESContext,0,sizeOfWESContext);   

      BSTR *bstrUserName = (BSTR*)pGenericPtr;
      *bstrUserName = SysAllocString(CT2OLE(CA2T(results.at(0).c_str())));
      bstrUserName++;

      pGenericPtr = bstrUserName;

      BSTR *bstrMachineIp = (BSTR*)pGenericPtr;
      *bstrMachineIp = SysAllocString(CT2OLE(CA2T(results.at(1).c_str())));
      bstrMachineIp++;

      pGenericPtr = bstrMachineIp;

      BSTR *bstrCertificate = (BSTR*)pGenericPtr;
     *bstrCertificate = SysAllocString(CT2OLE(CA2T(results.at(2).c_str())));
      bstrCertificate++;

      pGenericPtr = bstrCertificate;

            .....................
            so on so forth...............
如果我通过将此作为对象传递来调用它:

正常呼叫: MyCallableMethodUDT(((CWESContext)pWESContext))

下面是我在调试时从VisualStudio的Dissasembly视图中提取的程序集

       mov         esi,dword ptr [pWESContext]  
       sub         esp,58h  
       mov         ecx,16h  
       mov         edi,esp  
       rep movs    dword ptr es:[edi],dword ptr [esi]
我只需要理解第三行

当我在我的用户定义结构(即这里的WESContext)中增加成员时,它会增加,但我无法断定它是如何增加的。。。。?我需要泛化这个指令,这样无论对象是什么、大小和包含的数据是什么……它都应该通过上面写的编写汇编指令来调用它

问候,,
Usman

ecx
被用作第5行
rep movs
指令要复制的DWORD数的计数。它正在将数据从
esi
指向的起始地址复制到
edi
起始位置


ecx
中的值将是正在复制的数据的大小。

ecx
用作第5行
rep movs
指令要复制的DWORD数的计数。它正在将数据从
esi
指向的起始地址复制到
edi
起始位置


ecx
中的值将是正在复制的数据的大小。

请格式化您的代码!请格式化你的代码!实际上,DWORD的数量。如果PTR是
BYTE PTR
,或者指令是
MOVSB
,那么它就是字节数。但是当前的asm将组装为与
MOVSD
相同的。啊,是的,我没有注意到指令中存在DWORD PTR。修正了,实际上是DWORD的数量。如果PTR是
BYTE PTR
,或者指令是
MOVSB
,那么它就是字节数。但是当前的asm将组装为与
MOVSD
相同的。啊,是的,我没有注意到指令中存在DWORD PTR。固定的。