| 1 | #include "stdafx.h" | 
|---|
| 2 |  | 
|---|
| 3 | #include <Compiler.h> | 
|---|
| 4 |  | 
|---|
| 5 | #include "common.h" | 
|---|
| 6 |  | 
|---|
| 7 | #ifdef _AMD64_ | 
|---|
| 8 | #include "../compiler_x64/opcode.h" | 
|---|
| 9 | #else | 
|---|
| 10 | #include "../compiler_x86/opcode.h" | 
|---|
| 11 | #endif | 
|---|
| 12 |  | 
|---|
| 13 | //デバッグ用 | 
|---|
| 14 | #include "debug.h" | 
|---|
| 15 |  | 
|---|
| 16 | int Debugging_GetArray( const Subscripts &subscripts,char *array,const Type &type,LONG_PTR *plpOffset); | 
|---|
| 17 |  | 
|---|
| 18 | ULONG_PTR Debugging_GetVarPtr(RELATIVE_VAR *pRelativeVar){ | 
|---|
| 19 | extern DWORD ImageBase; | 
|---|
| 20 | extern int MemPos_RWSection; | 
|---|
| 21 | int i2; | 
|---|
| 22 |  | 
|---|
| 23 | if(pRelativeVar->dwKind==VAR_GLOBAL){ | 
|---|
| 24 | return ImageBase+MemPos_RWSection+pRelativeVar->offset; | 
|---|
| 25 | } | 
|---|
| 26 | else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){ | 
|---|
| 27 | extern HANDLE hDebugProcess; | 
|---|
| 28 | LONG_PTR lpData; | 
|---|
| 29 | SIZE_T accessBytes; | 
|---|
| 30 | ReadProcessMemory(hDebugProcess, | 
|---|
| 31 | (void *)(ImageBase+MemPos_RWSection+pRelativeVar->offset), | 
|---|
| 32 | &lpData, | 
|---|
| 33 | sizeof(LONG_PTR), | 
|---|
| 34 | &accessBytes); | 
|---|
| 35 |  | 
|---|
| 36 | return lpData; | 
|---|
| 37 | } | 
|---|
| 38 | else if(pRelativeVar->dwKind==VAR_LOCAL){ | 
|---|
| 39 | extern HWND hDebugWnd; | 
|---|
| 40 | i2=(int)SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0); | 
|---|
| 41 | i2=pobj_dti->iProcLevel-i2; | 
|---|
| 42 |  | 
|---|
| 43 | if(pobj_dti->lplpSpBase[i2]==0) return 0; | 
|---|
| 44 |  | 
|---|
| 45 | return pobj_dti->lplpSpBase[i2]+pRelativeVar->offset; | 
|---|
| 46 | } | 
|---|
| 47 | else if( pRelativeVar->dwKind == VAR_REFLOCAL ){ | 
|---|
| 48 | extern HWND hDebugWnd; | 
|---|
| 49 | i2=(int)SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0); | 
|---|
| 50 | i2=pobj_dti->iProcLevel-i2; | 
|---|
| 51 |  | 
|---|
| 52 | if(pobj_dti->lplpSpBase[i2]==0) return 0; | 
|---|
| 53 |  | 
|---|
| 54 | extern HANDLE hDebugProcess; | 
|---|
| 55 | LONG_PTR lpData; | 
|---|
| 56 | SIZE_T accessBytes; | 
|---|
| 57 | ReadProcessMemory(hDebugProcess, | 
|---|
| 58 | (void *)(pobj_dti->lplpSpBase[i2]+(int)pRelativeVar->offset), | 
|---|
| 59 | &lpData, | 
|---|
| 60 | sizeof(LONG_PTR), | 
|---|
| 61 | &accessBytes); | 
|---|
| 62 |  | 
|---|
| 63 | return lpData; | 
|---|
| 64 | } | 
|---|
| 65 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){ | 
|---|
| 66 | return pRelativeVar->offset; | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | return 0; | 
|---|
| 70 | } | 
|---|
| 71 |  | 
|---|
| 72 | bool Debugging_SetRelativeOffset( Type &type,RELATIVE_VAR *pRelativeVar,char *lpPtrOffset){ | 
|---|
| 73 | int array_num; | 
|---|
| 74 |  | 
|---|
| 75 | _int64 i64data; | 
|---|
| 76 | if( !StaticCalculation( true, lpPtrOffset, 0, &i64data, Type(), 1 ) ){ | 
|---|
| 77 | return false; | 
|---|
| 78 | } | 
|---|
| 79 | if( type.IsReal() ){ | 
|---|
| 80 | double dbl; | 
|---|
| 81 | memcpy(&dbl,&i64data,sizeof(double)); | 
|---|
| 82 | i64data=(_int64)dbl; | 
|---|
| 83 | } | 
|---|
| 84 |  | 
|---|
| 85 | array_num=(int)i64data; | 
|---|
| 86 |  | 
|---|
| 87 | if( type.PtrLevel() ){ | 
|---|
| 88 | type.PtrLevelDown(); | 
|---|
| 89 | array_num *= type.GetSize(); | 
|---|
| 90 | } | 
|---|
| 91 | else{ | 
|---|
| 92 | //エラー | 
|---|
| 93 | return false; | 
|---|
| 94 | } | 
|---|
| 95 |  | 
|---|
| 96 | extern HANDLE hDebugProcess; | 
|---|
| 97 | LONG_PTR lpData; | 
|---|
| 98 | SIZE_T accessBytes; | 
|---|
| 99 | lpData=Debugging_GetVarPtr(pRelativeVar); | 
|---|
| 100 | if(!ReadProcessMemory(hDebugProcess,(void *)lpData,&pRelativeVar->offset,sizeof(LONG_PTR),&accessBytes)){ | 
|---|
| 101 | return false; | 
|---|
| 102 | } | 
|---|
| 103 | pRelativeVar->dwKind=VAR_DIRECTMEM; | 
|---|
| 104 |  | 
|---|
| 105 | pRelativeVar->offset+=array_num; | 
|---|
| 106 | return true; | 
|---|
| 107 | } | 
|---|
| 108 |  | 
|---|
| 109 | int Debugging_GetMember( const CClass &objClass,char *member,RELATIVE_VAR *pRelativeVar, Type &resultType, BOOL bPrivateAccess){ | 
|---|
| 110 | int i2; | 
|---|
| 111 |  | 
|---|
| 112 | //直接参照に切り替え | 
|---|
| 113 | pRelativeVar->offset=(LONG_PTR)Debugging_GetVarPtr(pRelativeVar); | 
|---|
| 114 | pRelativeVar->dwKind=VAR_DIRECTMEM; | 
|---|
| 115 |  | 
|---|
| 116 | //クラス、配列の構成要素を解析する | 
|---|
| 117 | char VarName[VN_SIZE];      //変数名 | 
|---|
| 118 | char array[VN_SIZE];        //第1次配列 | 
|---|
| 119 | char lpPtrOffset[VN_SIZE];  //第2次配列 | 
|---|
| 120 | char NestMember[VN_SIZE];   //入れ子メンバ | 
|---|
| 121 | ReferenceKind refType; | 
|---|
| 122 | lstrcpy(VarName,member); | 
|---|
| 123 | if(!GetVarFormatString(VarName,array,lpPtrOffset,NestMember, refType ) ) return 0; | 
|---|
| 124 |  | 
|---|
| 125 |  | 
|---|
| 126 | //////////////////////////// | 
|---|
| 127 | // メンバオフセットを取得 | 
|---|
| 128 | //////////////////////////// | 
|---|
| 129 |  | 
|---|
| 130 | const CMember *pMember = objClass.FindDynamicMember( VarName ); | 
|---|
| 131 | if( !pMember ) | 
|---|
| 132 | { | 
|---|
| 133 | return 0; | 
|---|
| 134 | } | 
|---|
| 135 |  | 
|---|
| 136 | int offset = objClass.GetMemberOffset( VarName ); | 
|---|
| 137 |  | 
|---|
| 138 |  | 
|---|
| 139 | //アクセシビリティをチェック | 
|---|
| 140 | if(( bPrivateAccess==0 && pMember->IsPrivate() )|| | 
|---|
| 141 | pMember->IsNoneAccess() ){ | 
|---|
| 142 | return 0; | 
|---|
| 143 | } | 
|---|
| 144 | else if(bPrivateAccess==0&&pMember->IsProtected()) | 
|---|
| 145 | return 0; | 
|---|
| 146 |  | 
|---|
| 147 | resultType = pMember->GetType(); | 
|---|
| 148 |  | 
|---|
| 149 | //ポインタ変数の場合 | 
|---|
| 150 | if( resultType.IsPointer() ){ | 
|---|
| 151 | if( pMember->GetSubscripts().size() == 0 ){ | 
|---|
| 152 | lstrcpy(lpPtrOffset,array); | 
|---|
| 153 | array[0]=0; | 
|---|
| 154 | } | 
|---|
| 155 | } | 
|---|
| 156 | else{ | 
|---|
| 157 | if(lpPtrOffset[0]) return 0; | 
|---|
| 158 | } | 
|---|
| 159 |  | 
|---|
| 160 | pRelativeVar->offset+=offset; | 
|---|
| 161 |  | 
|---|
| 162 | if(array[0]){ | 
|---|
| 163 | //配列オフセット | 
|---|
| 164 | i2=Debugging_GetArray( | 
|---|
| 165 | pMember->GetSubscripts(), | 
|---|
| 166 | array, | 
|---|
| 167 | resultType, | 
|---|
| 168 | &pRelativeVar->offset); | 
|---|
| 169 | if(i2==0){ | 
|---|
| 170 | //式エラー | 
|---|
| 171 | return 0; | 
|---|
| 172 | } | 
|---|
| 173 | if(i2==-1){ | 
|---|
| 174 | //アクセスエラー | 
|---|
| 175 | return -1; | 
|---|
| 176 | } | 
|---|
| 177 | } | 
|---|
| 178 | else if( pMember->GetSubscripts().size() > 0 ){ | 
|---|
| 179 | resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); | 
|---|
| 180 | } | 
|---|
| 181 |  | 
|---|
| 182 | if(NestMember[0]){ | 
|---|
| 183 | //入れ子構造の場合 | 
|---|
| 184 |  | 
|---|
| 185 | if( resultType.IsObject() || resultType.IsStruct() ){ | 
|---|
| 186 | if( refType != RefDot ) return 0; | 
|---|
| 187 |  | 
|---|
| 188 | if( resultType.IsObject() ){ | 
|---|
| 189 | extern HANDLE hDebugProcess; | 
|---|
| 190 | LONG_PTR lpData; | 
|---|
| 191 | SIZE_T accessBytes; | 
|---|
| 192 | lpData=Debugging_GetVarPtr(pRelativeVar); | 
|---|
| 193 | if(!ReadProcessMemory(hDebugProcess,(void *)lpData,&pRelativeVar->offset,sizeof(LONG_PTR),&accessBytes)) return -1; | 
|---|
| 194 | pRelativeVar->dwKind=VAR_DIRECTMEM; | 
|---|
| 195 | } | 
|---|
| 196 | } | 
|---|
| 197 | else if( resultType.IsObjectPtr() || resultType.IsStructPtr() ){ | 
|---|
| 198 | //構造体ポインタ型メンバ変数 | 
|---|
| 199 |  | 
|---|
| 200 | if(lpPtrOffset[0]){ | 
|---|
| 201 | if( refType != RefDot ) return 0; | 
|---|
| 202 |  | 
|---|
| 203 | //直接参照に切り替え | 
|---|
| 204 | Debugging_SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); | 
|---|
| 205 |  | 
|---|
| 206 | lpPtrOffset[0]=0; | 
|---|
| 207 | } | 
|---|
| 208 | else{ | 
|---|
| 209 | if( refType != RefPointer ) return 0; | 
|---|
| 210 |  | 
|---|
| 211 | extern HANDLE hDebugProcess; | 
|---|
| 212 | LONG_PTR lpData; | 
|---|
| 213 | SIZE_T accessBytes; | 
|---|
| 214 | lpData=Debugging_GetVarPtr(pRelativeVar); | 
|---|
| 215 | if(!ReadProcessMemory(hDebugProcess,(void *)lpData,&pRelativeVar->offset,sizeof(LONG_PTR),&accessBytes)) return -1; | 
|---|
| 216 | pRelativeVar->dwKind=VAR_DIRECTMEM; | 
|---|
| 217 | } | 
|---|
| 218 | } | 
|---|
| 219 |  | 
|---|
| 220 | i2=Debugging_GetMember(pMember->GetType().GetClass(), | 
|---|
| 221 | NestMember, | 
|---|
| 222 | pRelativeVar, | 
|---|
| 223 | resultType, | 
|---|
| 224 | 0); | 
|---|
| 225 | if(i2==0){ | 
|---|
| 226 | //式エラー | 
|---|
| 227 | return 0; | 
|---|
| 228 | } | 
|---|
| 229 | if(i2==-1){ | 
|---|
| 230 | //アクセスエラー | 
|---|
| 231 | return -1; | 
|---|
| 232 | } | 
|---|
| 233 | } | 
|---|
| 234 |  | 
|---|
| 235 | if(lpPtrOffset[0]){ | 
|---|
| 236 | Debugging_SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); | 
|---|
| 237 | } | 
|---|
| 238 |  | 
|---|
| 239 | return 1; | 
|---|
| 240 | } | 
|---|
| 241 | int Debugging_GetArray( const Subscripts &subscripts,char *array,const Type &type,LONG_PTR *plpOffset){ | 
|---|
| 242 | extern HANDLE hHeap; | 
|---|
| 243 | int i,i2,i3,i4,i5,array_offset; | 
|---|
| 244 | char temporary[VN_SIZE],*pParm[MAX_PARMS]; | 
|---|
| 245 |  | 
|---|
| 246 | for(i=0,i2=0,i3=0;;i++,i2++){ | 
|---|
| 247 | if(array[i]=='('){ | 
|---|
| 248 | i4=GetStringInPare(temporary+i2,array+i); | 
|---|
| 249 | i+=i4-1; | 
|---|
| 250 | i2+=i4-1; | 
|---|
| 251 | continue; | 
|---|
| 252 | } | 
|---|
| 253 | if(array[i]=='['){ | 
|---|
| 254 | i4=GetStringInBracket(temporary+i2,array+i); | 
|---|
| 255 | i+=i4-1; | 
|---|
| 256 | i2+=i4-1; | 
|---|
| 257 | continue; | 
|---|
| 258 | } | 
|---|
| 259 | if(array[i]==','||array[i]=='\0'){ | 
|---|
| 260 | if( i3 >= (int)subscripts.size() ) | 
|---|
| 261 | { | 
|---|
| 262 | for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]); | 
|---|
| 263 | return 0; | 
|---|
| 264 | } | 
|---|
| 265 |  | 
|---|
| 266 | temporary[i2]=0; | 
|---|
| 267 |  | 
|---|
| 268 | pParm[i3]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); | 
|---|
| 269 | lstrcpy(pParm[i3],temporary); | 
|---|
| 270 |  | 
|---|
| 271 | i3++; | 
|---|
| 272 |  | 
|---|
| 273 | if(array[i]=='\0'){ | 
|---|
| 274 | if( i3 < (int)subscripts.size() ) | 
|---|
| 275 | { | 
|---|
| 276 | for(i3--;i3>=0;i3--) HeapDefaultFree(pParm[i3]); | 
|---|
| 277 | return 0; | 
|---|
| 278 | } | 
|---|
| 279 | break; | 
|---|
| 280 | } | 
|---|
| 281 |  | 
|---|
| 282 | i2=-1; | 
|---|
| 283 | continue; | 
|---|
| 284 | } | 
|---|
| 285 | temporary[i2]=array[i]; | 
|---|
| 286 | } | 
|---|
| 287 |  | 
|---|
| 288 | array_offset=0; | 
|---|
| 289 |  | 
|---|
| 290 | for(i=i3-1;i>=0;i--){ | 
|---|
| 291 | _int64 i64data; | 
|---|
| 292 | Type resultType; | 
|---|
| 293 | bool isMemoryAccessError; | 
|---|
| 294 | if( !StaticCalculation(true, pParm[i],0,&i64data,resultType,1, &isMemoryAccessError ) ){ | 
|---|
| 295 | //式エラー | 
|---|
| 296 | return 0; | 
|---|
| 297 | } | 
|---|
| 298 | if(isMemoryAccessError){ | 
|---|
| 299 | //アクセスエラー | 
|---|
| 300 | return -1; | 
|---|
| 301 | } | 
|---|
| 302 |  | 
|---|
| 303 | if(resultType.IsReal()){ | 
|---|
| 304 | double dbl; | 
|---|
| 305 | memcpy(&dbl,&i64data,sizeof(double)); | 
|---|
| 306 | i64data=(_int64)dbl; | 
|---|
| 307 | } | 
|---|
| 308 | i5=(int)i64data; | 
|---|
| 309 |  | 
|---|
| 310 | for(i2=i+1,i4=1;i2<i3;i2++) i4*=subscripts[i2]+1; | 
|---|
| 311 |  | 
|---|
| 312 | array_offset+=i5*i4; | 
|---|
| 313 |  | 
|---|
| 314 | HeapDefaultFree(pParm[i]); | 
|---|
| 315 | } | 
|---|
| 316 |  | 
|---|
| 317 | array_offset *= type.GetSize(); | 
|---|
| 318 |  | 
|---|
| 319 | *plpOffset+=array_offset; | 
|---|
| 320 |  | 
|---|
| 321 | return 1; | 
|---|
| 322 | } | 
|---|
| 323 | ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip){ | 
|---|
| 324 | UserProc *pUserProc = GetSubFromObp(obp_Rip); | 
|---|
| 325 |  | 
|---|
| 326 | BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){ | 
|---|
| 327 | if( pVar->GetName() == "_System_LocalThis" ){ | 
|---|
| 328 | return pVar->GetOffsetAddress(); | 
|---|
| 329 | } | 
|---|
| 330 | } | 
|---|
| 331 | return 0; | 
|---|
| 332 | } | 
|---|
| 333 | int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts){ | 
|---|
| 334 | extern HANDLE hDebugProcess; | 
|---|
| 335 | int i2,i3; | 
|---|
| 336 | char member[VN_SIZE],VarName[VN_SIZE],array[VN_SIZE],lpPtrOffset[VN_SIZE]; | 
|---|
| 337 | LONG_PTR lpData; | 
|---|
| 338 | SIZE_T accessBytes; | 
|---|
| 339 |  | 
|---|
| 340 | lstrcpy(VarName,variable); | 
|---|
| 341 | ReferenceKind refType; | 
|---|
| 342 | GetVarFormatString(VarName,array,lpPtrOffset,member,refType); | 
|---|
| 343 |  | 
|---|
| 344 | const Subscripts *pSubscripts; | 
|---|
| 345 | bool isArray; | 
|---|
| 346 |  | 
|---|
| 347 |  | 
|---|
| 348 | ///////////////// | 
|---|
| 349 | // ローカル変数 | 
|---|
| 350 | ///////////////// | 
|---|
| 351 | if( UserProc::IsLocalAreaCompiling() ){ | 
|---|
| 352 | const Variable *pVar = UserProc::CompilingUserProc().GetLocalVars().Find( Symbol( VarName ) ); | 
|---|
| 353 |  | 
|---|
| 354 | if( pVar ){ | 
|---|
| 355 | //ポインタ変数の場合 | 
|---|
| 356 | if( pVar->GetType().IsPointer() ){ | 
|---|
| 357 | if( !pVar->IsArray() ){ | 
|---|
| 358 | lstrcpy(lpPtrOffset,array); | 
|---|
| 359 | array[0]=0; | 
|---|
| 360 | } | 
|---|
| 361 | } | 
|---|
| 362 | else{ | 
|---|
| 363 | if(lpPtrOffset[0]) return 0; | 
|---|
| 364 | } | 
|---|
| 365 |  | 
|---|
| 366 | pRelativeVar->offset = pVar->GetOffsetAddress(); | 
|---|
| 367 | if( pVar->IsRef() ){ | 
|---|
| 368 | pRelativeVar->dwKind=VAR_REFLOCAL; | 
|---|
| 369 | } | 
|---|
| 370 | else{ | 
|---|
| 371 | pRelativeVar->dwKind=VAR_LOCAL; | 
|---|
| 372 | } | 
|---|
| 373 | resultType = pVar->GetType(); | 
|---|
| 374 | isArray = pVar->IsArray(); | 
|---|
| 375 | pSubscripts = &pVar->GetSubscripts(); | 
|---|
| 376 | } | 
|---|
| 377 | } | 
|---|
| 378 |  | 
|---|
| 379 | if(compiler.pCompilingClass){ | 
|---|
| 380 | /////////////////////// | 
|---|
| 381 | // クラスメンバの参照 | 
|---|
| 382 | /////////////////////// | 
|---|
| 383 |  | 
|---|
| 384 | if(memicmp(variable,"This.",5)==0){ | 
|---|
| 385 | //Thisオブジェクトのメンバを参照するとき | 
|---|
| 386 | SlideString(variable+5,-5); | 
|---|
| 387 | lstrcpy(VarName,variable); | 
|---|
| 388 | } | 
|---|
| 389 | else{ | 
|---|
| 390 | //クラス内の動的メンバを参照するとき(通常) | 
|---|
| 391 |  | 
|---|
| 392 | if( !compiler.pCompilingClass->HasDynamicMember( VarName ) ) | 
|---|
| 393 | { | 
|---|
| 394 | goto NonClassMember; | 
|---|
| 395 | } | 
|---|
| 396 | } | 
|---|
| 397 |  | 
|---|
| 398 | ///////////////////////////// | 
|---|
| 399 | // thisポインタを取得 | 
|---|
| 400 |  | 
|---|
| 401 | extern HWND hDebugWnd; | 
|---|
| 402 | i2=(int)SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0); | 
|---|
| 403 | i2=pobj_dti->iProcLevel-i2; | 
|---|
| 404 |  | 
|---|
| 405 | lpData=Debugging_GetThisPtrOffset(pobj_dti->lplpObp[i2]); | 
|---|
| 406 | if(!lpData){ | 
|---|
| 407 | //式エラー | 
|---|
| 408 | return 0; | 
|---|
| 409 | } | 
|---|
| 410 | lpData+=pobj_dti->lplpSpBase[i2]; | 
|---|
| 411 | if(!ReadProcessMemory(hDebugProcess,(void *)lpData,&pRelativeVar->offset,sizeof(LONG_PTR),&accessBytes)){ | 
|---|
| 412 | //メモリにアクセスできないとき | 
|---|
| 413 | return -1; | 
|---|
| 414 | } | 
|---|
| 415 |  | 
|---|
| 416 | pRelativeVar->dwKind=VAR_DIRECTMEM; | 
|---|
| 417 |  | 
|---|
| 418 | i3=Debugging_GetMember(*compiler.pCompilingClass,variable,pRelativeVar,resultType,1); | 
|---|
| 419 | if(i3==0){ | 
|---|
| 420 | //式エラー | 
|---|
| 421 | return 0; | 
|---|
| 422 | } | 
|---|
| 423 | if(i3==-1){ | 
|---|
| 424 | //アクセスエラー | 
|---|
| 425 | return -1; | 
|---|
| 426 | } | 
|---|
| 427 |  | 
|---|
| 428 | return 1; | 
|---|
| 429 | } | 
|---|
| 430 |  | 
|---|
| 431 | NonClassMember: | 
|---|
| 432 |  | 
|---|
| 433 | { | 
|---|
| 434 | /////////////////// | 
|---|
| 435 | // グローバル変数 | 
|---|
| 436 | /////////////////// | 
|---|
| 437 |  | 
|---|
| 438 | const Variable *pVar = compiler.GetObjectModule().meta.GetGlobalVars().Find( VarName ); | 
|---|
| 439 | if( !pVar ){ | 
|---|
| 440 | //一致しないとき | 
|---|
| 441 | return 0; | 
|---|
| 442 | } | 
|---|
| 443 |  | 
|---|
| 444 | //ポインタ変数の場合 | 
|---|
| 445 | if( pVar->GetType().IsPointer() ){ | 
|---|
| 446 | if( !pVar->IsArray() ){ | 
|---|
| 447 | lstrcpy(lpPtrOffset,array); | 
|---|
| 448 | array[0]=0; | 
|---|
| 449 | } | 
|---|
| 450 | } | 
|---|
| 451 | else{ | 
|---|
| 452 | if(lpPtrOffset[0]) return 0; | 
|---|
| 453 | } | 
|---|
| 454 |  | 
|---|
| 455 | pRelativeVar->offset=pVar->GetOffsetAddress(); | 
|---|
| 456 | if(pVar->IsRef()) pRelativeVar->dwKind=VAR_REFGLOBAL; | 
|---|
| 457 | else pRelativeVar->dwKind=VAR_GLOBAL; | 
|---|
| 458 | resultType = pVar->GetType(); | 
|---|
| 459 | isArray = pVar->IsArray(); | 
|---|
| 460 | pSubscripts = &pVar->GetSubscripts(); | 
|---|
| 461 | } | 
|---|
| 462 |  | 
|---|
| 463 |  | 
|---|
| 464 | if(array[0]==0&&isArray){ | 
|---|
| 465 | //配列の先頭ポインタを示す場合 | 
|---|
| 466 | resultType.SetBasicType( resultType.GetBasicType() | FLAG_PTR ); | 
|---|
| 467 | if( pResultSubscripts ) | 
|---|
| 468 | { | 
|---|
| 469 | (*pResultSubscripts) = *pSubscripts; | 
|---|
| 470 | } | 
|---|
| 471 | return 1; | 
|---|
| 472 | } | 
|---|
| 473 |  | 
|---|
| 474 | if(array[0]){ | 
|---|
| 475 | i3=Debugging_GetArray( *pSubscripts, array,resultType,&pRelativeVar->offset); | 
|---|
| 476 | if(i3==0){ | 
|---|
| 477 | //式エラー | 
|---|
| 478 | return 0; | 
|---|
| 479 | } | 
|---|
| 480 | if(i3==-1){ | 
|---|
| 481 | //アクセスエラー | 
|---|
| 482 | return -1; | 
|---|
| 483 | } | 
|---|
| 484 | } | 
|---|
| 485 | if(member[0]){ | 
|---|
| 486 | if( resultType.IsObject() || resultType.IsStruct() ){ | 
|---|
| 487 | //実態オブジェクトのメンバを参照(obj.member) | 
|---|
| 488 | if( refType != RefDot ){ | 
|---|
| 489 | return 0; | 
|---|
| 490 | } | 
|---|
| 491 |  | 
|---|
| 492 | i3=Debugging_GetMember(resultType.GetClass(),member,pRelativeVar,resultType,0); | 
|---|
| 493 | if(i3==0){ | 
|---|
| 494 | //式エラー | 
|---|
| 495 | return 0; | 
|---|
| 496 | } | 
|---|
| 497 | if(i3==-1){ | 
|---|
| 498 | //アクセスエラー | 
|---|
| 499 | return -1; | 
|---|
| 500 | } | 
|---|
| 501 | } | 
|---|
| 502 | else if( resultType.IsObjectPtr() || resultType.IsStructPtr() ){ | 
|---|
| 503 | //ポインタオブジェクトが示すメンバを参照 | 
|---|
| 504 | if(lpPtrOffset[0]){ | 
|---|
| 505 | //pObj[n].member | 
|---|
| 506 | if( refType != RefDot ) return 0; | 
|---|
| 507 | Debugging_SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset); | 
|---|
| 508 |  | 
|---|
| 509 | i3=Debugging_GetMember(resultType.GetClass(),member,pRelativeVar,resultType,0); | 
|---|
| 510 | if(i3==0){ | 
|---|
| 511 | //式エラー | 
|---|
| 512 | return 0; | 
|---|
| 513 | } | 
|---|
| 514 | if(i3==-1){ | 
|---|
| 515 | //アクセスエラー | 
|---|
| 516 | return -1; | 
|---|
| 517 | } | 
|---|
| 518 | } | 
|---|
| 519 | else{ | 
|---|
| 520 | //pObj->member | 
|---|
| 521 | if( refType != RefPointer ) return 0; | 
|---|
| 522 |  | 
|---|
| 523 | pRelativeVar->offset=Debugging_GetVarPtr(pRelativeVar); | 
|---|
| 524 | pRelativeVar->dwKind=VAR_DIRECTMEM; | 
|---|
| 525 |  | 
|---|
| 526 | if(!ReadProcessMemory(hDebugProcess,(void *)pRelativeVar->offset,&lpData,sizeof(LONG_PTR),&accessBytes)) return -1; | 
|---|
| 527 | pRelativeVar->offset=lpData; | 
|---|
| 528 |  | 
|---|
| 529 | i3=Debugging_GetMember(resultType.GetClass(),member,pRelativeVar,resultType,0); | 
|---|
| 530 | if(i3==0){ | 
|---|
| 531 | //式エラー | 
|---|
| 532 | return 0; | 
|---|
| 533 | } | 
|---|
| 534 | if(i3==-1){ | 
|---|
| 535 | //アクセスエラー | 
|---|
| 536 | return -1; | 
|---|
| 537 | } | 
|---|
| 538 | } | 
|---|
| 539 | } | 
|---|
| 540 | else{ | 
|---|
| 541 | return 0; | 
|---|
| 542 | } | 
|---|
| 543 | return 1; | 
|---|
| 544 | } | 
|---|
| 545 |  | 
|---|
| 546 | if(lpPtrOffset[0]){ | 
|---|
| 547 | if(!Debugging_SetRelativeOffset(resultType,pRelativeVar,lpPtrOffset)) return 0; | 
|---|
| 548 | } | 
|---|
| 549 |  | 
|---|
| 550 | return 1; | 
|---|
| 551 | } | 
|---|