PageRenderTime 49ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/ehsvc/beaengine/Includes/Routines_ModRM.c

https://bitbucket.org/brian_/le-bypass
C | 3557 lines | 3300 code | 110 blank | 147 comment | 974 complexity | 7d9c2c5f89ca3965225ae68af97f7543 MD5 | raw file
Possible License(s): MPL-2.0, 0BSD, Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. /* Copyright 2006-2009, BeatriX
  2. * File coded by BeatriX
  3. *
  4. * This file is part of BeaEngine.
  5. *
  6. * BeaEngine is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * BeaEngine is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with BeaEngine. If not, see <http://www.gnu.org/licenses/>.
  18. * =======================================
  19. *
  20. * ======================================= */
  21. void __bea_callspec__ MOD_RM(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  22. {
  23. GV.DECALAGE_EIP = 0;
  24. if (!Security(1, pMyDisasm)) return;
  25. GV.MOD_ = ((*((UInt8*)(UIntPtr) (GV.EIP_+1))) >> 6) & 0x3;
  26. GV.RM_ = (*((UInt8*)(UIntPtr) (GV.EIP_+1))) & 0x7;
  27. if (GV.MOD_ == 0) {
  28. ModRM_0[GV.RM_](pMyArgument, pMyDisasm);
  29. }
  30. else if (GV.MOD_ == 1) {
  31. GV.DECALAGE_EIP++;
  32. ModRM_1[GV.RM_](pMyArgument, pMyDisasm);
  33. }
  34. else if (GV.MOD_ == 2) {
  35. if (GV.AddressSize >= 32) {
  36. GV.DECALAGE_EIP += 4;
  37. }
  38. else {
  39. GV.DECALAGE_EIP += 2;
  40. }
  41. ModRM_2[GV.RM_](pMyArgument, pMyDisasm);
  42. }
  43. else {
  44. ModRM_3[GV.RM_](pMyArgument, pMyDisasm);
  45. }
  46. }
  47. /* =======================================
  48. *
  49. * ======================================= */
  50. void __bea_callspec__ Reg_Opcode(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  51. {
  52. size_t i = 0;
  53. if (!Security(1, pMyDisasm)) return;
  54. GV.REGOPCODE = ((*((UInt8*)(UIntPtr) (GV.EIP_+1))) >> 3) & 0x7;
  55. if (GV.REX.R_ == 1) {
  56. GV.REGOPCODE += 0x8;
  57. }
  58. if (GV.MMX_ == 1) {
  59. #ifndef BEA_LIGHT_DISASSEMBLY
  60. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, RegistersMMX[GV.REGOPCODE]);
  61. #endif
  62. (*pMyArgument).ArgType = REGISTER_TYPE+MMX_REG+REGS[GV.REGOPCODE];
  63. (*pMyArgument).ArgSize = 64;
  64. }
  65. else if (GV.SEG_ == 1) {
  66. #ifndef BEA_LIGHT_DISASSEMBLY
  67. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, RegistersSEG[GV.REGOPCODE]);
  68. #endif
  69. (*pMyArgument).ArgType = REGISTER_TYPE+SEGMENT_REG+REGS[GV.REGOPCODE];
  70. (*pMyArgument).ArgSize = 16;
  71. }
  72. else if (GV.CR_ == 1) {
  73. #ifndef BEA_LIGHT_DISASSEMBLY
  74. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, RegistersCR[GV.REGOPCODE]);
  75. #endif
  76. (*pMyArgument).ArgType = REGISTER_TYPE+CR_REG+REGS[GV.REGOPCODE];
  77. (*pMyArgument).ArgSize = 32;
  78. }
  79. else if (GV.DR_ == 1) {
  80. if (GV.SYNTAX_ == ATSyntax) {
  81. #ifndef BEA_LIGHT_DISASSEMBLY
  82. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, RegistersDR_AT[GV.REGOPCODE]);
  83. #endif
  84. }
  85. else {
  86. #ifndef BEA_LIGHT_DISASSEMBLY
  87. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, RegistersDR[GV.REGOPCODE]);
  88. #endif
  89. }
  90. (*pMyArgument).ArgType = REGISTER_TYPE+DR_REG+REGS[GV.REGOPCODE];
  91. (*pMyArgument).ArgSize = 32;
  92. }
  93. else if (GV.SSE_ == 1) {
  94. #ifndef BEA_LIGHT_DISASSEMBLY
  95. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, RegistersSSE[GV.REGOPCODE]);
  96. #endif
  97. (*pMyArgument).ArgType = REGISTER_TYPE+SSE_REG+REGS[GV.REGOPCODE];
  98. (*pMyArgument).ArgSize = 128;
  99. }
  100. else if (GV.OperandSize == 8) {
  101. if (GV.REX.state == 0) {
  102. #ifndef BEA_LIGHT_DISASSEMBLY
  103. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers8BitsLegacy[GV.REGOPCODE]);
  104. #endif
  105. (*pMyArgument).ArgType = REGISTER_TYPE+GENERAL_REG+REGS8BITS[GV.REGOPCODE];
  106. if (GV.REGOPCODE >= 4) {
  107. (*pMyArgument).ArgPosition = HighPosition;
  108. }
  109. (*pMyArgument).ArgSize = 8;
  110. }
  111. else {
  112. #ifndef BEA_LIGHT_DISASSEMBLY
  113. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers8Bits[GV.REGOPCODE]);
  114. #endif
  115. (*pMyArgument).ArgType = REGISTER_TYPE+GENERAL_REG+REGS[GV.REGOPCODE];
  116. (*pMyArgument).ArgSize = 8;
  117. }
  118. }
  119. else if (GV.OperandSize == 16) {
  120. #ifndef BEA_LIGHT_DISASSEMBLY
  121. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers16Bits[GV.REGOPCODE]);
  122. #endif
  123. (*pMyArgument).ArgType = REGISTER_TYPE+GENERAL_REG+REGS[GV.REGOPCODE];
  124. (*pMyArgument).ArgSize = 16;
  125. }
  126. else if (GV.OperandSize == 32) {
  127. #ifndef BEA_LIGHT_DISASSEMBLY
  128. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[GV.REGOPCODE]);
  129. #endif
  130. (*pMyArgument).ArgType = REGISTER_TYPE+GENERAL_REG+REGS[GV.REGOPCODE];
  131. (*pMyArgument).ArgSize = 32;
  132. }
  133. else if (GV.OperandSize == 64) {
  134. #ifndef BEA_LIGHT_DISASSEMBLY
  135. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[GV.REGOPCODE]);
  136. #endif
  137. (*pMyArgument).ArgType = REGISTER_TYPE+GENERAL_REG+REGS[GV.REGOPCODE];
  138. (*pMyArgument).ArgSize = 64;
  139. }
  140. }
  141. /* =======================================
  142. * ModRM_0
  143. * ======================================= */
  144. void __bea_callspec__ Addr_EAX(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  145. {
  146. #ifndef BEA_LIGHT_DISASSEMBLY
  147. size_t i = 0;
  148. if (GV.SYNTAX_ == ATSyntax) {
  149. (void) strcpy((char*) (*pMyArgument).ArgMnemonic, "(%");
  150. i += 2;
  151. }
  152. #endif
  153. (*pMyArgument).ArgType = MEMORY_TYPE;
  154. if (GV.AddressSize == 64) {
  155. if (GV.REX.B_ == 1) {
  156. #ifndef BEA_LIGHT_DISASSEMBLY
  157. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[8]);
  158. #endif
  159. (*pMyArgument).Memory.BaseRegister = REGS[8];
  160. }
  161. else {
  162. #ifndef BEA_LIGHT_DISASSEMBLY
  163. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[0]);
  164. #endif
  165. (*pMyArgument).Memory.BaseRegister = REGS[0];
  166. }
  167. }
  168. else if (GV.AddressSize == 32) {
  169. if (GV.REX.B_ == 1) {
  170. #ifndef BEA_LIGHT_DISASSEMBLY
  171. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[8]);
  172. #endif
  173. (*pMyArgument).Memory.BaseRegister = REGS[8];
  174. }
  175. else {
  176. #ifndef BEA_LIGHT_DISASSEMBLY
  177. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[0]);
  178. #endif
  179. (*pMyArgument).Memory.BaseRegister = REGS[0];
  180. }
  181. }
  182. else {
  183. #ifndef BEA_LIGHT_DISASSEMBLY
  184. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BXSI_);
  185. #endif
  186. }
  187. #ifndef BEA_LIGHT_DISASSEMBLY
  188. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  189. if (GV.SYNTAX_ == ATSyntax) {
  190. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  191. i += 1;
  192. }
  193. #endif
  194. }
  195. /* =======================================
  196. *
  197. * ======================================= */
  198. void __bea_callspec__ Addr_ECX(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  199. {
  200. #ifndef BEA_LIGHT_DISASSEMBLY
  201. size_t i = 0;
  202. if (GV.SYNTAX_ == ATSyntax) {
  203. (void) strcpy((char*) (*pMyArgument).ArgMnemonic, "(%");
  204. i += 2;
  205. }
  206. #endif
  207. (*pMyArgument).ArgType = MEMORY_TYPE;
  208. if (GV.AddressSize == 64) {
  209. if (GV.REX.B_ == 1) {
  210. #ifndef BEA_LIGHT_DISASSEMBLY
  211. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[9]);
  212. #endif
  213. (*pMyArgument).Memory.BaseRegister = REGS[1+8];
  214. }
  215. else {
  216. #ifndef BEA_LIGHT_DISASSEMBLY
  217. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[1]);
  218. #endif
  219. (*pMyArgument).Memory.BaseRegister = REGS[1];
  220. }
  221. }
  222. else if (GV.AddressSize == 32) {
  223. if (GV.REX.B_ == 1) {
  224. #ifndef BEA_LIGHT_DISASSEMBLY
  225. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[9]);
  226. #endif
  227. (*pMyArgument).Memory.BaseRegister = REGS[1+8];
  228. }
  229. else {
  230. #ifndef BEA_LIGHT_DISASSEMBLY
  231. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[1]);
  232. #endif
  233. (*pMyArgument).Memory.BaseRegister = REGS[1];
  234. }
  235. }
  236. else {
  237. #ifndef BEA_LIGHT_DISASSEMBLY
  238. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BXDI_);
  239. #endif
  240. }
  241. #ifndef BEA_LIGHT_DISASSEMBLY
  242. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  243. if (GV.SYNTAX_ == ATSyntax) {
  244. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  245. i += 1;
  246. }
  247. #endif
  248. }
  249. /* =======================================
  250. *
  251. * ======================================= */
  252. void __bea_callspec__ Addr_EDX(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  253. {
  254. #ifndef BEA_LIGHT_DISASSEMBLY
  255. size_t i = 0;
  256. if (GV.SYNTAX_ == ATSyntax) {
  257. (void) strcpy((char*) (*pMyArgument).ArgMnemonic, "(%");
  258. i += 2;
  259. }
  260. #endif
  261. (*pMyArgument).ArgType = MEMORY_TYPE;
  262. if (GV.AddressSize == 64) {
  263. if (GV.REX.B_ == 1) {
  264. #ifndef BEA_LIGHT_DISASSEMBLY
  265. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[10]);
  266. #endif
  267. (*pMyArgument).Memory.BaseRegister = REGS[2+8];
  268. }
  269. else {
  270. #ifndef BEA_LIGHT_DISASSEMBLY
  271. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[2]);
  272. #endif
  273. (*pMyArgument).Memory.BaseRegister = REGS[2];
  274. }
  275. }
  276. else if (GV.AddressSize == 32) {
  277. if (GV.REX.B_ == 1) {
  278. #ifndef BEA_LIGHT_DISASSEMBLY
  279. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[10]);
  280. #endif
  281. (*pMyArgument).Memory.BaseRegister = REGS[2+8];
  282. }
  283. else {
  284. #ifndef BEA_LIGHT_DISASSEMBLY
  285. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[2]);
  286. #endif
  287. (*pMyArgument).Memory.BaseRegister = REGS[2];
  288. }
  289. }
  290. else {
  291. #ifndef BEA_LIGHT_DISASSEMBLY
  292. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BPSI_);
  293. #endif
  294. }
  295. #ifndef BEA_LIGHT_DISASSEMBLY
  296. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  297. if (GV.SYNTAX_ == ATSyntax) {
  298. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  299. i += 1;
  300. }
  301. #endif
  302. }
  303. /* =======================================
  304. *
  305. * ======================================= */
  306. void __bea_callspec__ Addr_EBX(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  307. {
  308. #ifndef BEA_LIGHT_DISASSEMBLY
  309. size_t i = 0;
  310. if (GV.SYNTAX_ == ATSyntax) {
  311. (void) strcpy((char*) (*pMyArgument).ArgMnemonic, "(%");
  312. i += 2;
  313. }
  314. #endif
  315. (*pMyArgument).ArgType = MEMORY_TYPE;
  316. if (GV.AddressSize == 64) {
  317. if (GV.REX.B_ == 1) {
  318. #ifndef BEA_LIGHT_DISASSEMBLY
  319. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[11]);
  320. #endif
  321. (*pMyArgument).Memory.BaseRegister = REGS[3+8];
  322. }
  323. else {
  324. #ifndef BEA_LIGHT_DISASSEMBLY
  325. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[3]);
  326. #endif
  327. (*pMyArgument).Memory.BaseRegister = REGS[3];
  328. }
  329. }
  330. else if (GV.AddressSize == 32) {
  331. if (GV.REX.B_ == 1) {
  332. #ifndef BEA_LIGHT_DISASSEMBLY
  333. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[11]);
  334. #endif
  335. (*pMyArgument).Memory.BaseRegister = REGS[3+8];
  336. }
  337. else {
  338. #ifndef BEA_LIGHT_DISASSEMBLY
  339. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[3]);
  340. #endif
  341. (*pMyArgument).Memory.BaseRegister = REGS[3];
  342. }
  343. }
  344. else {
  345. #ifndef BEA_LIGHT_DISASSEMBLY
  346. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BPDI_);
  347. #endif
  348. }
  349. #ifndef BEA_LIGHT_DISASSEMBLY
  350. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  351. if (GV.SYNTAX_ == ATSyntax) {
  352. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  353. i += 1;
  354. }
  355. #endif
  356. }
  357. /* =======================================
  358. *
  359. * ======================================= */
  360. void __bea_callspec__ Addr_SIB(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  361. {
  362. if (!Security(2, pMyDisasm)) return;
  363. (*pMyArgument).ArgType = MEMORY_TYPE;
  364. if (GV.AddressSize >= 32) {
  365. GV.DECALAGE_EIP++;
  366. GV.BASE_ = ((UInt8) *((UInt8*) (UIntPtr) (GV.EIP_+2))) & 0x7;
  367. GV.SCALE_ = (((UInt8) *((UInt8*) (UIntPtr)(GV.EIP_+2))) & 0xc0) >> 6;
  368. GV.INDEX_ = (((UInt8) *((UInt8*) (UIntPtr)(GV.EIP_+2))) & 0x38) >> 3;
  369. (void) SIB[GV.SCALE_ ](pMyArgument, 0, pMyDisasm);
  370. }
  371. else {
  372. #ifndef BEA_LIGHT_DISASSEMBLY
  373. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic, Registers16Bits[6]);
  374. #endif
  375. (*pMyArgument).Memory.BaseRegister = REGS[6];
  376. }
  377. }
  378. /* =======================================
  379. *
  380. * ======================================= */
  381. void __bea_callspec__ Addr_disp32(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  382. {
  383. Int32 MyNumber;
  384. UInt64 MyAddress;
  385. size_t i = 0;
  386. (*pMyArgument).ArgType = MEMORY_TYPE;
  387. if (GV.AddressSize >= 32) {
  388. if (!Security(6, pMyDisasm)) return;
  389. GV.DECALAGE_EIP+=4;
  390. MyNumber = *((Int32*)(UIntPtr) (GV.EIP_+2));
  391. (*pMyArgument).Memory.Displacement = MyNumber;
  392. if (GV.Architecture == 64) {
  393. MyNumber += 6;
  394. MyNumber += GV.NB_PREFIX;
  395. if (GV.ImmediatSize == 32) {
  396. MyNumber += 4;
  397. }
  398. if (GV.ImmediatSize == 16) {
  399. MyNumber += 2;
  400. }
  401. if (GV.ImmediatSize == 8) {
  402. MyNumber += 1;
  403. }
  404. if ((*pMyDisasm).Instruction.Opcode >= 0x0F3800) { /* add two bytes if opcode is a 3-bytes */
  405. MyNumber +=2;
  406. }
  407. else if ((*pMyDisasm).Instruction.Opcode >= 0x0100) { /* add one byte if opcode is a 2-bytes */
  408. MyNumber +=1;
  409. }
  410. CalculateRelativeAddress(&MyAddress, (Int64)MyNumber, pMyDisasm);
  411. (*pMyDisasm).Instruction.AddrValue = MyAddress;
  412. #ifndef BEA_LIGHT_DISASSEMBLY
  413. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.16llX", (Int64)MyAddress);
  414. #endif
  415. (*pMyArgument).ArgType |= RELATIVE_;
  416. }
  417. else {
  418. #ifndef BEA_LIGHT_DISASSEMBLY
  419. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.8X", (Int64)MyNumber);
  420. #endif
  421. }
  422. }
  423. else {
  424. #ifndef BEA_LIGHT_DISASSEMBLY
  425. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic, Registers16Bits[7]);
  426. #endif
  427. (*pMyArgument).Memory.BaseRegister = REGS[7];
  428. }
  429. }
  430. /* =======================================
  431. *
  432. * ======================================= */
  433. void __bea_callspec__ Addr_ESI(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  434. {
  435. long MyNumber;
  436. #ifndef BEA_LIGHT_DISASSEMBLY
  437. size_t i = 0;
  438. if (GV.SYNTAX_ == ATSyntax) {
  439. (void) strcpy((char*) (*pMyArgument).ArgMnemonic, "(%");
  440. i += 2;
  441. }
  442. #endif
  443. (*pMyArgument).ArgType = MEMORY_TYPE;
  444. if (GV.AddressSize == 64) {
  445. if (GV.REX.B_ == 1) {
  446. #ifndef BEA_LIGHT_DISASSEMBLY
  447. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[14]);
  448. #endif
  449. (*pMyArgument).Memory.BaseRegister = REGS[6+8];
  450. }
  451. else {
  452. #ifndef BEA_LIGHT_DISASSEMBLY
  453. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[6]);
  454. #endif
  455. (*pMyArgument).Memory.BaseRegister = REGS[6];
  456. }
  457. }
  458. else if (GV.AddressSize == 32) {
  459. if (GV.REX.B_ == 1) {
  460. #ifndef BEA_LIGHT_DISASSEMBLY
  461. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[14]);
  462. #endif
  463. (*pMyArgument).Memory.BaseRegister = REGS[6+8];
  464. }
  465. else {
  466. #ifndef BEA_LIGHT_DISASSEMBLY
  467. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[6]);
  468. #endif
  469. (*pMyArgument).Memory.BaseRegister = REGS[6];
  470. }
  471. }
  472. else {
  473. GV.DECALAGE_EIP+=2;
  474. MyNumber = *((UInt16*)(UIntPtr) (GV.EIP_+2));
  475. (*pMyArgument).Memory.Displacement = MyNumber;
  476. if (!Security(2, pMyDisasm)) return;
  477. #ifndef BEA_LIGHT_DISASSEMBLY
  478. (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.4X", (Int64)MyNumber);
  479. #endif
  480. }
  481. #ifndef BEA_LIGHT_DISASSEMBLY
  482. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  483. if (GV.SYNTAX_ == ATSyntax) {
  484. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  485. i += 1;
  486. }
  487. #endif
  488. }
  489. /* =======================================
  490. *
  491. * ======================================= */
  492. void __bea_callspec__ Addr_EDI(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  493. {
  494. #ifndef BEA_LIGHT_DISASSEMBLY
  495. size_t i = 0;
  496. if (GV.SYNTAX_ == ATSyntax) {
  497. (void) strcpy((char*) (*pMyArgument).ArgMnemonic, "(%");
  498. i += 2;
  499. }
  500. #endif
  501. (*pMyArgument).ArgType = MEMORY_TYPE;
  502. if (GV.AddressSize == 64) {
  503. if (GV.REX.B_ == 1) {
  504. #ifndef BEA_LIGHT_DISASSEMBLY
  505. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[15]);
  506. #endif
  507. (*pMyArgument).Memory.BaseRegister = REGS[7+8];
  508. }
  509. else {
  510. #ifndef BEA_LIGHT_DISASSEMBLY
  511. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[7]);
  512. #endif
  513. (*pMyArgument).Memory.BaseRegister = REGS[7];
  514. }
  515. }
  516. else if (GV.AddressSize == 32) {
  517. if (GV.REX.B_ == 1) {
  518. #ifndef BEA_LIGHT_DISASSEMBLY
  519. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[15]);
  520. #endif
  521. (*pMyArgument).Memory.BaseRegister = REGS[7+8];
  522. }
  523. else {
  524. #ifndef BEA_LIGHT_DISASSEMBLY
  525. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[7]);
  526. #endif
  527. (*pMyArgument).Memory.BaseRegister = REGS[7];
  528. }
  529. }
  530. else {
  531. #ifndef BEA_LIGHT_DISASSEMBLY
  532. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers16Bits[3]);
  533. #endif
  534. (*pMyArgument).Memory.BaseRegister = REGS[3];
  535. }
  536. #ifndef BEA_LIGHT_DISASSEMBLY
  537. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  538. if (GV.SYNTAX_ == ATSyntax) {
  539. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  540. i += 1;
  541. }
  542. #endif
  543. }
  544. /* =======================================
  545. * ModRM_1
  546. * ======================================= */
  547. void __bea_callspec__ Addr_EAX_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  548. {
  549. size_t i = 0, j;
  550. long MyNumber;
  551. MyNumber = *((Int8*)(UIntPtr) (GV.EIP_+2));
  552. (*pMyArgument).Memory.Displacement = MyNumber;
  553. if (GV.SYNTAX_ == ATSyntax) {
  554. if (MyNumber < 0) {
  555. #ifndef BEA_LIGHT_DISASSEMBLY
  556. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  557. #endif
  558. i++;
  559. j=i;
  560. #ifndef BEA_LIGHT_DISASSEMBLY
  561. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) ~MyNumber+1);
  562. #endif
  563. }
  564. else {
  565. j=i;
  566. #ifndef BEA_LIGHT_DISASSEMBLY
  567. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) MyNumber);
  568. #endif
  569. }
  570. #ifndef BEA_LIGHT_DISASSEMBLY
  571. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "(%");
  572. #endif
  573. i+=2;
  574. }
  575. (*pMyArgument).ArgType = MEMORY_TYPE;
  576. if (GV.AddressSize == 64) {
  577. if (GV.REX.B_ == 1) {
  578. #ifndef BEA_LIGHT_DISASSEMBLY
  579. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[8]);
  580. #endif
  581. (*pMyArgument).Memory.BaseRegister = REGS[8];
  582. }
  583. else {
  584. #ifndef BEA_LIGHT_DISASSEMBLY
  585. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[0]);
  586. #endif
  587. (*pMyArgument).Memory.BaseRegister = REGS[0];
  588. }
  589. }
  590. else if (GV.AddressSize == 32) {
  591. if (GV.REX.B_ == 1) {
  592. #ifndef BEA_LIGHT_DISASSEMBLY
  593. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[8]);
  594. #endif
  595. (*pMyArgument).Memory.BaseRegister = REGS[8];
  596. }
  597. else {
  598. #ifndef BEA_LIGHT_DISASSEMBLY
  599. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[0]);
  600. #endif
  601. (*pMyArgument).Memory.BaseRegister = REGS[0];
  602. }
  603. }
  604. else {
  605. #ifndef BEA_LIGHT_DISASSEMBLY
  606. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BXSI_);
  607. #endif
  608. }
  609. #ifndef BEA_LIGHT_DISASSEMBLY
  610. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  611. if (GV.SYNTAX_ == ATSyntax) {
  612. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  613. i += 1;
  614. }
  615. else {
  616. #else
  617. if(1) {
  618. #endif
  619. if (MyNumber < 0) {
  620. #ifndef BEA_LIGHT_DISASSEMBLY
  621. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  622. #endif
  623. i++;
  624. #ifndef BEA_LIGHT_DISASSEMBLY
  625. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) ~MyNumber+1);
  626. #endif
  627. }
  628. else {
  629. #ifndef BEA_LIGHT_DISASSEMBLY
  630. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "+");
  631. #endif
  632. i++;
  633. #ifndef BEA_LIGHT_DISASSEMBLY
  634. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) MyNumber);
  635. #endif
  636. }
  637. }
  638. }
  639. /* =======================================
  640. * ModRM_1
  641. * ======================================= */
  642. void __bea_callspec__ Addr_ECX_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  643. {
  644. size_t i = 0, j;
  645. long MyNumber;
  646. MyNumber = (Int8) *((UInt8*) (UIntPtr)GV.EIP_+2);
  647. (*pMyArgument).Memory.Displacement = MyNumber;
  648. if (GV.SYNTAX_ == ATSyntax) {
  649. if (MyNumber < 0) {
  650. #ifndef BEA_LIGHT_DISASSEMBLY
  651. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  652. #endif
  653. i++;
  654. j=i;
  655. #ifndef BEA_LIGHT_DISASSEMBLY
  656. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) ~MyNumber+1);
  657. #endif
  658. }
  659. else {
  660. j=i;
  661. #ifndef BEA_LIGHT_DISASSEMBLY
  662. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) MyNumber);
  663. #endif
  664. }
  665. #ifndef BEA_LIGHT_DISASSEMBLY
  666. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "(%");
  667. #endif
  668. i+=2;
  669. }
  670. (*pMyArgument).ArgType = MEMORY_TYPE;
  671. if (GV.AddressSize == 64) {
  672. if (GV.REX.B_ == 1) {
  673. #ifndef BEA_LIGHT_DISASSEMBLY
  674. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[9]);
  675. #endif
  676. (*pMyArgument).Memory.BaseRegister = REGS[1+8];
  677. }
  678. else {
  679. #ifndef BEA_LIGHT_DISASSEMBLY
  680. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[1]);
  681. #endif
  682. (*pMyArgument).Memory.BaseRegister = REGS[1];
  683. }
  684. }
  685. else if (GV.AddressSize == 32) {
  686. if (GV.REX.B_ == 1) {
  687. #ifndef BEA_LIGHT_DISASSEMBLY
  688. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[9]);
  689. #endif
  690. (*pMyArgument).Memory.BaseRegister = REGS[1+8];
  691. }
  692. else {
  693. #ifndef BEA_LIGHT_DISASSEMBLY
  694. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[1]);
  695. #endif
  696. (*pMyArgument).Memory.BaseRegister = REGS[1];
  697. }
  698. }
  699. else {
  700. #ifndef BEA_LIGHT_DISASSEMBLY
  701. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BXDI_);
  702. #endif
  703. }
  704. #ifndef BEA_LIGHT_DISASSEMBLY
  705. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  706. if (GV.SYNTAX_ == ATSyntax) {
  707. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  708. i += 1;
  709. }
  710. else {
  711. #else
  712. if(1) {
  713. #endif
  714. if (MyNumber < 0) {
  715. #ifndef BEA_LIGHT_DISASSEMBLY
  716. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  717. #endif
  718. i++;
  719. #ifndef BEA_LIGHT_DISASSEMBLY
  720. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) ~MyNumber+1);
  721. #endif
  722. }
  723. else {
  724. #ifndef BEA_LIGHT_DISASSEMBLY
  725. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "+");
  726. #endif
  727. i++;
  728. #ifndef BEA_LIGHT_DISASSEMBLY
  729. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) MyNumber);
  730. #endif
  731. }
  732. }
  733. }
  734. /* =======================================
  735. * ModRM_1
  736. * ======================================= */
  737. void __bea_callspec__ Addr_EDX_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  738. {
  739. size_t i = 0, j;
  740. long MyNumber;
  741. MyNumber = *((Int8*)(UIntPtr) (GV.EIP_+2));
  742. (*pMyArgument).Memory.Displacement = MyNumber;
  743. if (GV.SYNTAX_ == ATSyntax) {
  744. if (MyNumber < 0) {
  745. #ifndef BEA_LIGHT_DISASSEMBLY
  746. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  747. #endif
  748. i++;
  749. j=i;
  750. #ifndef BEA_LIGHT_DISASSEMBLY
  751. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) ~MyNumber+1);
  752. #endif
  753. }
  754. else {
  755. j=i;
  756. #ifndef BEA_LIGHT_DISASSEMBLY
  757. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) MyNumber);
  758. #endif
  759. }
  760. #ifndef BEA_LIGHT_DISASSEMBLY
  761. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "(%");
  762. #endif
  763. i+=2;
  764. }
  765. (*pMyArgument).ArgType = MEMORY_TYPE;
  766. if (GV.AddressSize == 64) {
  767. if (GV.REX.B_ == 1) {
  768. #ifndef BEA_LIGHT_DISASSEMBLY
  769. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[10]);
  770. #endif
  771. (*pMyArgument).Memory.BaseRegister = REGS[2+8];
  772. }
  773. else {
  774. #ifndef BEA_LIGHT_DISASSEMBLY
  775. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[2]);
  776. #endif
  777. (*pMyArgument).Memory.BaseRegister = REGS[2];
  778. }
  779. }
  780. else if (GV.AddressSize == 32) {
  781. if (GV.REX.B_ == 1) {
  782. #ifndef BEA_LIGHT_DISASSEMBLY
  783. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[10]);
  784. #endif
  785. (*pMyArgument).Memory.BaseRegister = REGS[2+8];
  786. }
  787. else {
  788. #ifndef BEA_LIGHT_DISASSEMBLY
  789. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[2]);
  790. #endif
  791. (*pMyArgument).Memory.BaseRegister = REGS[2];
  792. }
  793. }
  794. else {
  795. #ifndef BEA_LIGHT_DISASSEMBLY
  796. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BPSI_);
  797. #endif
  798. }
  799. #ifndef BEA_LIGHT_DISASSEMBLY
  800. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  801. if (GV.SYNTAX_ == ATSyntax) {
  802. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  803. i += 1;
  804. }
  805. else {
  806. #else
  807. if(1) {
  808. #endif
  809. if (MyNumber < 0) {
  810. #ifndef BEA_LIGHT_DISASSEMBLY
  811. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  812. #endif
  813. i++;
  814. #ifndef BEA_LIGHT_DISASSEMBLY
  815. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) ~MyNumber+1);
  816. #endif
  817. }
  818. else {
  819. #ifndef BEA_LIGHT_DISASSEMBLY
  820. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "+");
  821. #endif
  822. i++;
  823. #ifndef BEA_LIGHT_DISASSEMBLY
  824. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) MyNumber);
  825. #endif
  826. }
  827. }
  828. }
  829. /* =======================================
  830. * ModRM_1
  831. * ======================================= */
  832. void __bea_callspec__ Addr_EBX_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  833. {
  834. size_t i = 0, j;
  835. long MyNumber;
  836. MyNumber = *((Int8*)(UIntPtr) (GV.EIP_+2));
  837. (*pMyArgument).Memory.Displacement = MyNumber;
  838. if (GV.SYNTAX_ == ATSyntax) {
  839. if (MyNumber < 0) {
  840. #ifndef BEA_LIGHT_DISASSEMBLY
  841. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  842. #endif
  843. i++;
  844. j=i;
  845. #ifndef BEA_LIGHT_DISASSEMBLY
  846. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) ~MyNumber+1);
  847. #endif
  848. }
  849. else {
  850. j=i;
  851. #ifndef BEA_LIGHT_DISASSEMBLY
  852. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) MyNumber);
  853. #endif
  854. }
  855. #ifndef BEA_LIGHT_DISASSEMBLY
  856. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "(%");
  857. #endif
  858. i+=2;
  859. }
  860. (*pMyArgument).ArgType = MEMORY_TYPE;
  861. if (GV.AddressSize == 64) {
  862. if (GV.REX.B_ == 1) {
  863. #ifndef BEA_LIGHT_DISASSEMBLY
  864. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[11]);
  865. #endif
  866. (*pMyArgument).Memory.BaseRegister = REGS[3+8];
  867. }
  868. else {
  869. #ifndef BEA_LIGHT_DISASSEMBLY
  870. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[3]);
  871. #endif
  872. (*pMyArgument).Memory.BaseRegister = REGS[3];
  873. }
  874. }
  875. else if (GV.AddressSize == 32) {
  876. if (GV.REX.B_ == 1) {
  877. #ifndef BEA_LIGHT_DISASSEMBLY
  878. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[11]);
  879. #endif
  880. (*pMyArgument).Memory.BaseRegister = REGS[3+8];
  881. }
  882. else {
  883. #ifndef BEA_LIGHT_DISASSEMBLY
  884. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[3]);
  885. #endif
  886. (*pMyArgument).Memory.BaseRegister = REGS[3];
  887. }
  888. }
  889. else {
  890. #ifndef BEA_LIGHT_DISASSEMBLY
  891. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BPDI_);
  892. #endif
  893. }
  894. #ifndef BEA_LIGHT_DISASSEMBLY
  895. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  896. if (GV.SYNTAX_ == ATSyntax) {
  897. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  898. i += 1;
  899. }
  900. else {
  901. #else
  902. if(1) {
  903. #endif
  904. if (MyNumber < 0) {
  905. #ifndef BEA_LIGHT_DISASSEMBLY
  906. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  907. #endif
  908. i++;
  909. #ifndef BEA_LIGHT_DISASSEMBLY
  910. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) ~MyNumber+1);
  911. #endif
  912. }
  913. else {
  914. #ifndef BEA_LIGHT_DISASSEMBLY
  915. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "+");
  916. #endif
  917. i++;
  918. #ifndef BEA_LIGHT_DISASSEMBLY
  919. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) MyNumber);
  920. #endif
  921. }
  922. }
  923. }
  924. /* =======================================
  925. *
  926. * ======================================= */
  927. void __bea_callspec__ Addr_SIB_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  928. {
  929. size_t i = 0, j;
  930. long MyNumber;
  931. if (!Security(2, pMyDisasm)) return;
  932. if (GV.AddressSize >= 32) {
  933. MyNumber = *((Int8*)(UIntPtr) (GV.EIP_+3));
  934. }
  935. else {
  936. MyNumber = *((Int8*)(UIntPtr) (GV.EIP_+2));
  937. }
  938. (*pMyArgument).Memory.Displacement = MyNumber;
  939. if (GV.SYNTAX_ == ATSyntax) {
  940. if (MyNumber < 0) {
  941. #ifndef BEA_LIGHT_DISASSEMBLY
  942. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  943. #endif
  944. i++;
  945. j=i;
  946. #ifndef BEA_LIGHT_DISASSEMBLY
  947. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) ~MyNumber+1);
  948. #endif
  949. }
  950. else {
  951. j=i;
  952. #ifndef BEA_LIGHT_DISASSEMBLY
  953. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) MyNumber);
  954. #endif
  955. }
  956. /*#ifndef BEA_LIGHT_DISASSEMBLY
  957. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "(%");
  958. #endif
  959. *i+=2; */
  960. }
  961. (*pMyArgument).ArgType = MEMORY_TYPE;
  962. if (GV.AddressSize >= 32) {
  963. GV.DECALAGE_EIP++;
  964. GV.BASE_ = (*((UInt8*)(UIntPtr) (GV.EIP_+2))) & 0x7;
  965. GV.SCALE_ = ((*((UInt8*)(UIntPtr) (GV.EIP_+2))) & 0xc0) >> 6;
  966. GV.INDEX_ = ((*((UInt8*)(UIntPtr) (GV.EIP_+2))) & 0x38) >> 3;
  967. j = i;
  968. i += SIB[GV.SCALE_ ](pMyArgument, j, pMyDisasm);
  969. }
  970. else {
  971. #ifndef BEA_LIGHT_DISASSEMBLY
  972. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic, Registers16Bits[6]);
  973. #endif
  974. i += strlen (Registers16Bits[6]);
  975. }
  976. if (GV.SYNTAX_ == ATSyntax) {
  977. #ifndef BEA_LIGHT_DISASSEMBLY
  978. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  979. #endif
  980. i++;
  981. }
  982. else {
  983. if (MyNumber < 0) {
  984. #ifndef BEA_LIGHT_DISASSEMBLY
  985. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  986. #endif
  987. i++;
  988. #ifndef BEA_LIGHT_DISASSEMBLY
  989. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) ~MyNumber+1);
  990. #endif
  991. }
  992. else {
  993. #ifndef BEA_LIGHT_DISASSEMBLY
  994. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "+");
  995. #endif
  996. i++;
  997. #ifndef BEA_LIGHT_DISASSEMBLY
  998. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) MyNumber);
  999. #endif
  1000. }
  1001. }
  1002. }
  1003. /* =======================================
  1004. * ModRM_1
  1005. * ======================================= */
  1006. void __bea_callspec__ Addr_EBP_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  1007. {
  1008. size_t i = 0, j;
  1009. long MyNumber;
  1010. MyNumber = *((Int8*)(UIntPtr) (GV.EIP_+2));
  1011. (*pMyArgument).Memory.Displacement = MyNumber;
  1012. if (GV.SYNTAX_ == ATSyntax) {
  1013. if (MyNumber < 0) {
  1014. #ifndef BEA_LIGHT_DISASSEMBLY
  1015. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  1016. #endif
  1017. i++;
  1018. j=i;
  1019. #ifndef BEA_LIGHT_DISASSEMBLY
  1020. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) ~MyNumber+1);
  1021. #endif
  1022. }
  1023. else {
  1024. j=i;
  1025. #ifndef BEA_LIGHT_DISASSEMBLY
  1026. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) MyNumber);
  1027. #endif
  1028. }
  1029. #ifndef BEA_LIGHT_DISASSEMBLY
  1030. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "(%");
  1031. #endif
  1032. i+=2;
  1033. }
  1034. (*pMyArgument).ArgType = MEMORY_TYPE;
  1035. if (GV.AddressSize == 64) {
  1036. if (GV.REX.B_ == 1) {
  1037. #ifndef BEA_LIGHT_DISASSEMBLY
  1038. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[13]);
  1039. #endif
  1040. (*pMyArgument).Memory.BaseRegister = REGS[5+8];
  1041. }
  1042. else {
  1043. #ifndef BEA_LIGHT_DISASSEMBLY
  1044. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[5]);
  1045. #endif
  1046. (*pMyArgument).Memory.BaseRegister = REGS[5];
  1047. }
  1048. }
  1049. else if (GV.AddressSize == 32) {
  1050. if (GV.REX.B_ == 1) {
  1051. #ifndef BEA_LIGHT_DISASSEMBLY
  1052. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[13]);
  1053. #endif
  1054. (*pMyArgument).Memory.BaseRegister = REGS[5+8];
  1055. }
  1056. else {
  1057. #ifndef BEA_LIGHT_DISASSEMBLY
  1058. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[5]);
  1059. #endif
  1060. (*pMyArgument).Memory.BaseRegister = REGS[5];
  1061. }
  1062. }
  1063. else {
  1064. #ifndef BEA_LIGHT_DISASSEMBLY
  1065. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers16Bits[7]);
  1066. #endif
  1067. (*pMyArgument).Memory.BaseRegister = REGS[7];
  1068. }
  1069. #ifndef BEA_LIGHT_DISASSEMBLY
  1070. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  1071. if (GV.SYNTAX_ == ATSyntax) {
  1072. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  1073. i += 1;
  1074. }
  1075. else {
  1076. #else
  1077. if(1) {
  1078. #endif
  1079. if (MyNumber < 0) {
  1080. #ifndef BEA_LIGHT_DISASSEMBLY
  1081. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  1082. #endif
  1083. i++;
  1084. #ifndef BEA_LIGHT_DISASSEMBLY
  1085. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) ~MyNumber+1);
  1086. #endif
  1087. }
  1088. else {
  1089. #ifndef BEA_LIGHT_DISASSEMBLY
  1090. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "+");
  1091. #endif
  1092. i++;
  1093. #ifndef BEA_LIGHT_DISASSEMBLY
  1094. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) MyNumber);
  1095. #endif
  1096. }
  1097. }
  1098. }
  1099. /* =======================================
  1100. * ModRM_1
  1101. * ======================================= */
  1102. void __bea_callspec__ Addr_ESI_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  1103. {
  1104. size_t i = 0, j;
  1105. long MyNumber;
  1106. MyNumber = *((Int8*)(UIntPtr) (GV.EIP_+2));
  1107. (*pMyArgument).Memory.Displacement = MyNumber;
  1108. if (GV.SYNTAX_ == ATSyntax) {
  1109. if (MyNumber < 0) {
  1110. #ifndef BEA_LIGHT_DISASSEMBLY
  1111. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  1112. #endif
  1113. i++;
  1114. j=i;
  1115. #ifndef BEA_LIGHT_DISASSEMBLY
  1116. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) ~MyNumber+1);
  1117. #endif
  1118. }
  1119. else {
  1120. j=i;
  1121. #ifndef BEA_LIGHT_DISASSEMBLY
  1122. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) MyNumber);
  1123. #endif
  1124. }
  1125. #ifndef BEA_LIGHT_DISASSEMBLY
  1126. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "(%");
  1127. #endif
  1128. i+=2;
  1129. }
  1130. (*pMyArgument).ArgType = MEMORY_TYPE;
  1131. if (GV.AddressSize == 64) {
  1132. if (GV.REX.B_ == 1) {
  1133. #ifndef BEA_LIGHT_DISASSEMBLY
  1134. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[14]);
  1135. #endif
  1136. (*pMyArgument).Memory.BaseRegister = REGS[6+8];
  1137. }
  1138. else {
  1139. #ifndef BEA_LIGHT_DISASSEMBLY
  1140. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[6]);
  1141. #endif
  1142. (*pMyArgument).Memory.BaseRegister = REGS[6];
  1143. }
  1144. }
  1145. else if (GV.AddressSize == 32) {
  1146. if (GV.REX.B_ == 1) {
  1147. #ifndef BEA_LIGHT_DISASSEMBLY
  1148. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[14]);
  1149. #endif
  1150. (*pMyArgument).Memory.BaseRegister = REGS[6+8];
  1151. }
  1152. else {
  1153. #ifndef BEA_LIGHT_DISASSEMBLY
  1154. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[6]);
  1155. #endif
  1156. (*pMyArgument).Memory.BaseRegister = REGS[6];
  1157. }
  1158. }
  1159. else {
  1160. #ifndef BEA_LIGHT_DISASSEMBLY
  1161. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers16Bits[5]);
  1162. #endif
  1163. (*pMyArgument).Memory.BaseRegister = REGS[5];
  1164. }
  1165. #ifndef BEA_LIGHT_DISASSEMBLY
  1166. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  1167. if (GV.SYNTAX_ == ATSyntax) {
  1168. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  1169. i += 1;
  1170. }
  1171. else {
  1172. #else
  1173. if(1) {
  1174. #endif
  1175. if (MyNumber < 0) {
  1176. #ifndef BEA_LIGHT_DISASSEMBLY
  1177. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  1178. #endif
  1179. i++;
  1180. #ifndef BEA_LIGHT_DISASSEMBLY
  1181. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) ~MyNumber+1);
  1182. #endif
  1183. }
  1184. else {
  1185. #ifndef BEA_LIGHT_DISASSEMBLY
  1186. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "+");
  1187. #endif
  1188. i++;
  1189. #ifndef BEA_LIGHT_DISASSEMBLY
  1190. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) MyNumber);
  1191. #endif
  1192. }
  1193. }
  1194. }
  1195. /* =======================================
  1196. * ModRM_1
  1197. * ======================================= */
  1198. void __bea_callspec__ Addr_EDI_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  1199. {
  1200. size_t i = 0, j;
  1201. long MyNumber;
  1202. MyNumber = *((Int8*)(UIntPtr) (GV.EIP_+2));
  1203. (*pMyArgument).Memory.Displacement = MyNumber;
  1204. if (GV.SYNTAX_ == ATSyntax) {
  1205. if (MyNumber < 0) {
  1206. #ifndef BEA_LIGHT_DISASSEMBLY
  1207. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  1208. #endif
  1209. i++;
  1210. j=i;
  1211. #ifndef BEA_LIGHT_DISASSEMBLY
  1212. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) ~MyNumber+1);
  1213. #endif
  1214. }
  1215. else {
  1216. j=i;
  1217. #ifndef BEA_LIGHT_DISASSEMBLY
  1218. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.2X",(Int64) MyNumber);
  1219. #endif
  1220. }
  1221. #ifndef BEA_LIGHT_DISASSEMBLY
  1222. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "(%");
  1223. #endif
  1224. i+=2;
  1225. }
  1226. (*pMyArgument).ArgType = MEMORY_TYPE;
  1227. if (GV.AddressSize == 64) {
  1228. if (GV.REX.B_ == 1) {
  1229. #ifndef BEA_LIGHT_DISASSEMBLY
  1230. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[15]);
  1231. #endif
  1232. (*pMyArgument).Memory.BaseRegister = REGS[7+8];
  1233. }
  1234. else {
  1235. #ifndef BEA_LIGHT_DISASSEMBLY
  1236. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[7]);
  1237. #endif
  1238. (*pMyArgument).Memory.BaseRegister = REGS[7];
  1239. }
  1240. }
  1241. else if (GV.AddressSize == 32) {
  1242. if (GV.REX.B_ == 1) {
  1243. #ifndef BEA_LIGHT_DISASSEMBLY
  1244. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[15]);
  1245. #endif
  1246. (*pMyArgument).Memory.BaseRegister = REGS[7+8];
  1247. }
  1248. else {
  1249. #ifndef BEA_LIGHT_DISASSEMBLY
  1250. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[7]);
  1251. #endif
  1252. (*pMyArgument).Memory.BaseRegister = REGS[7];
  1253. }
  1254. }
  1255. else {
  1256. #ifndef BEA_LIGHT_DISASSEMBLY
  1257. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers16Bits[3]);
  1258. #endif
  1259. (*pMyArgument).Memory.BaseRegister = REGS[3];
  1260. }
  1261. #ifndef BEA_LIGHT_DISASSEMBLY
  1262. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  1263. if (GV.SYNTAX_ == ATSyntax) {
  1264. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  1265. i += 1;
  1266. }
  1267. else {
  1268. #else
  1269. if(1) {
  1270. #endif
  1271. if (MyNumber < 0) {
  1272. #ifndef BEA_LIGHT_DISASSEMBLY
  1273. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  1274. #endif
  1275. i++;
  1276. #ifndef BEA_LIGHT_DISASSEMBLY
  1277. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) ~MyNumber+1);
  1278. #endif
  1279. }
  1280. else {
  1281. #ifndef BEA_LIGHT_DISASSEMBLY
  1282. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "+");
  1283. #endif
  1284. i++;
  1285. #ifndef BEA_LIGHT_DISASSEMBLY
  1286. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.2X",(Int64) MyNumber);
  1287. #endif
  1288. }
  1289. }
  1290. }
  1291. /* =======================================
  1292. * ModRM_2
  1293. * ======================================= */
  1294. void __bea_callspec__ Addr_EAX_disp32(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  1295. {
  1296. size_t i = 0, j;
  1297. long MyNumber;
  1298. if (GV.AddressSize == 16) {
  1299. MyNumber = *((Int16*)(UIntPtr) (GV.EIP_+2));
  1300. }
  1301. else{
  1302. MyNumber = *((Int32*)(UIntPtr) (GV.EIP_+2));
  1303. }
  1304. (*pMyArgument).Memory.Displacement = MyNumber;
  1305. if (GV.SYNTAX_ == ATSyntax) {
  1306. if (MyNumber < 0) {
  1307. #ifndef BEA_LIGHT_DISASSEMBLY
  1308. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  1309. #endif
  1310. i ++;
  1311. j=i;
  1312. #ifndef BEA_LIGHT_DISASSEMBLY
  1313. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.8X",(Int64) ~MyNumber+1);
  1314. #endif
  1315. }
  1316. else {
  1317. j = i;
  1318. #ifndef BEA_LIGHT_DISASSEMBLY
  1319. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.8X",(Int64) MyNumber);
  1320. #endif
  1321. }
  1322. #ifndef BEA_LIGHT_DISASSEMBLY
  1323. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "(%");
  1324. #endif
  1325. i+=2;
  1326. }
  1327. (*pMyArgument).ArgType = MEMORY_TYPE;
  1328. if (GV.AddressSize == 64) {
  1329. if (GV.REX.B_ == 1) {
  1330. #ifndef BEA_LIGHT_DISASSEMBLY
  1331. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[8]);
  1332. #endif
  1333. (*pMyArgument).Memory.BaseRegister = REGS[8];
  1334. }
  1335. else {
  1336. #ifndef BEA_LIGHT_DISASSEMBLY
  1337. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers64Bits[0]);
  1338. #endif
  1339. (*pMyArgument).Memory.BaseRegister = REGS[0];
  1340. }
  1341. }
  1342. else if (GV.AddressSize == 32) {
  1343. if (GV.REX.B_ == 1) {
  1344. #ifndef BEA_LIGHT_DISASSEMBLY
  1345. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[8]);
  1346. #endif
  1347. (*pMyArgument).Memory.BaseRegister = REGS[8];
  1348. }
  1349. else {
  1350. #ifndef BEA_LIGHT_DISASSEMBLY
  1351. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, Registers32Bits[0]);
  1352. #endif
  1353. (*pMyArgument).Memory.BaseRegister = REGS[0];
  1354. }
  1355. }
  1356. else {
  1357. #ifndef BEA_LIGHT_DISASSEMBLY
  1358. (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BXSI_);
  1359. #endif
  1360. }
  1361. #ifndef BEA_LIGHT_DISASSEMBLY
  1362. i = strlen ((char*) &(*pMyArgument).ArgMnemonic);
  1363. if (GV.SYNTAX_ == ATSyntax) {
  1364. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")");
  1365. i += 1;
  1366. }
  1367. else {
  1368. #else
  1369. if(1) {
  1370. #endif
  1371. if (MyNumber < 0) {
  1372. #ifndef BEA_LIGHT_DISASSEMBLY
  1373. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  1374. #endif
  1375. i++;
  1376. #ifndef BEA_LIGHT_DISASSEMBLY
  1377. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.8X",(Int64) ~MyNumber+1);
  1378. #endif
  1379. }
  1380. else {
  1381. #ifndef BEA_LIGHT_DISASSEMBLY
  1382. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "+");
  1383. #endif
  1384. i++;
  1385. #ifndef BEA_LIGHT_DISASSEMBLY
  1386. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.8X",(Int64) MyNumber);
  1387. #endif
  1388. }
  1389. }
  1390. }
  1391. /* =======================================
  1392. * ModRM_2
  1393. * ======================================= */
  1394. void __bea_callspec__ Addr_ECX_disp32(ARGTYPE* pMyArgument, PDISASM pMyDisasm)
  1395. {
  1396. size_t i = 0, j;
  1397. long MyNumber;
  1398. if (GV.AddressSize == 16) {
  1399. MyNumber = *((Int16*)(UIntPtr) (GV.EIP_+2));
  1400. }
  1401. else{
  1402. MyNumber = *((Int32*)(UIntPtr) (GV.EIP_+2));
  1403. }
  1404. (*pMyArgument).Memory.Displacement = MyNumber;
  1405. if (GV.SYNTAX_ == ATSyntax) {
  1406. if (MyNumber < 0) {
  1407. #ifndef BEA_LIGHT_DISASSEMBLY
  1408. (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, "-");
  1409. #endif
  1410. i ++;
  1411. j=i;
  1412. #ifndef BEA_LIGHT_DISASSEMBLY
  1413. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.8X",(Int64) ~MyNumber+1);
  1414. #endif
  1415. }
  1416. else {
  1417. j = i;
  1418. #ifndef BEA_LIGHT_DISASSEMBLY
  1419. i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+j,"%.8X",(Int64) MyNumber);
  1420. #endif
  1421. }
  1422. #ifndef BEA_LIGHT_DISASSEMBLY
  1423. (void) strcpy((char*) (

Large files files are truncated, but you can click here to view the full file