我只需要了解一條單一指令,因此我需要生成這些東西。如何爲「mov」指令生成數據?
我需要在運行時使用以下彙編代碼傳遞結構(用戶定義的數據類型的對象)。
凡以下是用戶定義的數據類型,即WESContext:
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;
我創建了塊足夠大小WESContext和樣本數據填充它。
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...............
如果我通過使此作爲對象調用它:
調用Normaly: MyCallableMethodUDT(((CWESContext)pWESContext));
現在下面的程序集中,我只是在調試時從Visual Studio的Dissasembly視圖中拉出來的。
mov esi,dword ptr [pWESContext]
sub esp,58h
mov ecx,16h
mov edi,esp
rep movs dword ptr es:[edi],dword ptr [esi]
我只需要知道3號線..
AS提高我的用戶定義的結構內部成員(即這裏WESContext),它增加了,但我無法斷定它是如何增加....?我需要生成這條指令,以便無論Object是什麼以及它包含的任何大小和數據類型......它都應該通過調用上面寫的彙編指令來調用它。
問候, 烏斯曼
請格式化您的代碼! – 2010-09-30 19:00:02