1 /*
   2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27  * A DLL which is loaded by Java applications to handle communication
  28  * between Java VMs purposes of Accessbility.
  29  */
  30 
  31 #include "AccessBridgeDebug.h"
  32 #include "JavaAccessBridge.h"
  33 #include "com_sun_java_accessibility_internal_AccessBridge.h" // programatically generated by JNI
  34 #include "accessBridgeResource.h"
  35 #include "accessBridgeCallbacks.h"
  36 #include "AccessBridgeMessages.h"
  37 
  38 
  39 #include <windows.h>
  40 #include <stdio.h>
  41 
  42 #include <jawt.h>
  43 #include <jawt_md.h>
  44 
  45 JavaAccessBridge *theJavaAccessBridge;
  46 HWND theDialogWindow;
  47 
  48 // re-entrance lock for receiving memory messages
  49 CRITICAL_SECTION receiveMemoryIPCLock;
  50 
  51 
  52 // unique broadcast msg. IDs gotten dymanically
  53 extern UINT theFromJavaHelloMsgID;
  54 extern UINT theFromWindowsHelloMsgID;
  55 
  56 
  57 // ---------------------------------------------------------------------------
  58 
  59 extern "C" {
  60     /**
  61      * DllMain - where Windows executables will load/unload us
  62      *
  63      */
  64     BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) {
  65 
  66         switch (fdwReason) {
  67         case DLL_PROCESS_ATTACH:
  68             InitializeCriticalSection(&receiveMemoryIPCLock);
  69             theJavaAccessBridge = new JavaAccessBridge(hinstDll);
  70             break;
  71 
  72         case DLL_PROCESS_DETACH:        // A Windows executable unloaded us
  73             if (theJavaAccessBridge != (JavaAccessBridge *) 0) {
  74                 delete theJavaAccessBridge;
  75                 DeleteCriticalSection(&receiveMemoryIPCLock);
  76             }
  77             break;
  78         }
  79         return TRUE;
  80     }
  81 
  82     /**
  83      * Open a native window (and init the wrappers we'll be using)
  84      *
  85      */
  86     JNIEXPORT void JNICALL
  87     Java_com_sun_java_accessibility_internal_AccessBridge_runDLL(JNIEnv *env, jobject obj) {
  88         PrintDebugString("\r\nJavaAccessBridge.DLL runDLL() called");
  89         theJavaAccessBridge->javaRun(env, obj);
  90     }
  91 
  92     /**
  93      * Our window proc
  94      *
  95      */
  96     BOOL APIENTRY AccessBridgeDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
  97         int command;
  98         COPYDATASTRUCT *sentToUs;
  99         char *package;
 100 
 101         switch (message) {
 102         case WM_INITDIALOG:
 103             PrintDebugString("In AccessBridgeDialog - Initializing");
 104             break;
 105 
 106         case WM_COMMAND:
 107             command = LOWORD (wParam);
 108             PrintDebugString("In AccessBridgeDialog - Got WM_COMMAND, command: %X", command);
 109             break;
 110 
 111             // call from Java with data for us to deliver
 112         case WM_COPYDATA:
 113             if (theDialogWindow == (HWND) wParam) {
 114                 PrintDebugString("In AccessBridgeDialog - Got WM_COPYDATA from ourselves");
 115             } else {
 116                 PrintDebugString("In AccessBridgeDialog - Got WM_COPYDATA from HWND %p", wParam);
 117                 sentToUs = (COPYDATASTRUCT *) lParam;
 118                 package = (char *) sentToUs->lpData;
 119                 theJavaAccessBridge->processPackage(package, sentToUs->cbData);
 120             }
 121             break;
 122 
 123             // call from Java with data for us retrieve from memory mapped file and deliver
 124         case AB_MESSAGE_WAITING:
 125             // wParam == sourceHwnd
 126             // lParam == buffer size in shared memory
 127             if (theDialogWindow == (HWND) wParam) {
 128                 PrintDebugString("In AccessBridgeDialog - Got AB_MESSAGE_WAITING from ourselves");
 129             } else {
 130                 PrintDebugString("In AccessBridgeDialog - Got AB_MESSAGE_WAITING from HWND %p", wParam);
 131                 LRESULT returnVal = theJavaAccessBridge->receiveMemoryPackage((HWND) wParam, (long) lParam);
 132             }
 133             break;
 134 
 135             // a JavaAccessBridge DLL is going away
 136         case AB_DLL_GOING_AWAY:
 137             PrintDebugString("In AccessBridgeDialog - Got AB_DLL_GOING_AWAY message");
 138             theJavaAccessBridge->WindowsATDestroyed((HWND) wParam);
 139             break;
 140 
 141         default:
 142             // the Windows AT is saying "hi"!
 143             // wParam == sourceHwnc; lParam unused
 144             if (message == theFromWindowsHelloMsgID) {
 145                 // A new Windows AT just said "hi";
 146                 // say "hi" back so it can mate up with us
 147                 // otherwise don't do anything (e.g. don't set up data structures yet)
 148                 PrintDebugString("In AccessBridgeDialog - Got theFromWindowsHelloMsgID message");
 149                 theJavaAccessBridge->postHelloToWindowsDLLMsg((HWND) wParam);
 150             }
 151         }
 152         return FALSE;
 153     }
 154 
 155 }
 156 
 157 
 158 // -----------------------------
 159 
 160 
 161 /**
 162  * Initialize the JavaAccessBridge
 163  *
 164  */
 165 JavaAccessBridge::JavaAccessBridge(HINSTANCE hInstance) {
 166     windowsInstance = hInstance;
 167     ATs = (AccessBridgeATInstance *) 0;
 168     initializeFileLogger();
 169     initBroadcastMessageIDs();          // get the unique to us broadcast msg. IDs
 170 }
 171 
 172 extern DWORD JavaBridgeThreadId;
 173 
 174 /**
 175  * Destroy the JavaAccessBridge
 176  *
 177  */
 178 JavaAccessBridge::~JavaAccessBridge() {
 179     // inform all other AccessBridges that we're going away
 180 
 181     PrintDebugString("\r\nin JavaAccessBridge::~JavaAccessBridge()");
 182 
 183     // Send a shutdown message for those applications like StarOffice that do
 184     // send a shutdown message themselves.
 185     javaShutdown(NULL, 0);
 186 
 187     AccessBridgeATInstance *current = ATs;
 188     while (current != (AccessBridgeATInstance *) 0) {
 189         PrintDebugString("  telling %p we're going away", current->winAccessBridgeWindow);
 190                 SendMessage(current->winAccessBridgeWindow,
 191                     AB_DLL_GOING_AWAY, (WPARAM) dialogWindow, (LPARAM) 0);
 192         current = current->nextATInstance;
 193     }
 194 
 195     PrintDebugString("  finished telling ATs about our demise");
 196 
 197         if(JavaBridgeThreadId)
 198                 {
 199                 PostThreadMessage(JavaBridgeThreadId,WM_USER+1,0,0);
 200                 Sleep(100);
 201                 }
 202 
 203     delete ATs;
 204 
 205     PrintDebugString("  finished deleting ATs");
 206     PrintDebugString("GOODBYE CRUEL WORLD...");
 207     finalizeFileLogger();
 208 }
 209 
 210 
 211 void
 212 JavaAccessBridge::javaRun(JNIEnv *env, jobject obj) {
 213     MSG msg;
 214 
 215     PrintDebugString("JavaAccessBridge::javaRun(%p, %p) called", env, obj);
 216 
 217     if (env->GetJavaVM(&javaVM) != 0) {
 218         return; // huh!?!?!
 219     }
 220     PrintDebugString("  -> javaVM = %p", javaVM);
 221 
 222     if (javaVM->AttachCurrentThread((void **) &windowsThreadJNIEnv, NULL) != 0) {
 223         return; // huh!?!?!
 224     }
 225     PrintDebugString("  -> windowsThreadJNIEnv = %p", windowsThreadJNIEnv);
 226 
 227     javaThreadABObject = env->NewGlobalRef(obj);
 228     windowsThreadABObject = windowsThreadJNIEnv->NewGlobalRef(obj);
 229 
 230     // initialize the Java thread AccessBridge entry points
 231     javaThreadEntryPoints = new AccessBridgeJavaEntryPoints(env, javaThreadABObject);
 232     if (javaThreadEntryPoints->BuildJavaEntryPoints() == FALSE) {
 233         return;         // couldn't build our entry points; let's get out of here!
 234     }
 235     PrintDebugString("  all Java thread entry points successfully found.");
 236 
 237     // initialize the Windows thread AccessBridge entry points
 238     windowsThreadEntryPoints = new AccessBridgeJavaEntryPoints(windowsThreadJNIEnv,
 239                                                                windowsThreadABObject);
 240     if (windowsThreadEntryPoints->BuildJavaEntryPoints() == FALSE) {
 241         return;         // couldn't build our entry points; let's get out of here!
 242     }
 243     PrintDebugString("  all Windows thread entry points successfully found.");
 244 
 245 
 246     // open our window
 247     if (initWindow() == TRUE) {
 248         PrintDebugString("  Window created.  HWND = %p", dialogWindow);
 249 
 250         // post a broadcast msg.; let other AccessBridge DLLs know we exist
 251         postHelloToWindowsDLLMsg(HWND_BROADCAST);
 252 
 253         // do that message loop thing
 254         while (GetMessage(&msg, NULL, 0, 0)) {
 255             TranslateMessage(&msg);
 256             DispatchMessage(&msg);
 257         }
 258     } else {
 259         PrintDebugString("  FAILED TO CREATE WINDOW!!!");
 260     }
 261 
 262     javaVM->DetachCurrentThread();
 263 }
 264 
 265 /**
 266  * Bring up our window; make a connection to the rest of the world
 267  *
 268  */
 269 BOOL
 270 JavaAccessBridge::initWindow() {
 271     theDialogWindow = CreateDialog(windowsInstance,
 272                                    "ACCESSBRIDGESTATUSWINDOW", NULL,
 273                                    (DLGPROC) AccessBridgeDialogProc);
 274 
 275     // If window could not be created, return "failure".
 276     if (!theDialogWindow)
 277         return FALSE;
 278 
 279     dialogWindow = theDialogWindow;
 280 
 281     // Make the window visible, update its client area, & return "success".
 282     // DEBUG_CODE(ShowWindow (theDialogWindow, SW_SHOWNORMAL));
 283     // DEBUG_CODE(UpdateWindow (theDialogWindow));
 284 
 285     return TRUE;
 286 }
 287 
 288 
 289 
 290 // -----------------------
 291 
 292 
 293 /**
 294  * postHelloToWindowsDLLMsg
 295  *          - PostMessage(theFromJavaHelloMsgID) to let one or
 296  *            all WindowDLLs we're here and have a vmID
 297  *
 298  *            destHwnd is either a single hwnd or HWND_BROADCAST
 299  *              (former if a reply, latter if we're just born)
 300  *            wParam is our HWND
 301  *            lParam is our vmID
 302  *
 303  */
 304 void
 305 JavaAccessBridge::postHelloToWindowsDLLMsg(HWND destHwnd) {
 306     PrintDebugString("\r\nIn JavaAccessBridge::postHelloToWindowsDLLMsg");
 307     PrintDebugString("  calling PostMessage(%p, %X, %p, %p)",
 308                      destHwnd, theFromJavaHelloMsgID, dialogWindow, dialogWindow);
 309     PostMessage(destHwnd, theFromJavaHelloMsgID, (WPARAM) dialogWindow, (LPARAM) dialogWindow);
 310 }
 311 
 312 
 313 // -----------------------
 314 
 315 /**
 316  * sendPackage - uses SendMessage(WM_COPYDATA) to do IPC messaging
 317  *                                with the Java AccessBridge DLL
 318  *
 319  */
 320 void
 321 JavaAccessBridge::sendPackage(char *buffer, int bufsize, HWND destHwnd) {
 322     COPYDATASTRUCT toCopy;
 323     toCopy.dwData = 0;          // 32-bits we could use for something...
 324     toCopy.cbData = bufsize;
 325     toCopy.lpData = buffer;
 326 
 327     SendMessage(destHwnd, WM_COPYDATA, (WPARAM) dialogWindow, (LPARAM) &toCopy);
 328 }
 329 
 330 
 331 /**
 332  * sendJavaEventPackage - walk through ATs, sending event messages to 'em
 333  *
 334  */
 335 void
 336 JavaAccessBridge::sendJavaEventPackage(char *buffer, int bufsize, long type) {
 337 
 338     PrintDebugString("JavaAccessBridge::sendJavaEventPackage(), type = %X", type);
 339 
 340     if (ATs == (AccessBridgeATInstance *) 0) {
 341         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
 342     }
 343 
 344     AccessBridgeATInstance *ati = ATs;
 345     while (ati != (AccessBridgeATInstance *) 0) {
 346         ati->sendJavaEventPackage(buffer, bufsize, type);
 347         ati = ati->nextATInstance;
 348     }
 349 }
 350 
 351 /**
 352  * sendAccessibilityEventPackage - walk through ATs, sending event messages to 'em
 353  *
 354  */
 355 void
 356 JavaAccessBridge::sendAccessibilityEventPackage(char *buffer, int bufsize, long type) {
 357 
 358     PrintDebugString("JavaAccessBridge::sendAccessibilityEventPackage(), type = %X", type);
 359 
 360     if (ATs == (AccessBridgeATInstance *) 0) {
 361         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
 362     }
 363 
 364     AccessBridgeATInstance *ati = ATs;
 365     while (ati != (AccessBridgeATInstance *) 0) {
 366         ati->sendAccessibilityEventPackage(buffer, bufsize, type);
 367         ati = ati->nextATInstance;
 368     }
 369 }
 370 
 371 
 372 
 373 
 374 /**
 375  * receiveMemoryPackage - uses Memory-Mapped files to do IPC messaging
 376  *                        with the Java AccessBridge DLL, receiving the
 377  *                        message from Java AccessBridge DLL by reading the
 378  *                        contents of the shared memory mapped file that
 379  *                        is used for Java-initiated messages
 380  *
 381  */
 382 BOOL
 383 JavaAccessBridge::receiveMemoryPackage(HWND srcWindow, long bufsize) {
 384     char *IPCview;
 385 
 386     PrintDebugString("\r\nJavaAccessBridge::receiveMemoryPackage(%p, %d)", srcWindow, bufsize);
 387 
 388     // look-up the appropriate IPCview based on the srcHWND of the Windows AccessBridge DLL
 389     if (ATs == (AccessBridgeATInstance *) 0) {
 390         PrintDebugString("  ERROR! - ATs == 0 (shouldn't happen in receiveMemoryPackage()!");
 391         return FALSE;
 392     }
 393     AccessBridgeATInstance *ati = ATs->findABATInstanceFromATHWND(srcWindow);
 394     if (ati != (AccessBridgeATInstance *) 0) {
 395         IPCview = (char *) ati->memoryMappedView;
 396 
 397         // wait for the lock if someone else has it (re-entrancy)
 398         EnterCriticalSection(&receiveMemoryIPCLock);
 399         {
 400             // set byte at end of buffer to indicate to caller that we have reached this point
 401             IPCview[bufsize] = 1;
 402 
 403             // process the package
 404             processPackage(IPCview, bufsize);
 405         }
 406         // release re-entrance lock
 407         LeaveCriticalSection(&receiveMemoryIPCLock);
 408 
 409         return TRUE;
 410 
 411     } else {
 412         //DEBUG_CODE(AppendToCallInfo("ERROR receiving memory package: couldn't find srcWindow"));
 413         PrintDebugString("ERROR receiving memory package: couldn't find srcWindow");
 414         return FALSE;
 415     }
 416 }
 417 
 418 /**
 419  * processPackage - processes the output of SendMessage(WM_COPYDATA)
 420  *                                      to do IPC messaging with the Windows AccessBridge DLL
 421  *
 422  */
 423 LRESULT
 424 JavaAccessBridge::processPackage(char *buffer, int bufsize) {
 425     PrintDebugString("\r\nProcessing package sent from Windows, bufsize = %d:", bufsize);
 426 
 427     PackageType *type = (PackageType *) buffer;
 428     LRESULT returnVal = 0;
 429     PrintDebugString("  PackageType = %X:", *type);
 430     jobject rAC;
 431 
 432     switch (*type) {
 433 
 434 
 435     case cMemoryMappedFileCreatedPackage:
 436         // Windows is telling us it created a memory mapped file for us to use
 437         // in repsonding to various information querying packages (see below)
 438         PrintDebugString("   type == cMemoryMappedFileCreatedPackage");
 439         if (bufsize == (sizeof(PackageType) + sizeof(MemoryMappedFileCreatedPackage))) {
 440             MemoryMappedFileCreatedPackage *pkg =
 441                 (MemoryMappedFileCreatedPackage *) (buffer + sizeof(PackageType));
 442             returnVal = MemoryMappedFileCreated((HWND)ABLongToHandle(pkg->bridgeWindow), pkg->filename);
 443         } else {
 444             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 445                              bufsize, sizeof(PackageType) + sizeof(MemoryMappedFileCreatedPackage));
 446         }
 447         break;
 448 
 449         // ------------ information querying packages ------------------
 450 
 451     case cReleaseJavaObjectPackage:
 452         PrintDebugString("   type == cReleaseJavaObjectPackage");
 453         if (bufsize == (sizeof(PackageType) + sizeof(ReleaseJavaObjectPackage))) {
 454             ReleaseJavaObjectPackage *pkg =
 455                 (ReleaseJavaObjectPackage *) (buffer + sizeof(PackageType));
 456             releaseJavaObject((jobject)pkg->object);
 457         } else {
 458             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 459                              bufsize, sizeof(PackageType) + sizeof(ReleaseJavaObjectPackage));
 460         }
 461         break;
 462 
 463     case cGetAccessBridgeVersionPackage:
 464         PrintDebugString("   type == cGetAccessBridgeVersionPackage");
 465         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessBridgeVersionPackage))) {
 466             GetAccessBridgeVersionPackage *pkg =
 467                 (GetAccessBridgeVersionPackage *) (buffer + sizeof(PackageType));
 468             windowsThreadEntryPoints->getVersionInfo(&(pkg->rVersionInfo));
 469         } else {
 470             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 471                              bufsize, sizeof(PackageType) + sizeof(GetAccessBridgeVersionPackage));
 472         }
 473         break;
 474 
 475     case cIsJavaWindowPackage:
 476         PrintDebugString("   type == cIsJavaWindowPackage");
 477         if (bufsize == (sizeof(PackageType) + sizeof(IsJavaWindowPackage))) {
 478             IsJavaWindowPackage *pkg =
 479                 (IsJavaWindowPackage *) (buffer + sizeof(PackageType));
 480             pkg->rResult =
 481                 windowsThreadEntryPoints->isJavaWindow(pkg->window);
 482             PrintDebugString("     -> returning result = %d", pkg->rResult);
 483         } else {
 484             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 485                              bufsize, sizeof(PackageType) + sizeof(IsJavaWindowPackage));
 486         }
 487         break;
 488 
 489     case cIsSameObjectPackage:
 490         PrintDebugString("   type == cIsSameObjectPackage");
 491         if (bufsize == (sizeof(PackageType) + sizeof(IsSameObjectPackage))) {
 492             IsSameObjectPackage *pkg =
 493                 (IsSameObjectPackage *) (buffer + sizeof(PackageType));
 494             pkg->rResult =
 495                 windowsThreadEntryPoints->isSameObject((jobject)pkg->obj1, (jobject)pkg->obj2);
 496             PrintDebugString("     -> returning result = %d", pkg->rResult);
 497         } else {
 498             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 499                              bufsize, sizeof(PackageType) + sizeof(IsSameObjectPackage));
 500         }
 501         break;
 502 
 503 
 504     case cGetAccessibleContextFromHWNDPackage:
 505         PrintDebugString("   type == cGetAccessibleContextFromHWNDPackage");
 506         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleContextFromHWNDPackage))) {
 507             GetAccessibleContextFromHWNDPackage *pkg =
 508                 (GetAccessibleContextFromHWNDPackage *) (buffer + sizeof(PackageType));
 509             rAC = windowsThreadEntryPoints->getAccessibleContextFromHWND(pkg->window);
 510             pkg->rAccessibleContext = (JOBJECT64)rAC;
 511             pkg->rVMID = HandleToLong(dialogWindow);
 512             PrintDebugString("     -> returning AC = %p, vmID = %X", rAC, pkg->rVMID);
 513         } else {
 514             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 515                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleContextFromHWNDPackage));
 516         }
 517         break;
 518 
 519 
 520     case cGetHWNDFromAccessibleContextPackage:
 521         PrintDebugString("   type == cGetHWNDFromAccessibleContextPackage");
 522         if (bufsize == (sizeof(PackageType) + sizeof(GetHWNDFromAccessibleContextPackage))) {
 523             GetHWNDFromAccessibleContextPackage *pkg =
 524                 (GetHWNDFromAccessibleContextPackage *) (buffer + sizeof(PackageType));
 525             pkg->rHWND =
 526                 ABHandleToLong( windowsThreadEntryPoints->getHWNDFromAccessibleContext((jobject)pkg->accessibleContext) );
 527             PrintDebugString("     -> returning HWND = %p", pkg->rHWND);
 528         } else {
 529             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 530                              bufsize, sizeof(PackageType) + sizeof(GetHWNDFromAccessibleContextPackage));
 531         }
 532         break;
 533 
 534 
 535         /* ===== utility methods ===== */
 536 
 537     case cSetTextContentsPackage:
 538         PrintDebugString("   type == cSetTextContentsPackage");
 539         if (bufsize == (sizeof(PackageType) + sizeof(SetTextContentsPackage))) {
 540             SetTextContentsPackage *pkg =
 541                 (SetTextContentsPackage *) (buffer + sizeof(PackageType));
 542             pkg->rResult =
 543                 windowsThreadEntryPoints->setTextContents((jobject)pkg->accessibleContext, pkg->text);
 544             PrintDebugString("     -> returning result = %d", pkg->rResult);
 545         } else {
 546             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 547                              bufsize, sizeof(PackageType) + sizeof(SetTextContentsPackage));
 548         }
 549         break;
 550 
 551     case cGetParentWithRolePackage:
 552         if (bufsize == (sizeof(PackageType) + sizeof(GetParentWithRolePackage))) {
 553             GetParentWithRolePackage *pkg =
 554                 (GetParentWithRolePackage *) (buffer + sizeof(PackageType));
 555             rAC = windowsThreadEntryPoints->getParentWithRole((jobject)pkg->accessibleContext, pkg->role);
 556             pkg->rAccessibleContext = (JOBJECT64)rAC;
 557             PrintDebugString("   type == cGetParentWithRolePackage");
 558             PrintDebugString("     pkg->vmID: %X", pkg->vmID);
 559             PrintDebugString("     pkg->accessibleContext: %p", (jobject)pkg->accessibleContext);
 560             PrintDebugString("     pkg->role: %ls", pkg->role);
 561             PrintDebugString("     -> returning rAccessibleContext = %p", rAC);
 562         } else {
 563             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 564                              bufsize, sizeof(PackageType) + sizeof(GetParentWithRolePackage));
 565         }
 566         break;
 567 
 568     case cGetTopLevelObjectPackage:
 569         PrintDebugString("   type == cGetTopLevelObjectPackage");
 570         if (bufsize == (sizeof(PackageType) + sizeof(GetTopLevelObjectPackage))) {
 571             GetTopLevelObjectPackage *pkg =
 572                 (GetTopLevelObjectPackage *) (buffer + sizeof(PackageType));
 573             rAC = windowsThreadEntryPoints->getTopLevelObject((jobject)pkg->accessibleContext);
 574             pkg->rAccessibleContext = (JOBJECT64)rAC;
 575             PrintDebugString("     -> returning rAccessibleContext = %p", rAC);
 576         } else {
 577             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 578                              bufsize, sizeof(PackageType) + sizeof(GetTopLevelObjectPackage));
 579         }
 580         break;
 581 
 582     case cGetParentWithRoleElseRootPackage:
 583         PrintDebugString("   type == cGetParentWithRoleElseRootPackage");
 584         if (bufsize == (sizeof(PackageType) + sizeof(GetParentWithRoleElseRootPackage))) {
 585             GetParentWithRoleElseRootPackage *pkg =
 586                 (GetParentWithRoleElseRootPackage *) (buffer + sizeof(PackageType));
 587             rAC = windowsThreadEntryPoints->getParentWithRoleElseRoot((jobject)pkg->accessibleContext, pkg->role);
 588             pkg->rAccessibleContext = (JOBJECT64)rAC;
 589             PrintDebugString("     -> returning rAccessibleContext = %p", rAC);
 590         } else {
 591             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 592                              bufsize, sizeof(PackageType) + sizeof(GetParentWithRoleElseRootPackage));
 593         }
 594         break;
 595 
 596     case cGetObjectDepthPackage:
 597         PrintDebugString("   type == cGetObjectDepthPackage");
 598         if (bufsize == (sizeof(PackageType) + sizeof(GetObjectDepthPackage))) {
 599             GetObjectDepthPackage *pkg =
 600                 (GetObjectDepthPackage *) (buffer + sizeof(PackageType));
 601             pkg->rResult =
 602                 windowsThreadEntryPoints->getObjectDepth((jobject)pkg->accessibleContext);
 603             PrintDebugString("     -> returning rResult = %d", pkg->rResult);
 604         } else {
 605             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 606                              bufsize, sizeof(PackageType) + sizeof(GetObjectDepthPackage));
 607         }
 608         break;
 609 
 610     case cGetActiveDescendentPackage:
 611         PrintDebugString("   type == cGetActiveDescendentPackage");
 612         if (bufsize == (sizeof(PackageType) + sizeof(GetActiveDescendentPackage))) {
 613             GetActiveDescendentPackage *pkg =
 614                 (GetActiveDescendentPackage *) (buffer + sizeof(PackageType));
 615             rAC = windowsThreadEntryPoints->getActiveDescendent((jobject)pkg->accessibleContext);
 616             pkg->rAccessibleContext = (JOBJECT64)rAC;
 617             PrintDebugString("     -> returning rAccessibleContext = %p", rAC);
 618         } else {
 619             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 620                              bufsize, sizeof(PackageType) + sizeof(GetActiveDescendentPackage));
 621         }
 622         break;
 623 
 624     case cGetAccessibleContextAtPackage:
 625         PrintDebugString("   type == cGetAccessibleContextAtPackage");
 626         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleContextAtPackage))) {
 627             GetAccessibleContextAtPackage *pkg =
 628                 (GetAccessibleContextAtPackage *) (buffer + sizeof(PackageType));
 629             pkg->rAccessibleContext = (JOBJECT64)
 630                 windowsThreadEntryPoints->getAccessibleContextAt(pkg->x, pkg->y,
 631                                                                  (jobject)pkg->AccessibleContext);
 632         } else {
 633             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 634                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleContextAtPackage));
 635         }
 636         break;
 637 
 638     case cGetAccessibleContextWithFocusPackage:
 639         PrintDebugString("   type == cGetAccessibleContextWithFocusPackage");
 640         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleContextWithFocusPackage))) {
 641             GetAccessibleContextWithFocusPackage *pkg =
 642                 (GetAccessibleContextWithFocusPackage *) (buffer + sizeof(PackageType));
 643             pkg->rAccessibleContext = (JOBJECT64)
 644                 windowsThreadEntryPoints->getAccessibleContextWithFocus();
 645                         pkg->rVMID =  HandleToLong(dialogWindow);
 646         } else {
 647             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 648                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleContextWithFocusPackage));
 649         }
 650         break;
 651 
 652     case cGetAccessibleContextInfoPackage:
 653         PrintDebugString("   type == cGetAccessibleContextInfoPackage");
 654         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleContextInfoPackage))) {
 655             GetAccessibleContextInfoPackage *pkg =
 656                 (GetAccessibleContextInfoPackage *) (buffer + sizeof(PackageType));
 657             windowsThreadEntryPoints->getAccessibleContextInfo(
 658                                                                (jobject)pkg->AccessibleContext, &(pkg->rAccessibleContextInfo));
 659         } else {
 660             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 661                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleContextInfoPackage));
 662         }
 663         break;
 664 
 665     case cGetAccessibleChildFromContextPackage:
 666         PrintDebugString("   type == cGetAccessibleChildFromContextPackage");
 667         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleChildFromContextPackage))) {
 668             GetAccessibleChildFromContextPackage *pkg =
 669                 (GetAccessibleChildFromContextPackage *) (buffer + sizeof(PackageType));
 670             pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleChildFromContext(
 671                                                                                               (jobject)pkg->AccessibleContext, pkg->childIndex);
 672         } else {
 673             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 674                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleChildFromContextPackage));
 675         }
 676         break;
 677 
 678     case cGetAccessibleParentFromContextPackage:
 679         PrintDebugString("   type == cGetAccessibleParentFromContextPackage");
 680         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleParentFromContextPackage))) {
 681             GetAccessibleParentFromContextPackage *pkg =
 682                 (GetAccessibleParentFromContextPackage *) (buffer + sizeof(PackageType));
 683             pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleParentFromContext(
 684                                                                                                (jobject)pkg->AccessibleContext);
 685         } else {
 686             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
 687                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleParentFromContextPackage));
 688         }
 689         break;
 690 
 691         // ------------ begin AccessibleTable packages ------------------
 692 
 693     case cGetAccessibleTableInfoPackage:
 694         PrintDebugString("   ##### type == cGetAccessibleTableInfoPackage");
 695         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableInfoPackage))) {
 696             GetAccessibleTableInfoPackage *pkg =
 697                 (GetAccessibleTableInfoPackage *) (buffer + sizeof(PackageType));
 698             windowsThreadEntryPoints->getAccessibleTableInfo((jobject)pkg->accessibleContext,
 699                                                              &(pkg->rTableInfo));
 700             PrintDebugString("   ##### processing succeeded");
 701         } else {
 702             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 703                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableInfoPackage));
 704         }
 705         break;
 706 
 707     case cGetAccessibleTableCellInfoPackage:
 708         PrintDebugString("   ##### type == cGetAccessibleTableCellInfoPackage");
 709         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableCellInfoPackage))) {
 710             GetAccessibleTableCellInfoPackage *pkg =
 711                 (GetAccessibleTableCellInfoPackage *) (buffer + sizeof(PackageType));
 712             windowsThreadEntryPoints->getAccessibleTableCellInfo((jobject)pkg->accessibleTable, pkg->row,
 713                                                                  pkg->column, &(pkg->rTableCellInfo));
 714             PrintDebugString("   ##### processing succeeded");
 715         } else {
 716             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 717                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableCellInfoPackage));
 718         }
 719         break;
 720 
 721     case cGetAccessibleTableRowHeaderPackage:
 722         PrintDebugString("   ##### type == cGetAccessibleTableRowHeaderPackage");
 723         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowHeaderPackage))) {
 724             GetAccessibleTableRowHeaderPackage *pkg =
 725                 (GetAccessibleTableRowHeaderPackage *) (buffer + sizeof(PackageType));
 726             windowsThreadEntryPoints->getAccessibleTableRowHeader((jobject)pkg->accessibleContext,
 727                                                                   &(pkg->rTableInfo));
 728             PrintDebugString("   ##### processing succeeded");
 729         } else {
 730             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 731                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowHeaderPackage));
 732         }
 733         break;
 734 
 735     case cGetAccessibleTableColumnHeaderPackage:
 736         PrintDebugString("   ##### type == cGetAccessibleTableColumnHeaderPackage");
 737         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnHeaderPackage))) {
 738             GetAccessibleTableColumnHeaderPackage *pkg =
 739                 (GetAccessibleTableColumnHeaderPackage *) (buffer + sizeof(PackageType));
 740             windowsThreadEntryPoints->getAccessibleTableColumnHeader((jobject)pkg->accessibleContext,
 741                                                                      &(pkg->rTableInfo));
 742             PrintDebugString("   ##### processing succeeded");
 743         } else {
 744             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 745                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnHeaderPackage));
 746         }
 747         break;
 748 
 749 
 750     case cGetAccessibleTableRowDescriptionPackage:
 751         PrintDebugString("   ##### type == cGetAccessibleTableRowDescriptionPackage");
 752         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowDescriptionPackage))) {
 753             GetAccessibleTableRowDescriptionPackage *pkg =
 754                 (GetAccessibleTableRowDescriptionPackage *) (buffer + sizeof(PackageType));
 755             pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleTableRowDescription(
 756                                                                                                  (jobject)pkg->accessibleContext, pkg->row);
 757             PrintDebugString("   ##### processing succeeded");
 758         } else {
 759             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 760                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowDescriptionPackage));
 761         }
 762         break;
 763 
 764     case cGetAccessibleTableColumnDescriptionPackage:
 765         PrintDebugString("   ##### type == cGetAccessibleTableColumnDescriptionPackage");
 766         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnDescriptionPackage))) {
 767             GetAccessibleTableColumnDescriptionPackage *pkg =
 768                 (GetAccessibleTableColumnDescriptionPackage *) (buffer + sizeof(PackageType));
 769             pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleTableColumnDescription(
 770                                                                                                     (jobject)pkg->accessibleContext, pkg->column);
 771             PrintDebugString("   ##### processing succeeded");
 772         } else {
 773             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 774                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnDescriptionPackage));
 775         }
 776         break;
 777 
 778     case cGetAccessibleTableColumnSelectionCountPackage:
 779         PrintDebugString("   ##### type == cGetAccessibleTableColumnSelectionCountPackage");
 780         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnSelectionCountPackage))) {
 781             GetAccessibleTableColumnSelectionCountPackage *pkg =
 782                 (GetAccessibleTableColumnSelectionCountPackage *) (buffer + sizeof(PackageType));
 783             pkg->rCount = windowsThreadEntryPoints->getAccessibleTableColumnSelectionCount(
 784                                                                                            (jobject)pkg->accessibleTable);
 785             PrintDebugString("   ##### processing succeeded");
 786         } else {
 787             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 788                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnSelectionCountPackage));
 789         }
 790         break;
 791 
 792     case cGetAccessibleTableRowSelectionCountPackage:
 793         PrintDebugString("   ##### type == cGetAccessibleTableRowSelectionCountPackage");
 794         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowSelectionCountPackage))) {
 795             GetAccessibleTableRowSelectionCountPackage *pkg =
 796                 (GetAccessibleTableRowSelectionCountPackage *) (buffer + sizeof(PackageType));
 797 
 798             pkg->rCount = windowsThreadEntryPoints->getAccessibleTableRowSelectionCount(
 799                                                                                         (jobject)pkg->accessibleTable);
 800 
 801             PrintDebugString("   ##### processing succeeded");
 802         } else {
 803             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 804                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowSelectionCountPackage));
 805         }
 806         break;
 807 
 808     case cIsAccessibleTableRowSelectedPackage:
 809         PrintDebugString("   ##### type == cIsAccessibleTableRowSelectedPackage");
 810         if (bufsize == (sizeof(PackageType) + sizeof(IsAccessibleTableRowSelectedPackage))) {
 811             IsAccessibleTableRowSelectedPackage *pkg =
 812                 (IsAccessibleTableRowSelectedPackage *) (buffer + sizeof(PackageType));
 813             pkg->rResult = windowsThreadEntryPoints->isAccessibleTableRowSelected(
 814                                                                                   (jobject)pkg->accessibleTable, pkg->row);
 815             PrintDebugString("   ##### processing succeeded");
 816         } else {
 817             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 818                              bufsize, sizeof(PackageType) + sizeof(IsAccessibleTableRowSelectedPackage));
 819         }
 820         break;
 821 
 822     case cIsAccessibleTableColumnSelectedPackage:
 823         PrintDebugString("   ##### type == cIsAccessibleTableColumnSelectedPackage");
 824         if (bufsize == (sizeof(PackageType) + sizeof(IsAccessibleTableColumnSelectedPackage))) {
 825             IsAccessibleTableColumnSelectedPackage *pkg =
 826                 (IsAccessibleTableColumnSelectedPackage *) (buffer + sizeof(PackageType));
 827             pkg->rResult = windowsThreadEntryPoints->isAccessibleTableColumnSelected(
 828                                                                                      (jobject)pkg->accessibleTable, pkg->column);
 829             PrintDebugString("   ##### processing succeeded");
 830         } else {
 831             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 832                              bufsize, sizeof(PackageType) + sizeof(IsAccessibleTableColumnSelectedPackage));
 833         }
 834         break;
 835 
 836     case cGetAccessibleTableColumnSelectionsPackage:
 837         PrintDebugString("   ##### type == cGetAccessibleTableColumnSelectionsPackage");
 838         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnSelectionsPackage))) {
 839             GetAccessibleTableColumnSelectionsPackage *pkg =
 840                 (GetAccessibleTableColumnSelectionsPackage *) (buffer + sizeof(PackageType));
 841             PrintDebugString("     ##### cGetAccessibleTableColumnSelectionsPackage count=%d", pkg->count);
 842             windowsThreadEntryPoints->getAccessibleTableColumnSelections(
 843                                                                          (jobject)pkg->accessibleTable, pkg->count, pkg->rSelections);
 844 
 845             for (int i = 0; i < pkg->count; i++) {
 846                 PrintDebugString("     ##### cGetAccessibleTableColumnSelectionsPackage(%d)=%d", i, pkg->rSelections[i]);
 847             }
 848 
 849             PrintDebugString("   ##### processing succeeded");
 850         } else {
 851             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 852                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnSelectionsPackage));
 853         }
 854         break;
 855 
 856 
 857     case cGetAccessibleTableRowSelectionsPackage:
 858         PrintDebugString("   ##### type == cGetAccessibleTableRowSelectionsPackage");
 859         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowSelectionsPackage))) {
 860             GetAccessibleTableRowSelectionsPackage *pkg =
 861                 (GetAccessibleTableRowSelectionsPackage *) (buffer + sizeof(PackageType));
 862             windowsThreadEntryPoints->getAccessibleTableRowSelections(
 863                                                                       (jobject)pkg->accessibleTable, pkg->count, pkg->rSelections);
 864             PrintDebugString("   ##### processing succeeded");
 865         } else {
 866             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 867                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowSelectionsPackage));
 868         }
 869         break;
 870 
 871     case cGetAccessibleTableRowPackage:
 872         PrintDebugString("   ##### type == cGetAccessibleTableRowPackage");
 873         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowPackage))) {
 874             GetAccessibleTableRowPackage *pkg =
 875                 (GetAccessibleTableRowPackage *) (buffer + sizeof(PackageType));
 876             pkg->rRow = windowsThreadEntryPoints->getAccessibleTableRow(
 877                                                                         (jobject)pkg->accessibleTable, pkg->index);
 878             PrintDebugString("   ##### processing succeeded");
 879         } else {
 880             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 881                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowPackage));
 882         }
 883         break;
 884 
 885     case cGetAccessibleTableColumnPackage:
 886         PrintDebugString("   ##### type == cGetAccessibleTableColumnPackage");
 887         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnPackage))) {
 888             GetAccessibleTableColumnPackage *pkg =
 889                 (GetAccessibleTableColumnPackage *) (buffer + sizeof(PackageType));
 890             pkg->rColumn = windowsThreadEntryPoints->getAccessibleTableColumn(
 891                                                                               (jobject)pkg->accessibleTable, pkg->index);
 892             PrintDebugString("   ##### processing succeeded");
 893         } else {
 894             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 895                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnPackage));
 896         }
 897         break;
 898 
 899     case cGetAccessibleTableIndexPackage:
 900         PrintDebugString("   ##### type == cGetAccessibleTableIndexPackage");
 901         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableIndexPackage))) {
 902             GetAccessibleTableIndexPackage *pkg =
 903                 (GetAccessibleTableIndexPackage *) (buffer + sizeof(PackageType));
 904             pkg->rIndex = windowsThreadEntryPoints->getAccessibleTableIndex(
 905                                                                             (jobject)pkg->accessibleTable, pkg->row, pkg->column);
 906             PrintDebugString("   ##### processing succeeded");
 907         } else {
 908             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 909                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableIndexPackage));
 910         }
 911         break;
 912 
 913         // ------------ end AccessibleTable packages ------------------
 914 
 915 
 916         // ------------ begin AccessibleRelationSet packages ------------------
 917 
 918     case cGetAccessibleRelationSetPackage:
 919         PrintDebugString("   ##### type == cGetAccessibleRelationSetPackage");
 920         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleRelationSetPackage))) {
 921             GetAccessibleRelationSetPackage *pkg =
 922                 (GetAccessibleRelationSetPackage *) (buffer + sizeof(PackageType));
 923             windowsThreadEntryPoints->getAccessibleRelationSet(
 924                                                                (jobject)pkg->accessibleContext, &(pkg->rAccessibleRelationSetInfo));
 925             PrintDebugString("   ##### processing succeeded");
 926         } else {
 927             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 928                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleRelationSetPackage));
 929         }
 930         break;
 931 
 932         // ------------ end AccessibleRelationSet packages ------------------
 933 
 934         // ------------ begin AccessibleHypertext packages ------------------
 935 
 936     case cGetAccessibleHypertextPackage:
 937         PrintDebugString("   ##### type == cGetAccessibleHypertextPackage");
 938         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHypertextPackage))) {
 939             GetAccessibleHypertextPackage *pkg =
 940                 (GetAccessibleHypertextPackage *) (buffer + sizeof(PackageType));
 941             windowsThreadEntryPoints->getAccessibleHypertext(
 942                                                              (jobject)pkg->accessibleContext, &(pkg->rAccessibleHypertextInfo));
 943             PrintDebugString("   ##### processing succeeded");
 944         } else {
 945             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 946                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleHypertextPackage));
 947         }
 948         break;
 949 
 950     case cActivateAccessibleHyperlinkPackage:
 951         PrintDebugString("   ##### type == cActivateAccessibleHyperlinkPackage");
 952         if (bufsize == (sizeof(PackageType) + sizeof(ActivateAccessibleHyperlinkPackage))) {
 953             ActivateAccessibleHyperlinkPackage *pkg =
 954                 (ActivateAccessibleHyperlinkPackage *) (buffer + sizeof(PackageType));
 955             pkg->rResult = windowsThreadEntryPoints->activateAccessibleHyperlink(
 956                                                                                  (jobject)pkg->accessibleContext, (jobject)pkg->accessibleHyperlink);
 957             PrintDebugString("   ##### processing succeeded");
 958         } else {
 959             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 960                              bufsize, sizeof(PackageType) + sizeof(ActivateAccessibleHyperlinkPackage));
 961         }
 962         break;
 963 
 964     case cGetAccessibleHyperlinkCountPackage:
 965         PrintDebugString("   ##### type == cGetAccessibleHyperlinkCountPackage");
 966         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHyperlinkCountPackage))) {
 967             GetAccessibleHyperlinkCountPackage *pkg =
 968                 (GetAccessibleHyperlinkCountPackage *) (buffer + sizeof(PackageType));
 969             pkg->rLinkCount = windowsThreadEntryPoints->getAccessibleHyperlinkCount(
 970                                                                                     (jobject)pkg->accessibleContext);
 971             PrintDebugString("   ##### processing succeeded: pkg->rLinkCount = %d", pkg->rLinkCount);
 972         } else {
 973             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 974                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleHyperlinkCountPackage));
 975         }
 976         break;
 977 
 978     case cGetAccessibleHypertextExtPackage:
 979         PrintDebugString("   ##### type == cGetAccessibleHypertextExtPackage");
 980         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHypertextExtPackage))) {
 981             GetAccessibleHypertextExtPackage *pkg =
 982                 (GetAccessibleHypertextExtPackage *) (buffer + sizeof(PackageType));
 983             pkg->rSuccess = windowsThreadEntryPoints->getAccessibleHypertextExt(
 984                                                                                 (jobject)pkg->accessibleContext, pkg->startIndex, &(pkg->rAccessibleHypertextInfo));
 985             PrintDebugString("   ##### processing succeeded");
 986         } else {
 987             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
 988                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleHypertextExtPackage));
 989         }
 990         break;
 991 
 992     case cGetAccessibleHypertextLinkIndexPackage:
 993         PrintDebugString("   ##### type == cGetAccessibleHypertextLinkIndexPackage");
 994         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHypertextLinkIndexPackage))) {
 995             GetAccessibleHypertextLinkIndexPackage *pkg =
 996                 (GetAccessibleHypertextLinkIndexPackage *) (buffer + sizeof(PackageType));
 997             pkg->rLinkIndex = windowsThreadEntryPoints->getAccessibleHypertextLinkIndex(
 998                                                                                         (jobject)pkg->hypertext, pkg->charIndex);
 999             PrintDebugString("   ##### processing succeeded");
1000         } else {
1001             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1002                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleHypertextLinkIndexPackage));
1003         }
1004         break;
1005 
1006     case cGetAccessibleHyperlinkPackage:
1007         PrintDebugString("   ##### type == cGetAccessibleHyperlinkPackage");
1008         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHyperlinkPackage))) {
1009             GetAccessibleHyperlinkPackage *pkg =
1010                 (GetAccessibleHyperlinkPackage *) (buffer + sizeof(PackageType));
1011             windowsThreadEntryPoints->getAccessibleHyperlink((jobject)pkg->hypertext, pkg->linkIndex,
1012                                                              &(pkg->rAccessibleHyperlinkInfo));
1013             PrintDebugString("   ##### processing succeeded");
1014         } else {
1015             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1016                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleHyperlinkPackage));
1017         }
1018         break;
1019 
1020         // ------------ end AccessibleHypertext packages
1021 
1022         // ------------ begin Accessible KeyBindings, Icons and Actions
1023 
1024     case cGetAccessibleKeyBindingsPackage:
1025         PrintDebugString("   ##### type == cGetAccessibleKeyBindingsPackage");
1026         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleKeyBindingsPackage))) {
1027             GetAccessibleKeyBindingsPackage *pkg =
1028                 (GetAccessibleKeyBindingsPackage *) (buffer + sizeof(PackageType));
1029             windowsThreadEntryPoints->getAccessibleKeyBindings (
1030                                                                 (jobject)pkg->accessibleContext, &(pkg->rAccessibleKeyBindings));
1031             PrintDebugString("   ##### processing succeeded");
1032         } else {
1033             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1034                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleKeyBindingsPackage));
1035         }
1036         break;
1037 
1038     case cGetAccessibleIconsPackage:
1039         PrintDebugString("   ##### type == cGetAccessibleIconsPackage");
1040         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleIconsPackage))) {
1041             GetAccessibleIconsPackage *pkg =
1042                 (GetAccessibleIconsPackage *) (buffer + sizeof(PackageType));
1043             windowsThreadEntryPoints->getAccessibleIcons (
1044                                                           (jobject)pkg->accessibleContext, &(pkg->rAccessibleIcons));
1045             PrintDebugString("   ##### processing succeeded");
1046         } else {
1047             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1048                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleIconsPackage));
1049         }
1050         break;
1051 
1052 
1053     case cGetAccessibleActionsPackage:
1054         PrintDebugString("   ##### type == cGetAccessibleActionsPackage");
1055         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleActionsPackage))) {
1056             GetAccessibleActionsPackage *pkg =
1057                 (GetAccessibleActionsPackage *) (buffer + sizeof(PackageType));
1058             windowsThreadEntryPoints->getAccessibleActions (
1059                                                             (jobject)pkg->accessibleContext, &(pkg->rAccessibleActions));
1060             PrintDebugString("   ##### processing succeeded");
1061         } else {
1062             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1063                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleActionsPackage));
1064         }
1065         break;
1066 
1067     case cDoAccessibleActionsPackage:
1068         PrintDebugString("   ##### type == cDoAccessibleActionsPackage");
1069         if (bufsize == (sizeof(PackageType) + sizeof(DoAccessibleActionsPackage))) {
1070             DoAccessibleActionsPackage *pkg =
1071                 (DoAccessibleActionsPackage *) (buffer + sizeof(PackageType));
1072             pkg->rResult =
1073                 windowsThreadEntryPoints->doAccessibleActions((jobject)pkg->accessibleContext, &(pkg->actionsToDo),
1074                                                               &(pkg->failure));
1075             PrintDebugString("   ##### processing succeeded");
1076         } else {
1077             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1078                              bufsize, sizeof(PackageType) + sizeof(DoAccessibleActionsPackage));
1079         }
1080         break;
1081 
1082         // ------------ begin addtional methods for Teton
1083 
1084     case cGetVirtualAccessibleNamePackage:
1085         PrintDebugString("   ##### type == GetVirtualAccessibleNamePackage");
1086         if (bufsize == (sizeof(PackageType) + sizeof(GetVirtualAccessibleNamePackage))) {
1087             GetVirtualAccessibleNamePackage *pkg =
1088                 (GetVirtualAccessibleNamePackage *) (buffer + sizeof(PackageType));
1089             windowsThreadEntryPoints->getVirtualAccessibleName ((const jobject)pkg->accessibleContext,
1090                                                              pkg->rName,
1091                                                              pkg->len);
1092             PrintDebugString("   ##### processing succeeded");
1093         } else {
1094             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1095                              bufsize, sizeof(PackageType) + sizeof(GetVirtualAccessibleNamePackage));
1096         }
1097         break;
1098 
1099     case cRequestFocusPackage:
1100         PrintDebugString("   ##### type == RequestFocusPackage");
1101         if (bufsize == (sizeof(PackageType) + sizeof(RequestFocusPackage))) {
1102             RequestFocusPackage *pkg =
1103                 (RequestFocusPackage *) (buffer + sizeof(PackageType));
1104             windowsThreadEntryPoints->requestFocus (
1105                                                     (jobject)pkg->accessibleContext);
1106             PrintDebugString("   ##### processing succeeded");
1107         } else {
1108             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1109                              bufsize, sizeof(PackageType) + sizeof(RequestFocusPackage));
1110         }
1111         break;
1112 
1113     case cSelectTextRangePackage:
1114         PrintDebugString("   ##### type == SelectTextRangePackage");
1115         if (bufsize == (sizeof(PackageType) + sizeof(SelectTextRangePackage))) {
1116             SelectTextRangePackage *pkg =
1117                 (SelectTextRangePackage *) (buffer + sizeof(PackageType));
1118             windowsThreadEntryPoints->selectTextRange (
1119                                                        (jobject)pkg->accessibleContext, pkg->startIndex, pkg->endIndex);
1120             PrintDebugString("   ##### processing succeeded");
1121         } else {
1122             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1123                              bufsize, sizeof(PackageType) + sizeof(SelectTextRangePackage));
1124         }
1125         break;
1126 
1127     case cGetTextAttributesInRangePackage:
1128         PrintDebugString("   ##### type == GetTextAttributesInRangePackage");
1129         if (bufsize == (sizeof(PackageType) + sizeof(GetTextAttributesInRangePackage))) {
1130             GetTextAttributesInRangePackage *pkg =
1131                 (GetTextAttributesInRangePackage *) (buffer + sizeof(PackageType));
1132             windowsThreadEntryPoints->getTextAttributesInRange (
1133                                                                 (jobject)pkg->accessibleContext, pkg->startIndex, pkg->endIndex,
1134                                                                 (AccessibleTextAttributesInfo *)&(pkg->attributes),
1135                                                                 &(pkg->rLength));
1136             PrintDebugString("   ##### processing succeeded");
1137         } else {
1138             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1139                              bufsize, sizeof(PackageType) + sizeof(GetTextAttributesInRangePackage));
1140         }
1141         break;
1142 
1143 
1144     case cGetVisibleChildrenCountPackage:
1145         PrintDebugString("   ##### type == GetVisibleChildrenCountPackage");
1146         if (bufsize == (sizeof(PackageType) + sizeof(GetVisibleChildrenCountPackage))) {
1147             GetVisibleChildrenCountPackage *pkg =
1148                 (GetVisibleChildrenCountPackage *) (buffer + sizeof(PackageType));
1149             pkg->rChildrenCount = windowsThreadEntryPoints->getVisibleChildrenCount ((jobject)pkg->accessibleContext);
1150 
1151             PrintDebugString("   ##### processing succeeded");
1152         } else {
1153             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1154                              bufsize, sizeof(PackageType) + sizeof(GetVisibleChildrenCountPackage));
1155         }
1156         break;
1157 
1158     case cGetVisibleChildrenPackage:
1159         PrintDebugString("   ##### type == GetVisibleChildrenPackage");
1160         if (bufsize == (sizeof(PackageType) + sizeof(GetVisibleChildrenPackage))) {
1161             GetVisibleChildrenPackage *pkg =
1162                 (GetVisibleChildrenPackage *) (buffer + sizeof(PackageType));
1163             pkg->rSuccess = windowsThreadEntryPoints->getVisibleChildren ((jobject)pkg->accessibleContext,
1164                                                                           pkg->startIndex,
1165                                                                           &(pkg->rVisibleChildrenInfo));
1166 
1167             PrintDebugString("   ##### processing succeeded");
1168         } else {
1169             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1170                              bufsize, sizeof(PackageType) + sizeof(GetVisibleChildrenPackage));
1171         }
1172         break;
1173 
1174     case cSetCaretPositionPackage:
1175         PrintDebugString("   ##### type == SetCaretPositionPackage");
1176         if (bufsize == (sizeof(PackageType) + sizeof(SetCaretPositionPackage))) {
1177             SetCaretPositionPackage *pkg =
1178                 (SetCaretPositionPackage *) (buffer + sizeof(PackageType));
1179             windowsThreadEntryPoints->setCaretPosition (
1180                                                         (jobject)pkg->accessibleContext, pkg->position);
1181             PrintDebugString("   ##### processing succeeded");
1182         } else {
1183             PrintDebugString("   ##### processing FAILED!! -> bufsize = %d; expectation = %d",
1184                              bufsize, sizeof(PackageType) + sizeof(SetCaretPositionPackage));
1185         }
1186         break;
1187 
1188         // ------------ end additional methods for Teton
1189 
1190         // ------------ end Accessible KeyBindings, Icons and Actions
1191 
1192         // ------------ Accessible Text packages ------------------
1193 
1194     case cGetAccessibleTextInfoPackage:
1195         PrintDebugString("   type == cGetAccessibleTextInfoPackage");
1196         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextInfoPackage))) {
1197             GetAccessibleTextInfoPackage *pkg =
1198                 (GetAccessibleTextInfoPackage *) (buffer + sizeof(PackageType));
1199             windowsThreadEntryPoints->getAccessibleTextInfo((jobject)pkg->AccessibleContext,
1200                                                             &(pkg->rTextInfo), pkg->x, pkg->y);
1201         } else {
1202             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1203                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextInfoPackage));
1204         }
1205         break;
1206 
1207     case cGetAccessibleTextItemsPackage:
1208         PrintDebugString("   type == cGetAccessibleTextItemsPackage");
1209         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextItemsPackage))) {
1210             GetAccessibleTextItemsPackage *pkg =
1211                 (GetAccessibleTextItemsPackage *) (buffer + sizeof(PackageType));
1212             windowsThreadEntryPoints->getAccessibleTextItems((jobject)pkg->AccessibleContext,
1213                                                              &(pkg->rTextItemsInfo), pkg->index);
1214         } else {
1215             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1216                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextInfoPackage));
1217         }
1218         break;
1219 
1220     case cGetAccessibleTextSelectionInfoPackage:
1221         PrintDebugString("   type == cGetAccessibleTextSelectionInfoPackage");
1222         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextSelectionInfoPackage))) {
1223             GetAccessibleTextSelectionInfoPackage *pkg =
1224                 (GetAccessibleTextSelectionInfoPackage *) (buffer + sizeof(PackageType));
1225             windowsThreadEntryPoints->getAccessibleTextSelectionInfo(
1226                                                                      (jobject)pkg->AccessibleContext, &(pkg->rTextSelectionItemsInfo));
1227         } else {
1228             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1229                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextSelectionInfoPackage));
1230         }
1231         break;
1232 
1233     case cGetAccessibleTextAttributeInfoPackage:
1234         PrintDebugString("   type == cGetAccessibleTextAttributeInfoPackage");
1235         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextAttributeInfoPackage))) {
1236             GetAccessibleTextAttributeInfoPackage *pkg =
1237                 (GetAccessibleTextAttributeInfoPackage *) (buffer + sizeof(PackageType));
1238             windowsThreadEntryPoints->getAccessibleTextAttributes(
1239                                                                   (jobject)pkg->AccessibleContext, pkg->index, (AccessibleTextAttributesInfo *) &(pkg->rAttributeInfo));
1240         } else {
1241             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1242                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextAttributeInfoPackage));
1243         }
1244         break;
1245 
1246     case cGetAccessibleTextRectInfoPackage:
1247         PrintDebugString("   type == cGetAccessibleTextRectInfoPackage");
1248         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextRectInfoPackage))) {
1249             GetAccessibleTextRectInfoPackage *pkg =
1250                 (GetAccessibleTextRectInfoPackage *) (buffer + sizeof(PackageType));
1251             windowsThreadEntryPoints->getAccessibleTextRect((jobject)pkg->AccessibleContext,
1252                                                             &(pkg->rTextRectInfo), pkg->index);
1253         } else {
1254             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1255                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextRectInfoPackage));
1256         }
1257         break;
1258 
1259     case cGetCaretLocationPackage:
1260         PrintDebugString("   type == cGetCaretLocationPackage");
1261         if (bufsize == (sizeof(PackageType) + sizeof(GetCaretLocationPackage))) {
1262             GetCaretLocationPackage *pkg =
1263                 (GetCaretLocationPackage *) (buffer + sizeof(PackageType));
1264             windowsThreadEntryPoints->getCaretLocation((jobject)pkg->AccessibleContext,
1265                                                             &(pkg->rTextRectInfo), pkg->index);
1266         } else {
1267             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1268                              bufsize, sizeof(PackageType) + sizeof(GetCaretLocationPackage));
1269         }
1270         break;
1271 
1272     case cGetAccessibleTextLineBoundsPackage:
1273         PrintDebugString("   type == cGetAccessibleTextLineBoundsPackage");
1274         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextLineBoundsPackage))) {
1275             GetAccessibleTextLineBoundsPackage *pkg =
1276                 (GetAccessibleTextLineBoundsPackage *) (buffer + sizeof(PackageType));
1277             windowsThreadEntryPoints->getAccessibleTextLineBounds((jobject)pkg->AccessibleContext,
1278                                                                   pkg->index, &(pkg->rLineStart), &(pkg->rLineEnd));
1279         } else {
1280             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1281                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextLineBoundsPackage));
1282         }
1283         break;
1284 
1285     case cGetAccessibleTextRangePackage:
1286         PrintDebugString("   type == cGetAccessibleTextRangePackage");
1287         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextRangePackage))) {
1288             GetAccessibleTextRangePackage *pkg =
1289                 (GetAccessibleTextRangePackage *) (buffer + sizeof(PackageType));
1290             windowsThreadEntryPoints->getAccessibleTextRange((jobject)pkg->AccessibleContext,
1291                                                              pkg->start, pkg->end, (wchar_t *) &(pkg->rText), (sizeof(pkg->rText) / sizeof(wchar_t)));
1292         } else {
1293             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1294                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextRangePackage));
1295         }
1296         break;
1297 
1298 
1299         // ------------ Accessible Value packages ------------------
1300 
1301     case cGetCurrentAccessibleValueFromContextPackage:
1302         PrintDebugString("   type == cGetCurrentAccessibleValueFromContextPackage");
1303         if (bufsize == (sizeof(PackageType) + sizeof(GetCurrentAccessibleValueFromContextPackage))) {
1304             GetCurrentAccessibleValueFromContextPackage *pkg =
1305                 (GetCurrentAccessibleValueFromContextPackage *) (buffer + sizeof(PackageType));
1306             windowsThreadEntryPoints->getCurrentAccessibleValueFromContext((jobject)pkg->AccessibleContext,
1307                                                                            (wchar_t *) &(pkg->rValue), (sizeof(pkg->rValue) / sizeof(wchar_t)));
1308         } else {
1309             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1310                              bufsize, sizeof(PackageType) + sizeof(GetCurrentAccessibleValueFromContextPackage));
1311         }
1312         break;
1313 
1314     case cGetMaximumAccessibleValueFromContextPackage:
1315         PrintDebugString("   type == cGetMaximumAccessibleValueFromContextPackage");
1316         if (bufsize == (sizeof(PackageType) + sizeof(GetMaximumAccessibleValueFromContextPackage))) {
1317             GetMaximumAccessibleValueFromContextPackage *pkg =
1318                 (GetMaximumAccessibleValueFromContextPackage *) (buffer + sizeof(PackageType));
1319             windowsThreadEntryPoints->getMaximumAccessibleValueFromContext((jobject)pkg->AccessibleContext,
1320                                                                            (wchar_t *) &(pkg->rValue), (sizeof(pkg->rValue) / sizeof(wchar_t)));
1321         } else {
1322             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1323                              bufsize, sizeof(PackageType) + sizeof(GetMaximumAccessibleValueFromContextPackage));
1324         }
1325         break;
1326 
1327     case cGetMinimumAccessibleValueFromContextPackage:
1328         PrintDebugString("   type == cGetMinimumAccessibleValueFromContextPackage");
1329         if (bufsize == (sizeof(PackageType) + sizeof(GetMinimumAccessibleValueFromContextPackage))) {
1330             GetMinimumAccessibleValueFromContextPackage *pkg =
1331                 (GetMinimumAccessibleValueFromContextPackage *) (buffer + sizeof(PackageType));
1332             windowsThreadEntryPoints->getMinimumAccessibleValueFromContext((jobject)pkg->AccessibleContext,
1333                                                                            (wchar_t *) &(pkg->rValue), (sizeof(pkg->rValue) / sizeof(wchar_t)));
1334         } else {
1335             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1336                              bufsize, sizeof(PackageType) + sizeof(GetMinimumAccessibleValueFromContextPackage));
1337         }
1338         break;
1339 
1340         // ------------ Accessible Selection packages ------------------
1341 
1342     case cAddAccessibleSelectionFromContextPackage:
1343         PrintDebugString("   type == cAddAccessibleSelectionFromContextPackage");
1344         if (bufsize == (sizeof(PackageType) + sizeof(AddAccessibleSelectionFromContextPackage))) {
1345             AddAccessibleSelectionFromContextPackage *pkg =
1346                 (AddAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType));
1347             windowsThreadEntryPoints->addAccessibleSelectionFromContext((jobject)pkg->AccessibleContext,
1348                                                                         pkg->index);
1349         } else {
1350             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1351                              bufsize, sizeof(PackageType) + sizeof(AddAccessibleSelectionFromContextPackage));
1352         }
1353         break;
1354 
1355     case cClearAccessibleSelectionFromContextPackage:
1356         PrintDebugString("   type == cClearAccessibleSelectionFromContextPackage");
1357         if (bufsize == (sizeof(PackageType) + sizeof(ClearAccessibleSelectionFromContextPackage))) {
1358             ClearAccessibleSelectionFromContextPackage *pkg =
1359                 (ClearAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType));
1360             windowsThreadEntryPoints->clearAccessibleSelectionFromContext((jobject)pkg->AccessibleContext);
1361         } else {
1362             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1363                              bufsize, sizeof(PackageType) + sizeof(ClearAccessibleSelectionFromContextPackage));
1364         }
1365         break;
1366 
1367     case cGetAccessibleSelectionFromContextPackage:
1368         PrintDebugString("   type == cGetAccessibleSelectionFromContextPackage");
1369         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleSelectionFromContextPackage))) {
1370             GetAccessibleSelectionFromContextPackage *pkg =
1371                 (GetAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType));
1372             pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleSelectionFromContext(
1373                                                                                                   (jobject)pkg->AccessibleContext, pkg->index);
1374         } else {
1375             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1376                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleSelectionFromContextPackage));
1377         }
1378         break;
1379 
1380     case cGetAccessibleSelectionCountFromContextPackage:
1381         PrintDebugString("   type == cGetAccessibleSelectionCountFromContextPackage");
1382         if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleSelectionCountFromContextPackage))) {
1383             GetAccessibleSelectionCountFromContextPackage *pkg =
1384                 (GetAccessibleSelectionCountFromContextPackage *) (buffer + sizeof(PackageType));
1385             pkg->rCount = windowsThreadEntryPoints->getAccessibleSelectionCountFromContext(
1386                                                                                            (jobject)pkg->AccessibleContext);
1387         } else {
1388             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1389                              bufsize, sizeof(PackageType) + sizeof(GetAccessibleSelectionCountFromContextPackage));
1390         }
1391         break;
1392 
1393     case cIsAccessibleChildSelectedFromContextPackage:
1394         PrintDebugString("   type == cIsAccessibleChildSelectedFromContextPackage");
1395         if (bufsize == (sizeof(PackageType) + sizeof(IsAccessibleChildSelectedFromContextPackage))) {
1396             IsAccessibleChildSelectedFromContextPackage *pkg =
1397                 (IsAccessibleChildSelectedFromContextPackage *) (buffer + sizeof(PackageType));
1398             pkg->rResult = windowsThreadEntryPoints->isAccessibleChildSelectedFromContext(
1399                                                                                           (jobject)pkg->AccessibleContext, pkg->index);
1400         } else {
1401             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1402                              bufsize, sizeof(PackageType) + sizeof(IsAccessibleChildSelectedFromContextPackage));
1403         }
1404         break;
1405 
1406     case cRemoveAccessibleSelectionFromContextPackage:
1407         PrintDebugString("   type == cRemoveAccessibleSelectionFromContextPackage");
1408         if (bufsize == (sizeof(PackageType) + sizeof(RemoveAccessibleSelectionFromContextPackage))) {
1409             RemoveAccessibleSelectionFromContextPackage *pkg =
1410                 (RemoveAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType));
1411             windowsThreadEntryPoints->removeAccessibleSelectionFromContext((jobject)pkg->AccessibleContext,
1412                                                                            pkg->index);
1413         } else {
1414             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1415                              bufsize, sizeof(PackageType) + sizeof(RemoveAccessibleSelectionFromContextPackage));
1416         }
1417         break;
1418 
1419     case cSelectAllAccessibleSelectionFromContextPackage:
1420         PrintDebugString("   type == cSelectAllAccessibleSelectionFromContextPackage");
1421         if (bufsize == (sizeof(PackageType) + sizeof(SelectAllAccessibleSelectionFromContextPackage))) {
1422             SelectAllAccessibleSelectionFromContextPackage *pkg =
1423                 (SelectAllAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType));
1424             windowsThreadEntryPoints->selectAllAccessibleSelectionFromContext((jobject)pkg->AccessibleContext);
1425         } else {
1426             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1427                              bufsize, sizeof(PackageType) + sizeof(SelectAllAccessibleSelectionFromContextPackage));
1428         }
1429         break;
1430 
1431 
1432         // ------------ event notification management packages ------------------
1433 
1434     case cAddJavaEventNotificationPackage:
1435         PrintDebugString("   type = cAddJavaEventNotificationPackage");
1436         if (bufsize == (sizeof(PackageType) + sizeof(AddJavaEventNotificationPackage))) {
1437             AddJavaEventNotificationPackage *pkg =
1438                 (AddJavaEventNotificationPackage *) (buffer + sizeof(PackageType));
1439             addJavaEventNotification(pkg->type, (HWND)ABLongToHandle( pkg->DLLwindow ) );
1440         } else {
1441             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1442                              bufsize, sizeof(PackageType) + sizeof(AddJavaEventNotificationPackage));
1443         }
1444         break;
1445 
1446     case cRemoveJavaEventNotificationPackage:
1447         PrintDebugString("   type = cRemoveJavaEventNotificationPackage");
1448         if (bufsize == (sizeof(PackageType) + sizeof(RemoveJavaEventNotificationPackage))) {
1449             RemoveJavaEventNotificationPackage *pkg =
1450                 (RemoveJavaEventNotificationPackage *) (buffer + sizeof(PackageType));
1451             removeJavaEventNotification(pkg->type, (HWND)ABLongToHandle( pkg->DLLwindow ));
1452         } else {
1453             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1454                              bufsize, sizeof(PackageType) + sizeof(RemoveJavaEventNotificationPackage));
1455         }
1456         break;
1457 
1458     case cAddAccessibilityEventNotificationPackage:
1459         PrintDebugString("   type = cAddAccessibilityEventNotificationPackage");
1460         if (bufsize == (sizeof(PackageType) + sizeof(AddAccessibilityEventNotificationPackage))) {
1461             AddAccessibilityEventNotificationPackage *pkg =
1462                 (AddAccessibilityEventNotificationPackage *) (buffer + sizeof(PackageType));
1463             addAccessibilityEventNotification(pkg->type, (HWND)ABLongToHandle(pkg->DLLwindow));
1464         } else {
1465             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1466                              bufsize, sizeof(PackageType) + sizeof(AddAccessibilityEventNotificationPackage));
1467         }
1468         break;
1469 
1470     case cRemoveAccessibilityEventNotificationPackage:
1471         PrintDebugString("   type = cRemoveAccessibilityEventNotificationPackage");
1472         if (bufsize == (sizeof(PackageType) + sizeof(RemoveAccessibilityEventNotificationPackage))) {
1473             RemoveAccessibilityEventNotificationPackage *pkg =
1474                 (RemoveAccessibilityEventNotificationPackage *) (buffer + sizeof(PackageType));
1475             removeAccessibilityEventNotification(pkg->type, (HWND)ABLongToHandle(pkg->DLLwindow));
1476         } else {
1477             PrintDebugString("   processing FAILED!! -> bufsize = %d; expectation = %d",
1478                              bufsize, sizeof(PackageType) + sizeof(RemoveAccessibilityEventNotificationPackage));
1479         }
1480         break;
1481 
1482     default:
1483         PrintDebugString("   processing FAILED!! -> don't know how to handle type = %X", *type);
1484         returnVal = -1;
1485         break;
1486     }
1487 
1488     PrintDebugString("   package processing completed");
1489     return returnVal;
1490 }
1491 
1492 
1493 // -----------------------------
1494 
1495 
1496 /**
1497  * MemoryMappedFileCreated
1498  *          - WindowsDLL letting us know it's created a memory-mapped file
1499  *            for IPC.  We need to open it and write a magic string into
1500  *            it to let the WindowsDLL know all is OK.  Also we need to
1501  *            set up our own data structures to communicate with the
1502  *            WindowsDLL
1503  *
1504  */
1505 LRESULT
1506 JavaAccessBridge::MemoryMappedFileCreated(HWND ATBridgeDLLWindow, char *filename) {
1507     PrintDebugString("  in MemoryMappedFileCreated(%p, %s)!", ATBridgeDLLWindow, filename);
1508     AccessBridgeATInstance *newAT =
1509         new AccessBridgeATInstance(dialogWindow, ATBridgeDLLWindow, filename, ATs);
1510     PrintDebugString("    just created a new ATInstance = %p, old = %p", newAT, ATs);
1511     ATs = newAT;
1512 
1513     LRESULT returnVal = ATs->initiateIPC();
1514     if (returnVal == 0) {
1515         PrintDebugString("  Successfully initiated IPC with AT!!!");
1516     } else {
1517         PrintDebugString("  ERROR: Failed to initiate IPC with AT!!!");
1518     }
1519 
1520     return returnVal;
1521 }
1522 
1523 
1524 /**
1525  * WindowsATDestroyed - lets the JavaABDLL know a Windows AT disappeared
1526  *
1527  */
1528 void
1529 JavaAccessBridge::WindowsATDestroyed(HWND ATBridgeDLLWindow) {
1530     PrintDebugString("\r\nin JavaAccessBridge::WindowsATDestroyed(%p)", ATBridgeDLLWindow);
1531     if (ATs == (AccessBridgeATInstance *) 0) {
1532         PrintDebugString("  ERROR!! -> ATs == 0! (shouldn't happen here)");
1533         return;
1534     }
1535 
1536     AccessBridgeATInstance *currentAT = ATs;
1537     AccessBridgeATInstance *previousAT = ATs;
1538     if (ATs->winAccessBridgeWindow == ATBridgeDLLWindow) {
1539         ATs = ATs->nextATInstance;
1540         // remove event notification for this AT
1541         removeJavaEventNotification(currentAT->javaEventMask, ATBridgeDLLWindow);
1542         removeAccessibilityEventNotification(currentAT->accessibilityEventMask, ATBridgeDLLWindow);
1543         delete currentAT;
1544         PrintDebugString("  data structures successfully removed");
1545     } else {
1546         while (currentAT != (AccessBridgeATInstance *) NULL) {
1547             if (currentAT->winAccessBridgeWindow == ATBridgeDLLWindow) {
1548                 previousAT->nextATInstance = currentAT->nextATInstance;
1549                 delete currentAT;
1550                 PrintDebugString("  data structures successfully removed");
1551                 return;
1552             } else {
1553                 previousAT = currentAT;
1554                 currentAT = currentAT->nextATInstance;
1555             }
1556         }
1557         PrintDebugString("  ERROR!! couldn't find matching data structures!");
1558     }
1559 }
1560 
1561 
1562 // -----------------------------
1563 
1564 
1565 /**
1566  * releaseJavaObject - lets the JavaVM know it can release the Java Object
1567  *
1568  * Note: once you have made this call, the JavaVM will garbage collect
1569  * the jobject you pass in.  If you later use that jobject in another
1570  * call, you will cause all maner of havoc!
1571  *
1572  */
1573 void
1574 JavaAccessBridge::releaseJavaObject(jobject object) {
1575     PrintDebugString("In JavaAccessBridge::releaseJavaObject");
1576     PrintDebugString("  object X: %p", object);
1577     if (windowsThreadJNIEnv != (JNIEnv *) 0) {
1578         windowsThreadJNIEnv->DeleteGlobalRef(object);
1579         PrintDebugString("  global reference deleted.", object);
1580     } else {
1581         PrintDebugString("  Error! windowsThreadJNIEnv == 0");
1582     }
1583 }
1584 
1585 // -----------------------------
1586 
1587 /**
1588  * addJavaEventNotification - this AT now wants this type of events
1589  *
1590  */
1591 void
1592 JavaAccessBridge::addJavaEventNotification(jlong type, HWND DLLwindow) {
1593     // walk through list of ATs, find this one and add this type
1594     // and, if we weren't listening for these before, ask Java for 'em
1595     PrintDebugString("  adding Java event type %016I64X to HWND %p", type, DLLwindow);
1596     AccessBridgeATInstance *ati = ATs;
1597     long globalEventMask = 0;
1598     while (ati != (AccessBridgeATInstance *) 0) {
1599         if (ati->winAccessBridgeWindow == DLLwindow) {
1600             ati->javaEventMask |= type;
1601             PrintDebugString("  found HWND, javaEventMask now is %X", ati->javaEventMask);
1602         } else {
1603             globalEventMask |= ati->javaEventMask;
1604         }
1605         ati = ati->nextATInstance;
1606     }
1607     PrintDebugString("  union of all Java AT event masks: %X", globalEventMask);
1608     if (!(globalEventMask & type)) {
1609         // no other ATs wanted this event;
1610         // start getting them from Java
1611         PrintDebugString("  no other AT wanted this Java event (so not registered); adding to AccessBridge.java");
1612         windowsThreadEntryPoints->addJavaEventNotification(type);
1613     }
1614 }
1615 
1616 /**
1617  * removeJavaEventNotification - this AT no longer wants this type of events
1618  *
1619  */
1620 void
1621 JavaAccessBridge::removeJavaEventNotification(jlong type, HWND DLLwindow) {
1622     // walk through list of ATs, find this one and remove this type
1623     // and, if no other AT wants 'em either, tell Java we no longer want 'em
1624     PrintDebugString("  removing Java event type %016I64X from HWND %p", type, DLLwindow);
1625     AccessBridgeATInstance *ati = ATs;
1626     long globalEventMask = 0;
1627     while (ati != (AccessBridgeATInstance *) 0) {
1628         if (ati->winAccessBridgeWindow == DLLwindow) {
1629             ati->javaEventMask &= (0xFFFFFFFF - type);
1630             PrintDebugString("  found HWND, javaEventMask now is %X", ati->javaEventMask);
1631         } else {
1632             globalEventMask |= ati->javaEventMask;
1633         }
1634         ati = ati->nextATInstance;
1635     }
1636     PrintDebugString("  union of all Java AT event masks: %X", globalEventMask);
1637     if (!(globalEventMask & type)) {
1638         // no other ATs wanted this event;
1639         // stop getting them from Java
1640         PrintDebugString("  no other AT wanted this Java event (so can remove); removing from AccessBridge.java");
1641         windowsThreadEntryPoints->removeJavaEventNotification(type);
1642     }
1643 }
1644 
1645 
1646 /**
1647  * addAccesibilityEventNotification - this AT now wants this type of events
1648  *
1649  */
1650 void
1651 JavaAccessBridge::addAccessibilityEventNotification(jlong type, HWND DLLwindow) {
1652     // walk through list of ATs, find this one and add this type
1653     // and, if we weren't listening for these before, ask Java for 'em
1654     PrintDebugString("  adding Accesibility event type %016I64X to HWND %p", type, DLLwindow);
1655     AccessBridgeATInstance *ati = ATs;
1656     long globalEventMask = 0;
1657     while (ati != (AccessBridgeATInstance *) 0) {
1658         if (ati->winAccessBridgeWindow == DLLwindow) {
1659             ati->accessibilityEventMask |= type;
1660             PrintDebugString("  found HWND, accessibilityEventMask now is %X", ati->accessibilityEventMask);
1661         } else {
1662             globalEventMask |= ati->accessibilityEventMask;
1663         }
1664         ati = ati->nextATInstance;
1665     }
1666     PrintDebugString("  union of all Accessibility AT event masks: %X", globalEventMask);
1667     if (!(globalEventMask & type)) {
1668         // no other ATs wanted this event;
1669         // start getting them from Java
1670         PrintDebugString("  no other AT wanted this Accesibility event (so not registered); adding to AccessBridge.java");
1671         windowsThreadEntryPoints->addAccessibilityEventNotification(type);
1672     }
1673 }
1674 
1675 /**
1676  * removeAccesibilityEventNotification - this AT no longer wants this type of events
1677  *
1678  */
1679 void
1680 JavaAccessBridge::removeAccessibilityEventNotification(jlong type, HWND DLLwindow) {
1681     // walk through list of ATs, find this one and remove this type
1682     // and, if no other AT wants 'em either, tell Java we no longer want 'em
1683     PrintDebugString("  removing Accesibility event type %016I64X from HWND %p", type, DLLwindow);
1684     AccessBridgeATInstance *ati = ATs;
1685     long globalEventMask = 0;
1686     while (ati != (AccessBridgeATInstance *) 0) {
1687         if (ati->winAccessBridgeWindow == DLLwindow) {
1688             ati->accessibilityEventMask &= (0xFFFFFFFF - type);
1689             PrintDebugString("  found HWND, accessibilityEventMask now is %X", ati->accessibilityEventMask);
1690         } else {
1691             globalEventMask |= ati->accessibilityEventMask;
1692         }
1693         ati = ati->nextATInstance;
1694     }
1695     PrintDebugString("  union of all Accessibility AT event masks: %X", globalEventMask);
1696     if (!(globalEventMask & type)) {
1697         // no other ATs wanted this event;
1698         // stop getting them from Java
1699         PrintDebugString("  no other AT wanted this Accessibility event (so can remove); removing from AccessBridge.java");
1700         windowsThreadEntryPoints->removeAccessibilityEventNotification(type);
1701     }
1702 }
1703 
1704 
1705 
1706 
1707 /**
1708  * firePropertyCaretChange
1709  *
1710  */
1711 void
1712 JavaAccessBridge::firePropertyCaretChange(JNIEnv *env, jobject callingObj,
1713                                           jobject event, jobject source,
1714                                           jint oldValue, jint newValue) {
1715 
1716     PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyCaretChanged(%p, %p, %p, %p, %d, %d)",
1717                      env, callingObj, event,
1718                      source, oldValue, newValue);
1719 
1720     // sanity check
1721     if (ATs == (AccessBridgeATInstance *) 0) {
1722         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
1723         return;         // panic!
1724     }
1725 
1726     // common setup
1727     char buffer[sizeof(PackageType) + sizeof(PropertyCaretChangePackage)];
1728     PackageType *type = (PackageType *) buffer;
1729     PropertyCaretChangePackage *pkg = (PropertyCaretChangePackage *) (buffer + sizeof(PackageType));
1730     *type = cPropertyCaretChangePackage;
1731     pkg->vmID = (long) dialogWindow;
1732 
1733     // make new Global Refs and send events only to those ATs that want 'em
1734     AccessBridgeATInstance *ati = ATs;
1735     while (ati != (AccessBridgeATInstance *) 0) {
1736         if (ati->accessibilityEventMask & cPropertyCaretChangeEvent) {
1737 
1738             PrintDebugString("  sending to AT");
1739 
1740             // make new GlobalRefs for this AT
1741             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
1742             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
1743 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
1744             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
1745             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
1746 #else // JOBJECT64 is jlong (64 bit)
1747             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
1748             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
1749 #endif
1750 
1751             pkg->oldPosition = oldValue;
1752             pkg->newPosition = newValue;
1753 
1754             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyCaretChangeEvent);
1755         }
1756         ati = ati->nextATInstance;
1757     }
1758     PrintDebugString("  done with propertyCaretChange event");
1759 }
1760 
1761 /**
1762  * firePropertyDescriptionChange
1763  *
1764  */
1765 void
1766 JavaAccessBridge::firePropertyDescriptionChange(JNIEnv *env, jobject callingObj,
1767                                                 jobject event, jobject source,
1768                                                 jstring oldValue, jstring newValue){
1769 
1770     PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyDescriptionChanged(%p, %p, %p, %p, %p, %p)",
1771                      env, callingObj, event,
1772                      source, oldValue, newValue);
1773 
1774     // sanity check
1775     if (ATs == (AccessBridgeATInstance *) 0) {
1776         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
1777         return;         // panic!
1778     }
1779 
1780     // common setup
1781     const wchar_t *stringBytes;
1782     char buffer[sizeof(PackageType) + sizeof(PropertyDescriptionChangePackage)];
1783     PackageType *type = (PackageType *) buffer;
1784     PropertyDescriptionChangePackage *pkg = (PropertyDescriptionChangePackage *) (buffer + sizeof(PackageType));
1785     *type = cPropertyDescriptionChangePackage;
1786     pkg->vmID = (long) dialogWindow;
1787 
1788     // make new Global Refs and send events only to those ATs that want 'em
1789     AccessBridgeATInstance *ati = ATs;
1790     while (ati != (AccessBridgeATInstance *) 0) {
1791         if (ati->accessibilityEventMask & cPropertyCaretChangeEvent) {
1792 
1793             PrintDebugString("  sending to AT");
1794 
1795             // make new GlobalRefs for this AT
1796             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
1797             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
1798 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
1799             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
1800             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
1801 #else // JOBJECT64 is jlong (64 bit)
1802             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
1803             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
1804 #endif
1805 
1806             if (oldValue != (jstring) 0) {
1807                 stringBytes = (const wchar_t *) env->GetStringChars(oldValue, 0);
1808                 if (stringBytes == NULL) {
1809                     if (!env->ExceptionCheck()) {
1810                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
1811                         if (cls != NULL) {
1812                             env->ThrowNew(cls, NULL);
1813                         }
1814                     }
1815                     return;
1816                 }
1817                 wcsncpy(pkg->oldDescription, stringBytes, (sizeof(pkg->oldDescription) / sizeof(wchar_t)));
1818                 env->ReleaseStringChars(oldValue, stringBytes);
1819             } else {
1820                 wcsncpy(pkg->oldDescription, L"(null)", (sizeof(pkg->oldDescription) / sizeof(wchar_t)));
1821             }
1822 
1823             if (newValue != (jstring) 0) {
1824                 stringBytes = (const wchar_t *) env->GetStringChars(newValue, 0);
1825                 if (stringBytes == NULL) {
1826                    if (!env->ExceptionCheck()) {
1827                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
1828                         if (cls != NULL) {
1829                             env->ThrowNew(cls, NULL);
1830                         }
1831                     }
1832                     return;
1833                 }
1834                 wcsncpy(pkg->newDescription, stringBytes, (sizeof(pkg->newDescription) / sizeof(wchar_t)));
1835                 env->ReleaseStringChars(newValue, stringBytes);
1836             } else {
1837                 wcsncpy(pkg->newDescription, L"(null)", (sizeof(pkg->newDescription) / sizeof(wchar_t)));
1838             }
1839 
1840             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyDescriptionChangeEvent);
1841         }
1842         ati = ati->nextATInstance;
1843     }
1844     PrintDebugString("  done with propertyDescriptionChange event");
1845 }
1846 
1847 /**
1848  * firePropertyNameChange
1849  *
1850  */
1851 void
1852 JavaAccessBridge::firePropertyNameChange(JNIEnv *env, jobject callingObj,
1853                                          jobject event, jobject source,
1854                                          jstring oldValue, jstring newValue){
1855 
1856     PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyNameChanged(%p, %p, %p, %p, %p, %p)",
1857                      env, callingObj, event,
1858                      source, oldValue, newValue);
1859 
1860     // sanity check
1861     if (ATs == (AccessBridgeATInstance *) 0) {
1862         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
1863         return;         // panic!
1864     }
1865 
1866     // common setup
1867     const wchar_t *stringBytes;
1868     char buffer[sizeof(PackageType) + sizeof(PropertyNameChangePackage)];
1869     PackageType *type = (PackageType *) buffer;
1870     PropertyNameChangePackage *pkg = (PropertyNameChangePackage *) (buffer + sizeof(PackageType));
1871     *type = cPropertyNameChangePackage;
1872     pkg->vmID = (long) dialogWindow;
1873 
1874     // make new Global Refs and send events only to those ATs that want 'em
1875     AccessBridgeATInstance *ati = ATs;
1876     while (ati != (AccessBridgeATInstance *) 0) {
1877         if (ati->accessibilityEventMask & cPropertyNameChangeEvent) {
1878 
1879             PrintDebugString("  sending to AT");
1880 
1881             // make new GlobalRefs for this AT
1882             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
1883             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
1884 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
1885             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
1886             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
1887 #else // JOBJECT64 is jlong (64 bit)
1888             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
1889             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
1890 #endif
1891 
1892             if (oldValue != (jstring) 0) {
1893                 stringBytes = (const wchar_t *) env->GetStringChars(oldValue, 0);
1894                 if (stringBytes == NULL) {
1895                     if (!env->ExceptionCheck()) {
1896                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
1897                         if (cls != NULL) {
1898                             env->ThrowNew(cls, NULL);
1899                         }
1900                     }
1901                     return;
1902                 }
1903                 wcsncpy(pkg->oldName, stringBytes, (sizeof(pkg->oldName) / sizeof(wchar_t)));
1904                 env->ReleaseStringChars(oldValue, stringBytes);
1905             } else {
1906                 wcsncpy(pkg->oldName, L"(null)", (sizeof(pkg->oldName) / sizeof(wchar_t)));
1907             }
1908 
1909             if (newValue != (jstring) 0) {
1910                 stringBytes = (const wchar_t *) env->GetStringChars(newValue, 0);
1911                 if (stringBytes == NULL) {
1912                     if (!env->ExceptionCheck()) {
1913                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
1914                         if (cls != NULL) {
1915                             env->ThrowNew(cls, NULL);
1916                         }
1917                     }
1918                     return;
1919                 }
1920                 wcsncpy(pkg->newName, stringBytes, (sizeof(pkg->newName) / sizeof(wchar_t)));
1921                 env->ReleaseStringChars(newValue, stringBytes);
1922             } else {
1923                 wcsncpy(pkg->newName, L"(null)", (sizeof(pkg->newName) / sizeof(wchar_t)));
1924             }
1925 
1926             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyNameChangeEvent);
1927         }
1928         ati = ati->nextATInstance;
1929     }
1930     PrintDebugString("  done with propertyNameChange event");
1931 }
1932 
1933 
1934 /**
1935  * firePropertySelectionChange
1936  *
1937  */
1938 void
1939 JavaAccessBridge::firePropertySelectionChange(JNIEnv *env, jobject callingObj,
1940                                               jobject event, jobject source) {
1941 
1942     PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertySelectionChanged(%p, %p, %p, %p)",
1943                      env, callingObj, event, source);
1944 
1945     // sanity check
1946     if (ATs == (AccessBridgeATInstance *) 0) {
1947         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
1948         return;         // panic!
1949     }
1950 
1951     // common setup
1952     char buffer[sizeof(PackageType) + sizeof(PropertySelectionChangePackage)];
1953     PackageType *type = (PackageType *) buffer;
1954     PropertySelectionChangePackage *pkg = (PropertySelectionChangePackage *) (buffer + sizeof(PackageType));
1955     *type = cPropertySelectionChangePackage;
1956     pkg->vmID = (long) dialogWindow;
1957 
1958     // make new Global Refs and send events only to those ATs that want 'em
1959     AccessBridgeATInstance *ati = ATs;
1960     while (ati != (AccessBridgeATInstance *) 0) {
1961         if (ati->accessibilityEventMask & cPropertySelectionChangeEvent) {
1962 
1963             PrintDebugString("  sending to AT");
1964 
1965             // make new GlobalRefs for this AT
1966             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
1967             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
1968 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
1969             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
1970             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
1971 #else // JOBJECT64 is jlong (64 bit)
1972             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
1973             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
1974 #endif
1975 
1976             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertySelectionChangeEvent);
1977         }
1978         ati = ati->nextATInstance;
1979     }
1980     PrintDebugString("  done with propertySelectionChange event");
1981 }
1982 
1983 
1984 /**
1985  * firePropertyStateChange
1986  *
1987  */
1988 void
1989 JavaAccessBridge::firePropertyStateChange(JNIEnv *env, jobject callingObj,
1990                                           jobject event, jobject source,
1991                                           jstring oldValue, jstring newValue){
1992 
1993     PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyStateChanged(%p, %p, %p, %p, %p, %p)",
1994                      env, callingObj, event,
1995                      source, oldValue, newValue);
1996 
1997     // sanity check
1998     if (ATs == (AccessBridgeATInstance *) 0) {
1999         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2000         return;         // panic!
2001     }
2002 
2003     // common setup
2004     const wchar_t *stringBytes;
2005     char buffer[sizeof(PackageType) + sizeof(PropertyStateChangePackage)];
2006     PackageType *type = (PackageType *) buffer;
2007     PropertyStateChangePackage *pkg = (PropertyStateChangePackage *) (buffer + sizeof(PackageType));
2008     *type = cPropertyStateChangePackage;
2009     pkg->vmID = (long) dialogWindow;
2010 
2011     // make new Global Refs and send events only to those ATs that want 'em
2012     AccessBridgeATInstance *ati = ATs;
2013     while (ati != (AccessBridgeATInstance *) 0) {
2014         if (ati->accessibilityEventMask & cPropertyStateChangeEvent) {
2015 
2016             PrintDebugString("  sending to AT");
2017 
2018             // make new GlobalRefs for this AT
2019             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2020             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2021 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2022             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2023             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2024 #else // JOBJECT64 is jlong (64 bit)
2025             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2026             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2027 #endif
2028 
2029             if (oldValue != (jstring) 0) {
2030                 stringBytes = (const wchar_t *) env->GetStringChars(oldValue, 0);
2031                 if (stringBytes == NULL) {
2032                     if (!env->ExceptionCheck()) {
2033                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2034                         if (cls != NULL) {
2035                             env->ThrowNew(cls, NULL);
2036                         }
2037                     }
2038                     return;
2039                 }
2040                 wcsncpy(pkg->oldState, stringBytes, (sizeof(pkg->oldState) / sizeof(wchar_t)));
2041                 env->ReleaseStringChars(oldValue, stringBytes);
2042             } else {
2043                 wcsncpy(pkg->oldState, L"(null)", (sizeof(pkg->oldState) / sizeof(wchar_t)));
2044             }
2045 
2046             if (newValue != (jstring) 0) {
2047                 stringBytes = (const wchar_t *) env->GetStringChars(newValue, 0);
2048                 if (stringBytes == NULL) {
2049                     if (!env->ExceptionCheck()) {
2050                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2051                         if (cls != NULL) {
2052                             env->ThrowNew(cls, NULL);
2053                         }
2054                     }
2055                     return;
2056                 }
2057                 wcsncpy(pkg->newState, stringBytes, (sizeof(pkg->newState) / sizeof(wchar_t)));
2058                 env->ReleaseStringChars(newValue, stringBytes);
2059             } else {
2060                 wcsncpy(pkg->newState, L"(null)", (sizeof(pkg->newState) / sizeof(wchar_t)));
2061             }
2062 
2063             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyStateChangeEvent);
2064         }
2065         ati = ati->nextATInstance;
2066     }
2067     PrintDebugString("  done with propertyStateChange event");
2068 }
2069 
2070 
2071 /**
2072  * firePropertyTextChange
2073  *
2074  */
2075 void
2076 JavaAccessBridge::firePropertyTextChange(JNIEnv *env, jobject callingObj,
2077                                          jobject event, jobject source) {
2078 
2079     PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyTextChanged(%p, %p, %p, %p)",
2080                      env, callingObj, event, source);
2081 
2082     // sanity check
2083     if (ATs == (AccessBridgeATInstance *) 0) {
2084         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2085         return;         // panic!
2086     }
2087 
2088     // common setup
2089     char buffer[sizeof(PackageType) + sizeof(PropertyTextChangePackage)];
2090     PackageType *type = (PackageType *) buffer;
2091     PropertyTextChangePackage *pkg = (PropertyTextChangePackage *) (buffer + sizeof(PackageType));
2092     *type = cPropertyTextChangePackage;
2093     pkg->vmID = (long) dialogWindow;
2094 
2095     // make new Global Refs and send events only to those ATs that want 'em
2096     AccessBridgeATInstance *ati = ATs;
2097     while (ati != (AccessBridgeATInstance *) 0) {
2098         if (ati->accessibilityEventMask & cPropertyTextChangeEvent) {
2099 
2100             PrintDebugString("  sending to AT");
2101 
2102             // make new GlobalRefs for this AT
2103             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2104             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2105 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2106             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2107             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2108 #else // JOBJECT64 is jlong (64 bit)
2109             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2110             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2111 #endif
2112 
2113             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyTextChangeEvent);
2114         }
2115         ati = ati->nextATInstance;
2116     }
2117     PrintDebugString("  done with propertyTextChange event");
2118 }
2119 
2120 
2121 /**
2122  * firePropertyValueChange
2123  *
2124  */
2125 void
2126 JavaAccessBridge::firePropertyValueChange(JNIEnv *env, jobject callingObj,
2127                                           jobject event, jobject source,
2128                                           jstring oldValue, jstring newValue){
2129 
2130     PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyValueChanged(%p, %p, %p, %p, %p, %p)",
2131                      env, callingObj, event,
2132                      source, oldValue, newValue);
2133 
2134     // sanity check
2135     if (ATs == (AccessBridgeATInstance *) 0) {
2136         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2137         return;         // panic!
2138     }
2139 
2140     // common setup
2141     const wchar_t *stringBytes;
2142     char buffer[sizeof(PackageType) + sizeof(PropertyValueChangePackage)];
2143     PackageType *type = (PackageType *) buffer;
2144     PropertyValueChangePackage *pkg = (PropertyValueChangePackage *) (buffer + sizeof(PackageType));
2145     *type = cPropertyValueChangePackage;
2146     pkg->vmID = (long) dialogWindow;
2147 
2148     // make new Global Refs and send events only to those ATs that want 'em
2149     AccessBridgeATInstance *ati = ATs;
2150     while (ati != (AccessBridgeATInstance *) 0) {
2151         if (ati->accessibilityEventMask & cPropertyValueChangeEvent) {
2152 
2153             PrintDebugString("  sending to AT");
2154 
2155             // make new GlobalRefs for this AT
2156             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2157             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2158 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2159             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2160             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2161 #else // JOBJECT64 is jlong (64 bit)
2162             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2163             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2164 #endif
2165 
2166             if (oldValue != (jstring) 0) {
2167                 stringBytes = (const wchar_t *) env->GetStringChars(oldValue, 0);
2168                 if (stringBytes == NULL) {
2169                     if (!env->ExceptionCheck()) {
2170                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2171                         if (cls != NULL) {
2172                             env->ThrowNew(cls, NULL);
2173                         }
2174                     }
2175                     return;
2176                 }
2177                 wcsncpy(pkg->oldValue, stringBytes, (sizeof(pkg->oldValue) / sizeof(wchar_t)));
2178                 env->ReleaseStringChars(oldValue, stringBytes);
2179             } else {
2180                 wcsncpy(pkg->oldValue, L"(null)", (sizeof(pkg->oldValue) / sizeof(wchar_t)));
2181             }
2182 
2183             if (newValue != (jstring) 0) {
2184                 stringBytes = (const wchar_t *) env->GetStringChars(newValue, 0);
2185                 if (stringBytes == NULL) {
2186                     if (!env->ExceptionCheck()) {
2187                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2188                         if (cls != NULL) {
2189                             env->ThrowNew(cls, NULL);
2190                         }
2191                     }
2192                     return;
2193                 }
2194                 wcsncpy(pkg->newValue, stringBytes, (sizeof(pkg->newValue) / sizeof(wchar_t)));
2195                 env->ReleaseStringChars(newValue, stringBytes);
2196             } else {
2197                 wcsncpy(pkg->newValue, L"(null)", (sizeof(pkg->newValue) / sizeof(wchar_t)));
2198             }
2199 
2200             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyValueChangeEvent);
2201         }
2202         ati = ati->nextATInstance;
2203     }
2204     PrintDebugString("  done with propertyValueChange event");
2205 }
2206 
2207 /**
2208  * firePropertyVisibleDataChange
2209  *
2210  */
2211 void
2212 JavaAccessBridge::firePropertyVisibleDataChange(JNIEnv *env, jobject callingObj,
2213                                                 jobject event, jobject source) {
2214 
2215     PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyVisibleDataChanged(%p, %p, %p, %p)",
2216                      env, callingObj, event, source);
2217 
2218     // sanity check
2219     if (ATs == (AccessBridgeATInstance *) 0) {
2220         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2221         return;         // panic!
2222     }
2223 
2224     // common setup
2225     char buffer[sizeof(PackageType) + sizeof(PropertyVisibleDataChangePackage)];
2226     PackageType *type = (PackageType *) buffer;
2227     PropertyVisibleDataChangePackage *pkg = (PropertyVisibleDataChangePackage *) (buffer + sizeof(PackageType));
2228     *type = cPropertyVisibleDataChangePackage;
2229     pkg->vmID = (long) dialogWindow;
2230 
2231     // make new Global Refs and send events only to those ATs that want 'em
2232     AccessBridgeATInstance *ati = ATs;
2233     while (ati != (AccessBridgeATInstance *) 0) {
2234         if (ati->accessibilityEventMask & cPropertyVisibleDataChangeEvent) {
2235 
2236             PrintDebugString("  sending to AT");
2237 
2238             // make new GlobalRefs for this AT
2239             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2240             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2241 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2242             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2243             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2244 #else // JOBJECT64 is jlong (64 bit)
2245             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2246             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2247 #endif
2248 
2249             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyVisibleDataChangeEvent);
2250         }
2251         ati = ati->nextATInstance;
2252     }
2253     PrintDebugString("  done with propertyVisibleDataChange event");
2254 }
2255 
2256 
2257 /**
2258  * firePropertyChildChange
2259  *
2260  */
2261 void
2262 JavaAccessBridge::firePropertyChildChange(JNIEnv *env, jobject callingObj,
2263                                           jobject event, jobject source,
2264                                           jobject oldValue, jobject newValue){
2265 
2266     PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyChildPropertyChanged(%p, %p, %p, %p, %p, %p)",
2267                      env, callingObj, event,
2268                      source, oldValue, newValue);
2269 
2270     // sanity check
2271     if (ATs == (AccessBridgeATInstance *) 0) {
2272         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2273         return;         // panic!
2274     }
2275 
2276     // common setup
2277     char buffer[sizeof(PackageType) + sizeof(PropertyChildChangePackage)];
2278     PackageType *type = (PackageType *) buffer;
2279     PropertyChildChangePackage *pkg = (PropertyChildChangePackage *) (buffer + sizeof(PackageType));
2280     *type = cPropertyChildChangePackage;
2281     pkg->vmID = (long) dialogWindow;
2282 
2283     // make new Global Refs and send events only to those ATs that want 'em
2284     AccessBridgeATInstance *ati = ATs;
2285     while (ati != (AccessBridgeATInstance *) 0) {
2286         if (ati->accessibilityEventMask & cPropertyChildChangeEvent) {
2287 
2288             PrintDebugString("  sending to AT");
2289 
2290             // make new GlobalRefs for this AT
2291             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2292             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2293             pkg->oldChildAccessibleContext = (JOBJECT64)env->NewGlobalRef(oldValue);
2294             pkg->newChildAccessibleContext = (JOBJECT64)env->NewGlobalRef(newValue);
2295 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2296             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2297             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2298             PrintDebugString("  GlobalRef'd OldChildAC: %p", pkg->oldChildAccessibleContext);
2299             PrintDebugString("  GlobalRef'd NewChildAC: %p", pkg->newChildAccessibleContext);
2300 #else // JOBJECT64 is jlong (64 bit)
2301             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2302             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2303             PrintDebugString("  GlobalRef'd OldChildAC: %016I64X", pkg->oldChildAccessibleContext);
2304             PrintDebugString("  GlobalRef'd NewChildAC: %016I64X", pkg->newChildAccessibleContext);
2305 #endif
2306 
2307             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyChildChangeEvent);
2308         }
2309         ati = ati->nextATInstance;
2310     }
2311     PrintDebugString("  done with propertyChildChange event");
2312 }
2313 
2314 
2315 /**
2316  * firePropertyActiveDescendentChange
2317  *
2318  */
2319 void
2320 JavaAccessBridge::firePropertyActiveDescendentChange(JNIEnv *env, jobject callingObj,
2321                                                      jobject event, jobject source,
2322                                                      jobject oldValue, jobject newValue){
2323 
2324     PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyActiveDescendentPropertyChanged(%p, %p, %p, %p, %p, %p)",
2325                      env, callingObj, event,
2326                      source, oldValue, newValue);
2327 
2328     // sanity check
2329     if (ATs == (AccessBridgeATInstance *) 0) {
2330         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2331         return;         // panic!
2332     }
2333 
2334     // common setup
2335     char buffer[sizeof(PackageType) + sizeof(PropertyActiveDescendentChangePackage)];
2336     PackageType *type = (PackageType *) buffer;
2337     PropertyActiveDescendentChangePackage *pkg = (PropertyActiveDescendentChangePackage *) (buffer + sizeof(PackageType));
2338     *type = cPropertyActiveDescendentChangePackage;
2339     pkg->vmID = (long) dialogWindow;
2340 
2341     // make new Global Refs and send events only to those ATs that want 'em
2342     AccessBridgeATInstance *ati = ATs;
2343     while (ati != (AccessBridgeATInstance *) 0) {
2344         if (ati->accessibilityEventMask & cPropertyActiveDescendentChangeEvent) {
2345 
2346             PrintDebugString("  sending to AT");
2347 
2348             // make new GlobalRefs for this AT
2349             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2350             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2351             pkg->oldActiveDescendentAccessibleContext = (JOBJECT64)env->NewGlobalRef(oldValue);
2352             pkg->newActiveDescendentAccessibleContext = (JOBJECT64)env->NewGlobalRef(newValue);
2353 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2354             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2355             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2356             PrintDebugString("  GlobalRef'd OldActiveDescendentAC: %p", pkg->oldActiveDescendentAccessibleContext);
2357             PrintDebugString("  GlobalRef'd NewActiveDescendentAC: %p", pkg->newActiveDescendentAccessibleContext);
2358 #else // JOBJECT64 is jlong (64 bit)
2359             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2360             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2361             PrintDebugString("  GlobalRef'd OldActiveDescendentAC: %016I64X", pkg->oldActiveDescendentAccessibleContext);
2362             PrintDebugString("  GlobalRef'd NewActiveDescendentAC: %016I64X", pkg->newActiveDescendentAccessibleContext);
2363 #endif
2364 
2365             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyActiveDescendentChangeEvent);
2366         }
2367         ati = ati->nextATInstance;
2368     }
2369     PrintDebugString("  done with propertyActiveChange event");
2370 }
2371 
2372 /**
2373  * firePropertyValueChange
2374  *
2375  */
2376 void
2377 JavaAccessBridge::firePropertyTableModelChange(JNIEnv *env, jobject callingObj,
2378                                                jobject event, jobject source,
2379                                                jstring oldValue, jstring newValue){
2380 
2381     PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyTableModelChange(%p, %p, %p, %p, %p, %p)",
2382                      env, callingObj, event,
2383                      source, oldValue, newValue);
2384 
2385     // sanity check
2386     if (ATs == (AccessBridgeATInstance *) 0) {
2387         PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2388         return;         // panic!
2389     }
2390 
2391     // common setup
2392     const wchar_t *stringBytes;
2393     char buffer[sizeof(PackageType) + sizeof(PropertyTableModelChangePackage)];
2394     PackageType *type = (PackageType *) buffer;
2395     PropertyTableModelChangePackage *pkg = (PropertyTableModelChangePackage *) (buffer + sizeof(PackageType));
2396     *type = cPropertyTableModelChangePackage;
2397     pkg->vmID = (long) dialogWindow;
2398 
2399     // make new Global Refs and send events only to those ATs that want 'em
2400     AccessBridgeATInstance *ati = ATs;
2401     while (ati != (AccessBridgeATInstance *) 0) {
2402         if (ati->accessibilityEventMask & cPropertyTableModelChangeEvent) {
2403 
2404             PrintDebugString("  sending to AT");
2405 
2406             // make new GlobalRefs for this AT
2407             pkg->Event = (JOBJECT64)env->NewGlobalRef(event);
2408             pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);
2409 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2410             PrintDebugString("  GlobalRef'd Event: %p", pkg->Event);
2411             PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2412 #else // JOBJECT64 is jlong (64 bit)
2413             PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event);
2414             PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2415 #endif
2416 
2417             if (oldValue != (jstring) 0) {
2418                 stringBytes = (const wchar_t *) env->GetStringChars(oldValue, 0);
2419                 if (stringBytes == NULL) {
2420                     if (!env->ExceptionCheck()) {
2421                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2422                         if (cls != NULL) {
2423                             env->ThrowNew(cls, NULL);
2424                         }
2425                     }
2426                     return;
2427                 }
2428                 wcsncpy(pkg->oldValue, stringBytes, (sizeof(pkg->oldValue) / sizeof(wchar_t)));
2429                 env->ReleaseStringChars(oldValue, stringBytes);
2430             } else {
2431                 wcsncpy(pkg->oldValue, L"(null)", (sizeof(pkg->oldValue) / sizeof(wchar_t)));
2432             }
2433 
2434             if (newValue != (jstring) 0) {
2435                 stringBytes = (const wchar_t *) env->GetStringChars(newValue, 0);
2436                 if (stringBytes == NULL) {
2437                     if (!env->ExceptionCheck()) {
2438                         jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2439                         if (cls != NULL) {
2440                             env->ThrowNew(cls, NULL);
2441                         }
2442                     }
2443                     return;
2444                 }
2445                 wcsncpy(pkg->newValue, stringBytes, (sizeof(pkg->newValue) / sizeof(wchar_t)));
2446                 env->ReleaseStringChars(newValue, stringBytes);
2447             } else {
2448                 wcsncpy(pkg->newValue, L"(null)", (sizeof(pkg->newValue) / sizeof(wchar_t)));
2449             }
2450 
2451             ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyTableModelChangeEvent);
2452         }
2453         ati = ati->nextATInstance;
2454     }
2455     PrintDebugString("  done with propertyTableModelChange event");
2456 }
2457 
2458 
2459 
2460 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
2461 #define PRINT_GLOBALREFS() \
2462     PrintDebugString("  GlobalRef'd Event: %p", pkg->Event); \
2463     PrintDebugString("  GlobalRef'd Source: %p", pkg->AccessibleContextSource);
2464 #else // JOBJECT64 is jlong (64 bit)
2465 #define PRINT_GLOBALREFS() \
2466     PrintDebugString("  GlobalRef'd Event: %016I64X", pkg->Event); \
2467     PrintDebugString("  GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource);
2468 #endif
2469 
2470 #define FIRE_EVENT(function, packageStruct, packageConstant, eventConstant)             \
2471     void JavaAccessBridge::function(JNIEnv *env, jobject callingObj,                    \
2472                                     jobject eventObj, jobject source) {                 \
2473                                                                                         \
2474         PrintDebugString("\r\nFiring event id = %d(%p, %p, %p, %p); vmID = %X",         \
2475                          eventConstant, env, callingObj, eventObj, source, dialogWindow); \
2476                                                                                         \
2477         /* sanity check */                                                              \
2478         if (ATs == (AccessBridgeATInstance *) 0) {                                      \
2479             PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");           \
2480             return;         /* panic! */                                                \
2481         }                                                                               \
2482                                                                                         \
2483         /* common setup */                                                              \
2484         char buffer[sizeof(PackageType) + sizeof(packageStruct)];                       \
2485         PackageType *type = (PackageType *) buffer;                                     \
2486         packageStruct *pkg = (packageStruct *) (buffer + sizeof(PackageType));          \
2487         *type = packageConstant;                                                        \
2488         pkg->vmID = (long) dialogWindow;                                                \
2489                                                                                         \
2490         /* make new Global Refs, send events only to those ATs that want 'em */         \
2491         AccessBridgeATInstance *ati = ATs;                                              \
2492         while (ati != (AccessBridgeATInstance *) 0) {                                   \
2493             PrintDebugString("\r\njavaEventMask = %X eventConstant=%d pkg->vmID=%X",    \
2494                              ati->javaEventMask, eventConstant, pkg->vmID );            \
2495             if (ati->javaEventMask & eventConstant) {                                   \
2496                                                                                         \
2497                 PrintDebugString("  sending to AT");                                    \
2498                 /* make new GlobalRefs for this AT */                                   \
2499                 pkg->Event = (JOBJECT64)env->NewGlobalRef(eventObj);                    \
2500                 pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source);    \
2501                 PRINT_GLOBALREFS()                                                      \
2502                                                                                         \
2503                 ati->sendJavaEventPackage(buffer, sizeof(buffer), eventConstant);       \
2504             }                                                                           \
2505             ati = ati->nextATInstance;                                                  \
2506         }                                                                               \
2507         PrintDebugString("  done with firing AWT event");                               \
2508     }
2509 
2510     void JavaAccessBridge::javaShutdown(JNIEnv *env, jobject callingObj) {
2511 
2512         PrintDebugString("\r\nFiring event id = %d(%p, %p); vmID = %X",
2513                          cJavaShutdownEvent, env, callingObj, dialogWindow);
2514 
2515         /* sanity check */
2516         if (ATs == (AccessBridgeATInstance *) 0) {
2517             PrintDebugString("  ERROR!! ATs == 0! (shouldn't happen here!)");
2518             return;             /* panic! */
2519         }
2520 
2521         /* common setup */
2522         char buffer[sizeof(PackageType) + sizeof(JavaShutdownPackage)];
2523         PackageType *type = (PackageType *) buffer;
2524         JavaShutdownPackage *pkg = (JavaShutdownPackage *) (buffer + sizeof(PackageType));
2525         *type = cJavaShutdownPackage;
2526         pkg->vmID = (long) dialogWindow;
2527 
2528         /* make new Global Refs, send events only to those ATs that want 'em */
2529         AccessBridgeATInstance *ati = ATs;
2530         while (ati != (AccessBridgeATInstance *) 0) {
2531             if (ati->javaEventMask & cJavaShutdownEvent) {
2532                 PrintDebugString("  sending to AT");
2533                 ati->sendJavaEventPackage(buffer, sizeof(buffer), cJavaShutdownEvent);
2534             }
2535             ati = ati->nextATInstance;
2536         }
2537         PrintDebugString("  done with firing AWT event");
2538     }
2539 
2540     FIRE_EVENT(fireFocusGained, FocusGainedPackage, cFocusGainedPackage, cFocusGainedEvent)
2541     FIRE_EVENT(fireFocusLost, FocusLostPackage, cFocusLostPackage, cFocusLostEvent)
2542     FIRE_EVENT(fireCaretUpdate, CaretUpdatePackage, cCaretUpdatePackage, cCaretUpdateEvent)
2543     FIRE_EVENT(fireMouseClicked, MouseClickedPackage, cMouseClickedPackage, cMouseClickedEvent)
2544     FIRE_EVENT(fireMouseEntered, MouseEnteredPackage, cMouseEnteredPackage, cMouseEnteredEvent)
2545     FIRE_EVENT(fireMouseExited, MouseExitedPackage, cMouseExitedPackage, cMouseExitedEvent)
2546     FIRE_EVENT(fireMousePressed, MousePressedPackage, cMousePressedPackage, cMousePressedEvent)
2547     FIRE_EVENT(fireMouseReleased, MouseReleasedPackage, cMouseReleasedPackage, cMouseReleasedEvent)
2548     FIRE_EVENT(fireMenuCanceled, MenuCanceledPackage, cMenuCanceledPackage, cMenuCanceledEvent)
2549     FIRE_EVENT(fireMenuDeselected, MenuDeselectedPackage, cMenuDeselectedPackage, cMenuDeselectedEvent)
2550     FIRE_EVENT(fireMenuSelected, MenuSelectedPackage, cMenuSelectedPackage, cMenuSelectedEvent)
2551     FIRE_EVENT(firePopupMenuCanceled, PopupMenuCanceledPackage, cPopupMenuCanceledPackage, cPopupMenuCanceledEvent)
2552     FIRE_EVENT(firePopupMenuWillBecomeInvisible, PopupMenuWillBecomeInvisiblePackage, cPopupMenuWillBecomeInvisiblePackage, cPopupMenuWillBecomeInvisibleEvent)
2553     FIRE_EVENT(firePopupMenuWillBecomeVisible, PopupMenuWillBecomeVisiblePackage, cPopupMenuWillBecomeVisiblePackage, cPopupMenuWillBecomeVisibleEvent)
2554 
2555 
2556     // -----------------------------
2557 
2558 
2559 extern "C" {        // event stuff from AccessBridge.h, generated by JNI
2560 
2561     JNIEXPORT void JNICALL
2562     Java_com_sun_java_accessibility_internal_AccessBridge_sendDebugString(JNIEnv *env, jobject callingObj, jstring debugStr) {
2563 
2564         const wchar_t *stringBytes;
2565         stringBytes = (const wchar_t *) env->GetStringChars(debugStr, 0);
2566         if (stringBytes == NULL) {
2567             if (!env->ExceptionCheck()) {
2568                 jclass cls = env->FindClass("java/lang/OutOfMemoryError");
2569                 if (cls != NULL) {
2570                     env->ThrowNew(cls, NULL);
2571                 }
2572             }
2573             return;
2574         }
2575         wPrintJavaDebugString(L"AccessBridge.java: %ls", stringBytes);
2576         env->ReleaseStringChars(debugStr, stringBytes);
2577     }
2578 
2579     JNIEXPORT void JNICALL
2580     Java_com_sun_java_accessibility_internal_AccessBridge_propertyCaretChange(JNIEnv *env, jobject callingObj,
2581                                                                         jobject event, jobject source,
2582                                                                         jint oldValue, jint newValue) {
2583         theJavaAccessBridge->firePropertyCaretChange(env, callingObj,
2584                                                         event, source,
2585                                                         oldValue, newValue);
2586     }
2587 
2588     JNIEXPORT void JNICALL
2589     Java_com_sun_java_accessibility_internal_AccessBridge_propertyDescriptionChange(JNIEnv *env, jobject callingObj,
2590                                                                             jobject event, jobject source,
2591                                                                             jstring oldValue, jstring newValue) {
2592         theJavaAccessBridge->firePropertyDescriptionChange(env, callingObj,
2593                                                             event, source,
2594                                                             oldValue, newValue);
2595     }
2596 
2597     JNIEXPORT void JNICALL
2598     Java_com_sun_java_accessibility_internal_AccessBridge_propertyNameChange(JNIEnv *env, jobject callingObj,
2599                                                                     jobject event, jobject source,
2600                                                                     jstring oldValue, jstring newValue) {
2601         theJavaAccessBridge->firePropertyNameChange(env, callingObj,
2602                                                     event, source,
2603                                                     oldValue, newValue);
2604     }
2605 
2606     JNIEXPORT void JNICALL
2607     Java_com_sun_java_accessibility_internal_AccessBridge_propertySelectionChange(JNIEnv *env, jobject callingObj,
2608                                                                             jobject event, jobject source) {
2609         theJavaAccessBridge->firePropertySelectionChange(env, callingObj,
2610                                                             event, source);
2611     }
2612 
2613     JNIEXPORT void JNICALL
2614     Java_com_sun_java_accessibility_internal_AccessBridge_propertyStateChange(JNIEnv *env, jobject callingObj,
2615                                                                         jobject event, jobject source,
2616                                                                         jstring oldValue, jstring newValue) {
2617         theJavaAccessBridge->firePropertyStateChange(env, callingObj,
2618                                                         event, source,
2619                                                         oldValue, newValue);
2620     }
2621 
2622     JNIEXPORT void JNICALL
2623     Java_com_sun_java_accessibility_internal_AccessBridge_propertyTextChange(JNIEnv *env, jobject callingObj,
2624                                                                     jobject event,  jobject source) {
2625         theJavaAccessBridge->firePropertyTextChange(env, callingObj,
2626                                                     event, source);
2627     }
2628 
2629     JNIEXPORT void JNICALL
2630     Java_com_sun_java_accessibility_internal_AccessBridge_propertyValueChange(JNIEnv *env, jobject callingObj,
2631                                                                         jobject event, jobject source,
2632                                                                         jstring oldValue, jstring newValue) {
2633         theJavaAccessBridge->firePropertyValueChange(env, callingObj,
2634                                                         event, source,
2635                                                         oldValue, newValue);
2636     }
2637 
2638     JNIEXPORT void JNICALL
2639     Java_com_sun_java_accessibility_internal_AccessBridge_propertyVisibleDataChange(JNIEnv *env, jobject callingObj,
2640                                                                             jobject event,  jobject source) {
2641         theJavaAccessBridge->firePropertyVisibleDataChange(env, callingObj,
2642                                                             event, source);
2643     }
2644 
2645     JNIEXPORT void JNICALL
2646     Java_com_sun_java_accessibility_internal_AccessBridge_propertyChildChange(JNIEnv *env, jobject callingObj,
2647                                                                         jobject event, jobject source,
2648                                                                         jobject oldValue, jobject newValue) {
2649         theJavaAccessBridge->firePropertyChildChange(env, callingObj,
2650                                                         event, source,
2651                                                         oldValue, newValue);
2652     }
2653 
2654     JNIEXPORT void JNICALL
2655     Java_com_sun_java_accessibility_internal_AccessBridge_propertyActiveDescendentChange(JNIEnv *env, jobject callingObj,
2656                                                                                 jobject event,  jobject source,
2657                                                                                 jobject oldValue,
2658                                                                                 jobject newValue) {
2659         theJavaAccessBridge->firePropertyActiveDescendentChange(env, callingObj,
2660                                                                 event, source,
2661                                                                 oldValue, newValue);
2662     }
2663 
2664     JNIEXPORT void JNICALL
2665     Java_com_sun_java_accessibility_internal_AccessBridge_propertyTableModelChange(JNIEnv *env, jobject callingObj,
2666                                                                             jobject event,  jobject source,
2667                                                                             jstring oldValue, jstring newValue) {
2668 
2669         theJavaAccessBridge->firePropertyTableModelChange(env, callingObj,
2670                                                             event, source,
2671                                                             oldValue, newValue);
2672     }
2673 
2674 #define HANDLE_STANDARD_EVENT_FROM_JAVA(function, method) \
2675     JNIEXPORT void JNICALL \
2676     function(JNIEnv *env, jobject callingObj, jobject event, jobject source) { \
2677         theJavaAccessBridge->method(env, callingObj, event, source); \
2678     }
2679 
2680 
2681     JNIEXPORT void JNICALL
2682     Java_com_sun_java_accessibility_internal_AccessBridge_javaShutdown(JNIEnv *env, jobject callingObj) {
2683         theJavaAccessBridge->javaShutdown(env, callingObj);
2684     }
2685 
2686     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_focusGained, fireFocusGained)
2687     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_focusLost, fireFocusLost)
2688     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_caretUpdate, fireCaretUpdate)
2689     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_mouseClicked, fireMouseClicked)
2690     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_mouseEntered, fireMouseEntered)
2691     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_mouseExited, fireMouseExited)
2692     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_mousePressed, fireMousePressed)
2693     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_mouseReleased, fireMouseReleased)
2694     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_menuCanceled, fireMenuCanceled)
2695     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_menuDeselected, fireMenuDeselected)
2696     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_menuSelected, fireMenuSelected)
2697     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_popupMenuCanceled, firePopupMenuCanceled)
2698     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_popupMenuWillBecomeInvisible, firePopupMenuWillBecomeInvisible)
2699     HANDLE_STANDARD_EVENT_FROM_JAVA(Java_com_sun_java_accessibility_internal_AccessBridge_popupMenuWillBecomeVisible, firePopupMenuWillBecomeVisible)
2700 
2701     /*
2702      * Map a HWND to a Java component
2703      *
2704      * Class:     com_sun_java_accessibility_internal_AccessBridge
2705      * Method:    jawtGetComponentFromNativeWindowHandle
2706      * Signature: (I)Ljava/awt/Component;
2707      */
2708     JNIEXPORT jobject JNICALL
2709     Java_com_sun_java_accessibility_internal_AccessBridge_jawtGetComponentFromNativeWindowHandle
2710         (JNIEnv *env, jobject callingObj, jint windowHandle) {
2711 
2712     JAWT awt;
2713     jboolean result;
2714     jobject component = (jobject)0;
2715 
2716     // Get the AWT
2717     awt.version = JAWT_VERSION_1_4;
2718     result = JAWT_GetAWT(env, &awt);
2719     if (result == JNI_FALSE) {
2720         return (jobject)0;
2721     }
2722 
2723     // Get the component
2724     return awt.GetComponent(env, (void *)windowHandle);
2725     }
2726 
2727 
2728     /*
2729      * Map a Java component to a HWND
2730      *
2731      * Class:     com_sun_java_accessibility_internal_AccessBridge
2732      * Method:    jawtGetNativeWindowHandleFromComponent
2733      * Signature: (Ljava/awt/Component;)I
2734      */
2735     JNIEXPORT jint JNICALL
2736     Java_com_sun_java_accessibility_internal_AccessBridge_jawtGetNativeWindowHandleFromComponent
2737         (JNIEnv *env, jobject callingObj, jobject component) {
2738 
2739         JAWT awt;
2740         JAWT_DrawingSurface* ds;
2741         JAWT_DrawingSurfaceInfo* dsi;
2742         JAWT_Win32DrawingSurfaceInfo* dsi_win;
2743         jboolean result;
2744         // jint lock;
2745         jint windowHandle = -1;
2746 
2747         // Get the AWT
2748         awt.version = JAWT_VERSION_1_4;
2749         result = JAWT_GetAWT(env, &awt);
2750         if (result == JNI_FALSE) {
2751             return -1;
2752         }
2753 
2754         // Get the drawing surface
2755         ds = awt.GetDrawingSurface(env, component);
2756         if (ds == NULL) {
2757             return -1;
2758         }
2759 
2760         // Get the drawing surface info
2761         dsi = ds->GetDrawingSurfaceInfo(ds);
2762 
2763         // Get the platform-specific drawing info
2764         dsi_win = (JAWT_Win32DrawingSurfaceInfo *)dsi->platformInfo;
2765 
2766         // Get the window handle
2767         windowHandle = (jint)dsi_win->hwnd;
2768 
2769         // Free the drawing surface info
2770         ds->FreeDrawingSurfaceInfo(dsi);
2771 
2772         // Free the drawing surface
2773         awt.FreeDrawingSurface(ds);
2774 
2775         return windowHandle;
2776     }
2777 
2778 }
--- EOF ---