Esempio n. 1
0
static t_BlockInfo* GetBlockInfo(byte *block) {
	t_BlockInfo *p_blockinfo;
	byte *p_begin;
	byte *p_end;

	ASSERT(NULL != block);
	for (p_blockinfo = g_head; NULL != p_blockinfo; p_blockinfo = p_blockinfo->m_next) {
		p_begin = BLOCK_BEGIN(p_blockinfo->m_begin);
		p_end = BLOCK_END(p_blockinfo->m_begin, p_blockinfo->m_size);
		if (p_begin > block || p_end < block)
			continue;
		else
			break;
	}

	ASSERT(NULL != p_blockinfo);
	return p_blockinfo;
}
Esempio n. 2
0
JNIEXPORT jobject JNICALL
                  Java_net_javajeff_jtwain_JTwain_acquire
                  (JNIEnv *env,
                   jclass clazz)
{
   // Create a static window whose handle is passed to DSM_Entry() when we
   // open the data source manager.

   HWND hwnd = CreateWindow ("STATIC",
                             "",
                             WS_POPUPWINDOW,
                             CW_USEDEFAULT,
                             CW_USEDEFAULT,
                             CW_USEDEFAULT,
                             CW_USEDEFAULT,
                             HWND_DESKTOP,
                             0,
                             g_hinstDLL,
                             0);

   // If window could not be created, throw exception. Because the exception
   // is not actually thrown until execution returns to Java, we must return
   // a value -- (jobject) 0 was chosen to represent Image null. This value
   // will not be seen in the Java code because of the exception.

   if (hwnd == 0)
   {
       throwJTE (env, "Unable to create private window (acquire)");
       return (jobject) 0;
   }

   // Ensure that the default data source's dialog box does not disappear
   // behind other windows, which can be very disconcerting to the user. We do
   // that by making the hwnd -- created above and passed to DSM_Entry() below
   // -- the handle of the topmost window.

   SetWindowPos (hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE);

   TW_UINT16 rc;
   jobject image = 0;

   BLOCK_BEGIN(1)

   // Open the data source manager.

   rc = (*g_pDSM_Entry) (&g_AppID,
                         0,
                         DG_CONTROL,
                         DAT_PARENT,
                         MSG_OPENDSM,
                         (TW_MEMREF) &hwnd);

   // If data source manager could not be opened, throw exception. Because the
   // exception is not actually thrown until execution returns to Java, we
   // first exit current block to destroy previously-created window and return
   // a value (which isn't seen in the Java code).

   if (rc != TWRC_SUCCESS)
   {
       throwJTE (env, "Unable to open data source manager (acquire)");
       EXIT_CURRENT_BLOCK
   }