VirtualBox

source: vbox/trunk/src/VBox/Disassembler/DisasmTest.cpp@ 41669

Last change on this file since 41669 was 41669, checked in by vboxsync, 12 years ago

DISInstr -> DISInstrToStr.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1/** @file
2 *
3 * VBox disassembler:
4 * Test application
5 */
6
7/*
8 * Copyright (C) 2006-2007 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#include <VBox/dis.h>
23#include <VBox/err.h>
24#include <stdio.h>
25#include <iprt/string.h>
26#include <iprt/asm.h>
27
28DECLASM(int) TestProc();
29#ifndef RT_OS_OS2
30DECLASM(int) TestProc64();
31#endif
32//uint8_t aCode16[] = { 0x66, 0x67, 0x89, 0x07 };
33
34int main(int argc, char **argv)
35{
36 printf("VBox Disassembler Test\n");
37 if (argc != 1)
38 {
39 //printf("DisasmBlock on printf:\n");
40 //DisasmBlock((uint8_t *)printf, 256);
41 }
42 else
43 {
44 uint8_t const *pbInstr = (uint8_t const *)(uintptr_t)TestProc;
45
46 for (int i=0;i<50;i++)
47 {
48 unsigned cb;
49 DISCPUSTATE cpu;
50 char szOutput[256];
51
52 if (RT_SUCCESS(DISInstrToStr(pbInstr, CPUMODE_32BIT, &cpu, &cb, szOutput, sizeof(szOutput))))
53 {
54 printf("%s", szOutput);
55 }
56 else
57 {
58 printf("DISOne failed!\n");
59 return 1;
60 }
61 pbInstr += cb;
62 }
63
64#ifndef RT_OS_OS2
65 printf("\n64 bits disassembly\n");
66 pbInstr = (uint8_t const *)(uintptr_t)TestProc64;
67
68////__debugbreak();
69 for (int i=0;i<50;i++)
70 {
71 unsigned cb;
72 DISCPUSTATE cpu;
73 char szOutput[256];
74
75 if (RT_SUCCESS(DISInstrToStr(pbInstr, CPUMODE_64BIT, &cpu, &cb, szOutput, sizeof(szOutput))))
76 printf("%s", szOutput);
77 else
78 {
79 printf("DISOne failed!\n");
80 return 1;
81 }
82 pbInstr += cb;
83 }
84#endif
85 }
86 return 0;
87}
88
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette