VirtualBox

source: vbox/trunk/src/VBox/Main/testcase/tstVBoxAPIXPCOM.cpp@ 107866

Last change on this file since 107866 was 107768, checked in by vboxsync, 4 weeks ago

Main/testcase/tstVBoxAPIXPCOM.cpp: Prevent theoretical buffer overflow in testcase, harmless, bugref:3409

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.8 KB
Line 
1/* $Id: tstVBoxAPIXPCOM.cpp 107768 2025-01-15 12:17:44Z vboxsync $ */
2/** @file
3 *
4 * tstVBoxAPIXPCOM - sample program to illustrate the VirtualBox
5 * XPCOM API for machine management.
6 * It only uses standard C/C++ and XPCOM semantics,
7 * no additional VBox classes/macros/helpers.
8 */
9
10/*
11 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
12 *
13 * This file is part of VirtualBox base platform packages, as
14 * available from https://www.virtualbox.org.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation, in version 3 of the
19 * License.
20 *
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see <https://www.gnu.org/licenses>.
28 *
29 * SPDX-License-Identifier: GPL-3.0-only
30 */
31
32/*
33 * PURPOSE OF THIS SAMPLE PROGRAM
34 * ------------------------------
35 *
36 * This sample program is intended to demonstrate the minimal code necessary
37 * to use VirtualBox XPCOM API for learning puroses only. The program uses
38 * pure XPCOM and doesn't have any extra dependencies to let you better
39 * understand what is going on when a client talks to the VirtualBox core
40 * using the XPCOM framework.
41 *
42 * However, if you want to write a real application, it is highly recommended
43 * to use our MS COM XPCOM Glue library and helper C++ classes. This way, you
44 * will get at least the following benefits:
45 *
46 * a) better portability: both the MS COM (used on Windows) and XPCOM (used
47 * everywhere else) VirtualBox client application from the same source code
48 * (including common smart C++ templates for automatic interface pointer
49 * reference counter and string data management);
50 * b) simpler XPCOM initialization and shutdown (only a single method call
51 * that does everything right).
52 *
53 * Currently, there is no separate sample program that uses the VirtualBox MS
54 * COM XPCOM Glue library. Please refer to the sources of stock VirtualBox
55 * applications such as the VirtualBox GUI frontend or the VBoxManage command
56 * line frontend.
57 *
58 *
59 * RUNNING THIS SAMPLE PROGRAM
60 * ---------------------------
61 *
62 * This sample program needs to know where the VirtualBox core files reside
63 * and where to search for VirtualBox shared libraries. Therefore, you need to
64 * use the following (or similar) command to execute it:
65 *
66 * $ env VBOX_XPCOM_HOME=../../.. LD_LIBRARY_PATH=../../.. ./tstVBoxAPIXPCOM
67 *
68 * The above command assumes that VBoxRT.so, VBoxXPCOM.so and others reside in
69 * the directory ../../..
70 */
71
72
73#include <stdio.h>
74#include <stdlib.h>
75#include <iconv.h>
76
77/*
78 * Include the XPCOM headers
79 */
80#include <nsMemory.h>
81#include <nsString.h>
82#include <nsIServiceManager.h>
83#include <nsEventQueueUtils.h>
84
85#include <nsIExceptionService.h>
86
87/*
88 * VirtualBox XPCOM interface. This header is generated
89 * from IDL which in turn is generated from a custom XML format.
90 */
91#include "VirtualBox_XPCOM.h"
92
93/*
94 * Prototypes
95 */
96
97char *nsIDToString(nsID *guid);
98void printErrorInfo();
99
100
101/**
102 * Display all registered VMs on the screen with some information about each
103 *
104 * @param virtualBox VirtualBox instance object.
105 */
106static void listVMs(IVirtualBox *virtualBox)
107{
108 nsresult rc;
109
110 printf("----------------------------------------------------\n");
111 printf("VM List:\n\n");
112
113 /*
114 * Get the list of all registered VMs
115 */
116 IMachine **machines = NULL;
117 PRUint32 cMachines = 0;
118
119 rc = virtualBox->GetMachines(&cMachines, &machines);
120 if (NS_SUCCEEDED(rc))
121 {
122 /*
123 * Iterate through the collection
124 */
125 for (PRUint32 i = 0; i < cMachines; ++ i)
126 {
127 IMachine *machine = machines[i];
128 if (machine)
129 {
130 PRBool isAccessible = PR_FALSE;
131 machine->GetAccessible(&isAccessible);
132
133 if (isAccessible)
134 {
135 nsXPIDLString machineName;
136 machine->GetName(getter_Copies(machineName));
137 char *machineNameAscii = ToNewCString(machineName);
138 printf("\tName: %s\n", machineNameAscii);
139 free(machineNameAscii);
140 }
141 else
142 {
143 printf("\tName: <inaccessible>\n");
144 }
145
146 nsXPIDLString iid;
147 machine->GetId(getter_Copies(iid));
148 const char *uuidString = ToNewCString(iid);
149 printf("\tUUID: %s\n", uuidString);
150 free((void*)uuidString);
151
152 if (isAccessible)
153 {
154 nsXPIDLString configFile;
155 machine->GetSettingsFilePath(getter_Copies(configFile));
156 char *configFileAscii = ToNewCString(configFile);
157 printf("\tConfig file: %s\n", configFileAscii);
158 free(configFileAscii);
159
160 PRUint32 memorySize;
161 machine->GetMemorySize(&memorySize);
162 printf("\tMemory size: %uMB\n", memorySize);
163
164 nsXPIDLString typeId;
165 machine->GetOSTypeId(getter_Copies(typeId));
166 IGuestOSType *osType = nsnull;
167 virtualBox->GetGuestOSType(typeId.get(), &osType);
168 nsXPIDLString osName;
169 osType->GetDescription(getter_Copies(osName));
170 char *osNameAscii = ToNewCString(osName);
171 printf("\tGuest OS: %s\n\n", osNameAscii);
172 free(osNameAscii);
173 osType->Release();
174 }
175
176 /* don't forget to release the objects in the array... */
177 machine->Release();
178 }
179 }
180 nsMemory::Free(machines);
181 }
182 printf("----------------------------------------------------\n\n");
183}
184
185/**
186 * Create a sample VM
187 *
188 * @param virtualBox VirtualBox instance object.
189 */
190static void createVM(IVirtualBox *virtualBox)
191{
192 nsresult rc;
193 /*
194 * First create a unnamed new VM. It will be unconfigured and not be saved
195 * in the configuration until we explicitely choose to do so.
196 */
197 nsCOMPtr<IMachine> machine;
198 rc = virtualBox->CreateMachine(NULL, /* settings file */
199 NS_LITERAL_STRING("A brand new name").get(),
200 PlatformArchitecture_x86,
201 0, nsnull, /* groups (safearray)*/
202 nsnull, /* ostype */
203 nsnull, /* create flags */
204 nsnull, /* cipher */
205 nsnull, /* password id */
206 nsnull, /* password */
207 getter_AddRefs(machine));
208 if (NS_FAILED(rc))
209 {
210 printf("Error: could not create machine! rc=%#x\n", rc);
211 return;
212 }
213
214 /*
215 * Set some properties
216 */
217 /* alternative to illustrate the use of string classes */
218 rc = machine->SetName(NS_ConvertUTF8toUTF16("A new name").get());
219 if (NS_FAILED(rc))
220 {
221 printf("Error: could not set name for machine! rc=%#x\n", rc);
222 return;
223 }
224
225 rc = machine->SetMemorySize(128);
226 if (NS_FAILED(rc))
227 {
228 printf("Error: could not set memory size for machine! rc=%#x\n", rc);
229 return;
230 }
231
232 /*
233 * Now a more advanced property -- the guest OS type. This is
234 * an object by itself which has to be found first. Note that we
235 * use the ID of the guest OS type here which is an internal
236 * representation (you can find that by configuring the OS type of
237 * a machine in the GUI and then looking at the <Guest ostype=""/>
238 * setting in the XML file. It is also possible to get the OS type from
239 * its description (win2k would be "Windows 2000") by getting the
240 * guest OS type collection and enumerating it.
241 */
242 nsCOMPtr<IGuestOSType> osType;
243 rc = virtualBox->GetGuestOSType(NS_LITERAL_STRING(GUEST_OS_ID_STR_X86("Windows2000")).get(),
244 getter_AddRefs(osType));
245 if (NS_FAILED(rc))
246 {
247 printf("Error: could not find guest OS type! rc=%#x\n", rc);
248 }
249 else
250 {
251 machine->SetOSTypeId(NS_LITERAL_STRING(GUEST_OS_ID_STR_X86("Windows2000")).get());
252 }
253
254 /*
255 * Register the VM. Note that this call also saves the VM config
256 * to disk. It is also possible to save the VM settings but not
257 * register the VM.
258 *
259 * Also note that due to current VirtualBox limitations, the machine
260 * must be registered *before* we can attach hard disks to it.
261 */
262 rc = virtualBox->RegisterMachine(machine);
263 if (NS_FAILED(rc))
264 {
265 printf("Error: could not register machine! rc=%#x\n", rc);
266 printErrorInfo();
267 return;
268 }
269
270 nsCOMPtr<IMachine> origMachine = machine;
271
272 /*
273 * In order to manipulate the registered machine, we must open a session
274 * for that machine. Do it now.
275 */
276 nsCOMPtr<ISession> session;
277 nsCOMPtr<IMachine> sessionMachine;
278 {
279 nsCOMPtr<nsIComponentManager> manager;
280 rc = NS_GetComponentManager(getter_AddRefs(manager));
281 if (NS_FAILED(rc))
282 {
283 printf("Error: could not get component manager! rc=%#x\n", rc);
284 return;
285 }
286 rc = manager->CreateInstanceByContractID(NS_SESSION_CONTRACTID,
287 nsnull,
288 NS_GET_IID(ISession),
289 getter_AddRefs(session));
290 if (NS_FAILED(rc))
291 {
292 printf("Error, could not instantiate session object! rc=%#x\n", rc);
293 return;
294 }
295
296 rc = machine->LockMachine(session, LockType_Write);
297 if (NS_FAILED(rc))
298 {
299 printf("Error, could not lock the machine for the session! rc=%#x\n", rc);
300 return;
301 }
302
303 /*
304 * After the machine is registered, the initial machine object becomes
305 * immutable. In order to get a mutable machine object, we must query
306 * it from the opened session object.
307 */
308 rc = session->GetMachine(getter_AddRefs(sessionMachine));
309 if (NS_FAILED(rc))
310 {
311 printf("Error, could not get machine session! rc=%#x\n", rc);
312 return;
313 }
314 }
315
316 /*
317 * Create a virtual harddisk
318 */
319 nsCOMPtr<IMedium> hardDisk = 0;
320 rc = virtualBox->CreateMedium(NS_LITERAL_STRING("VDI").get(),
321 NS_LITERAL_STRING("/tmp/TestHardDisk.vdi").get(),
322 AccessMode_ReadWrite, DeviceType_HardDisk,
323 getter_AddRefs(hardDisk));
324 if (NS_FAILED(rc))
325 {
326 printf("Failed creating a hard disk object! rc=%#x\n", rc);
327 }
328 else
329 {
330 /*
331 * We have only created an object so far. No on disk representation exists
332 * because none of its properties has been set so far. Let's continue creating
333 * a dynamically expanding image.
334 */
335 nsCOMPtr<IProgress> progress;
336 MediumVariant_T mediumVariants[] =
337 { MediumVariant_Standard };
338 rc = hardDisk->CreateBaseStorage(100 * 1024 * 1024, // size in bytes
339 sizeof(mediumVariants) / sizeof(mediumVariants[0]), mediumVariants,
340 getter_AddRefs(progress)); // optional progress object
341 if (NS_FAILED(rc))
342 {
343 printf("Failed creating hard disk image! rc=%#x\n", rc);
344 }
345 else
346 {
347 /*
348 * Creating the image is done in the background because it can take quite
349 * some time (at least fixed size images). We have to wait for its completion.
350 * Here we wait forever (timeout -1) which is potentially dangerous.
351 */
352 rc = progress->WaitForCompletion(-1);
353 PRInt32 resultCode;
354 progress->GetResultCode(&resultCode);
355 if (NS_FAILED(rc) || NS_FAILED(resultCode))
356 {
357 printf("Error: could not create hard disk! rc=%#x\n",
358 NS_FAILED(rc) ? rc : resultCode);
359 }
360 else
361 {
362 /*
363 * Now that it's created, we can assign it to the VM.
364 */
365 rc = sessionMachine->AttachDevice(
366 NS_LITERAL_STRING("IDE Controller").get(), // controller identifier
367 0, // channel number on the controller
368 0, // device number on the controller
369 DeviceType_HardDisk,
370 hardDisk);
371 if (NS_FAILED(rc))
372 {
373 printf("Error: could not attach hard disk! rc=%#x\n", rc);
374 }
375 }
376 }
377 }
378
379 /*
380 * It's got a hard disk but that one is new and thus not bootable. Make it
381 * boot from an ISO file. This requires some processing. First the ISO file
382 * has to be registered and then mounted to the VM's DVD drive and selected
383 * as the boot device.
384 */
385 nsCOMPtr<IMedium> dvdImage;
386 rc = virtualBox->OpenMedium(NS_LITERAL_STRING("/home/vbox/isos/winnt4ger.iso").get(),
387 DeviceType_DVD,
388 AccessMode_ReadOnly,
389 false /* fForceNewUuid */,
390 getter_AddRefs(dvdImage));
391 if (NS_FAILED(rc))
392 printf("Error: could not open CD image! rc=%#x\n", rc);
393 else
394 {
395 /*
396 * Now assign it to our VM
397 */
398 rc = sessionMachine->MountMedium(
399 NS_LITERAL_STRING("IDE Controller").get(), // controller identifier
400 2, // channel number on the controller
401 0, // device number on the controller
402 dvdImage,
403 PR_FALSE); // aForce
404 if (NS_FAILED(rc))
405 {
406 printf("Error: could not mount ISO image! rc=%#x\n", rc);
407 }
408 else
409 {
410 /*
411 * Last step: tell the VM to boot from the CD.
412 */
413 rc = sessionMachine->SetBootOrder(1, DeviceType::DVD);
414 if (NS_FAILED(rc))
415 {
416 printf("Could not set boot device! rc=%#x\n", rc);
417 }
418 }
419 }
420
421 /*
422 * Save all changes we've just made.
423 */
424 rc = sessionMachine->SaveSettings();
425 if (NS_FAILED(rc))
426 printf("Could not save machine settings! rc=%#x\n", rc);
427
428 /*
429 * It is always important to close the open session when it becomes not
430 * necessary any more.
431 */
432 session->UnlockMachine();
433
434 IMedium **aMedia;
435 PRUint32 cMedia;
436 rc = machine->Unregister((CleanupMode_T)CleanupMode_DetachAllReturnHardDisksOnly,
437 &cMedia, &aMedia);
438 if (NS_FAILED(rc))
439 printf("Unregistering the machine failed! rc=%#x\n", rc);
440 else
441 {
442 nsCOMPtr<IProgress> pProgress;
443 rc = machine->DeleteConfig(cMedia, aMedia, getter_AddRefs(pProgress));
444 if (NS_FAILED(rc))
445 printf("Deleting of machine failed! rc=%#x\n", rc);
446 else
447 {
448 rc = pProgress->WaitForCompletion(-1);
449 PRInt32 resultCode;
450 pProgress->GetResultCode(&resultCode);
451 if (NS_FAILED(rc) || NS_FAILED(resultCode))
452 printf("Failed to delete the machine! rc=%#x\n",
453 NS_FAILED(rc) ? rc : resultCode);
454 }
455
456 /* Release the media array: */
457 for (PRUint32 i = 0; i < cMedia; i++)
458 if (aMedia[i])
459 aMedia[i]->Release();
460 nsMemory::Free(aMedia);
461 }
462}
463
464// main
465///////////////////////////////////////////////////////////////////////////////
466
467int main(int argc, char **argv)
468{
469 /*
470 * Check that PRUnichar is equal in size to what compiler composes L""
471 * strings from; otherwise NS_LITERAL_STRING macros won't work correctly
472 * and we will get a meaningless SIGSEGV. This, of course, must be checked
473 * at compile time in xpcom/string/nsTDependentString.h, but XPCOM lacks
474 * compile-time assert macros and I'm not going to add them now.
475 */
476 if (sizeof(PRUnichar) != sizeof(wchar_t))
477 {
478 printf("Error: sizeof(PRUnichar) {%lu} != sizeof(wchar_t) {%lu}!\n"
479 "Probably, you forgot the -fshort-wchar compiler option.\n",
480 (unsigned long) sizeof(PRUnichar),
481 (unsigned long) sizeof(wchar_t));
482 return -1;
483 }
484
485#if 1 /* Please ignore this! It is very very crude. */
486# ifdef RTPATH_APP_PRIVATE_ARCH
487 if (!getenv("VBOX_XPCOM_HOME"))
488 setenv("VBOX_XPCOM_HOME", RTPATH_APP_PRIVATE_ARCH, 1);
489# else
490 char szTmp[8192];
491 if (!getenv("VBOX_XPCOM_HOME"))
492 {
493 strncpy(szTmp, argv[0], sizeof(szTmp));
494 *strrchr(szTmp, '/') = '\0';
495 strcat(szTmp, "/..");
496 fprintf(stderr, "tstVBoxAPIXPCOM: VBOX_XPCOM_HOME is not set, using '%s' instead\n", szTmp);
497 setenv("VBOX_XPCOM_HOME", szTmp, 1);
498 }
499# endif
500#endif
501 (void)argc; (void)argv;
502
503 nsresult rc;
504
505 /*
506 * This is the standard XPCOM init procedure.
507 * What we do is just follow the required steps to get an instance
508 * of our main interface, which is IVirtualBox.
509 *
510 * Note that we scope all nsCOMPtr variables in order to have all XPCOM
511 * objects automatically released before we call NS_ShutdownXPCOM at the
512 * end. This is an XPCOM requirement.
513 */
514 {
515 nsCOMPtr<nsIServiceManager> serviceManager;
516 rc = NS_InitXPCOM2(getter_AddRefs(serviceManager), nsnull, nsnull);
517 if (NS_FAILED(rc))
518 {
519 printf("Error: XPCOM could not be initialized! rc=%#x\n", rc);
520 return -1;
521 }
522
523#if 0
524 /*
525 * Register our components. This step is only necessary if this executable
526 * implements XPCOM components itself which is not the case for this
527 * simple example.
528 */
529 nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(serviceManager);
530 if (!registrar)
531 {
532 printf("Error: could not query nsIComponentRegistrar interface!\n");
533 return -1;
534 }
535 registrar->AutoRegister(nsnull);
536#endif
537
538 /*
539 * Make sure the main event queue is created. This event queue is
540 * responsible for dispatching incoming XPCOM IPC messages. The main
541 * thread should run this event queue's loop during lengthy non-XPCOM
542 * operations to ensure messages from the VirtualBox server and other
543 * XPCOM IPC clients are processed. This use case doesn't perform such
544 * operations so it doesn't run the event loop.
545 */
546 nsCOMPtr<nsIEventQueue> eventQ;
547 rc = NS_GetMainEventQ(getter_AddRefs(eventQ));
548 if (NS_FAILED(rc))
549 {
550 printf("Error: could not get main event queue! rc=%#x\n", rc);
551 return -1;
552 }
553
554 /*
555 * Now XPCOM is ready and we can start to do real work.
556 * IVirtualBox is the root interface of VirtualBox and will be
557 * retrieved from the XPCOM component manager. We use the
558 * XPCOM provided smart pointer nsCOMPtr for all objects because
559 * that's very convenient and removes the need deal with reference
560 * counting and freeing.
561 */
562 nsCOMPtr<nsIComponentManager> manager;
563 rc = NS_GetComponentManager(getter_AddRefs(manager));
564 if (NS_FAILED(rc))
565 {
566 printf("Error: could not get component manager! rc=%#x\n", rc);
567 return -1;
568 }
569
570 nsCOMPtr<IVirtualBox> virtualBox;
571 rc = manager->CreateInstanceByContractID(NS_VIRTUALBOX_CONTRACTID,
572 nsnull,
573 NS_GET_IID(IVirtualBox),
574 getter_AddRefs(virtualBox));
575 if (NS_FAILED(rc))
576 {
577 printf("Error, could not instantiate VirtualBox object! rc=%#x\n", rc);
578 return -1;
579 }
580 printf("VirtualBox object created\n");
581
582 ////////////////////////////////////////////////////////////////////////////////
583 ////////////////////////////////////////////////////////////////////////////////
584 ////////////////////////////////////////////////////////////////////////////////
585
586
587 listVMs(virtualBox);
588
589 createVM(virtualBox);
590
591
592 ////////////////////////////////////////////////////////////////////////////////
593 ////////////////////////////////////////////////////////////////////////////////
594 ////////////////////////////////////////////////////////////////////////////////
595
596 /* this is enough to free the IVirtualBox instance -- smart pointers rule! */
597 virtualBox = nsnull;
598
599 /*
600 * Process events that might have queued up in the XPCOM event
601 * queue. If we don't process them, the server might hang.
602 */
603 eventQ->ProcessPendingEvents();
604 }
605
606 /*
607 * Perform the standard XPCOM shutdown procedure.
608 */
609 NS_ShutdownXPCOM(nsnull);
610 printf("Done!\n");
611 return 0;
612}
613
614
615//////////////////////////////////////////////////////////////////////////////////////////////////////
616//// Helpers
617//////////////////////////////////////////////////////////////////////////////////////////////////////
618
619/**
620 * Helper function to convert an nsID into a human readable string
621 *
622 * @returns result string, allocated. Has to be freed using free()
623 * @param guid Pointer to nsID that will be converted.
624 */
625char *nsIDToString(nsID *guid)
626{
627 char *res = (char *)malloc(39);
628 if (res != NULL)
629 {
630 snprintf(res, 39, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
631 guid->m0, (PRUint32)guid->m1, (PRUint32)guid->m2,
632 (PRUint32)guid->m3[0], (PRUint32)guid->m3[1], (PRUint32)guid->m3[2],
633 (PRUint32)guid->m3[3], (PRUint32)guid->m3[4], (PRUint32)guid->m3[5],
634 (PRUint32)guid->m3[6], (PRUint32)guid->m3[7]);
635 }
636 return res;
637}
638
639/**
640 * Helper function to print XPCOM exception information set on the current
641 * thread after a failed XPCOM method call. This function will also print
642 * extended VirtualBox error info if it is available.
643 */
644void printErrorInfo()
645{
646 nsresult rc = NS_ERROR_UNEXPECTED;
647 nsCOMPtr<nsIExceptionService> es;
648 es = do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID, &rc);
649 if (NS_SUCCEEDED(rc))
650 {
651 nsCOMPtr<nsIExceptionManager> em;
652 rc = es->GetCurrentExceptionManager(getter_AddRefs(em));
653 if (NS_SUCCEEDED(rc))
654 {
655 nsCOMPtr<nsIException> ex;
656 rc = em->GetCurrentException(getter_AddRefs(ex));
657 if (NS_SUCCEEDED(rc) && ex)
658 {
659 nsCOMPtr<IVirtualBoxErrorInfo> info;
660 info = do_QueryInterface(ex, &rc);
661 if (NS_SUCCEEDED(rc) && info)
662 {
663 /* got extended error info */
664 printf("Extended error info (IVirtualBoxErrorInfo):\n");
665 PRInt32 resultCode = NS_OK;
666 info->GetResultCode(&resultCode);
667 printf(" resultCode=%08X\n", resultCode);
668 nsXPIDLString component;
669 info->GetComponent(getter_Copies(component));
670 printf(" component=%s\n", NS_ConvertUTF16toUTF8(component).get());
671 nsXPIDLString text;
672 info->GetText(getter_Copies(text));
673 printf(" text=%s\n", NS_ConvertUTF16toUTF8(text).get());
674 }
675 else
676 {
677 /* got basic error info */
678 printf("Basic error info (nsIException):\n");
679 nsresult resultCode = NS_OK;
680 ex->GetResult(&resultCode);
681 printf(" resultCode=%08X\n", resultCode);
682 nsXPIDLCString message;
683 ex->GetMessage(getter_Copies(message));
684 printf(" message=%s\n", message.get());
685 }
686
687 /* reset the exception to NULL to indicate we've processed it */
688 em->SetCurrentException(NULL);
689
690 rc = NS_OK;
691 }
692 }
693 }
694}
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