VirtualBox

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

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

DIS: More cleanups.

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