Ejemplo n.º 1
0
LONG WINAPI myImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
{
	LONG myReturn=0;
	LONG tempLen=0;
	int StrBufLen=0;
	if (dwIndex==GCS_RESULTSTR && g_HOOKflag)
	{
		memset(g_IMEString,0,256);
		tempLen=254;
		g_myHOOK2.HookStatus(false);
		ImmGetCompositionStringW(hIMC,GCS_RESULTSTR,g_IMEString,tempLen);
		g_myHOOK2.HookStatus(true);
		g_IMEString[254]=0;
		g_IMEString[255]=0;
		if (lstrcmpW((wchar_t *)g_IMEString,(wchar_t *)g_StringBuf1)!=0)
		{
			memset(g_StringBuf1,0,256);
			lstrcpyW((wchar_t *)g_StringBuf1,(wchar_t *)g_IMEString);
			WCharToMByte((wchar_t *)g_StringBuf1,g_IMEString,256);
			SendMessage(g_hMainhWnd,WM_HXWDLLWX_QQBTX,0,0);
			memset(g_StringBuf2,0,256);
			MByteToWChar(g_IMEString,(wchar_t *)g_StringBuf2,128);
		}
		if (lpBuf==NULL || dwBufLen==0)
		{
			myReturn=lstrlenW((wchar_t *)g_StringBuf2)*2;
		}
		else
		{
			StrBufLen=lstrlenW((wchar_t *)g_StringBuf2)*2;
			memset(lpBuf,0,dwBufLen);
			if (dwBufLen>=StrBufLen) 
			{
				dwBufLen=StrBufLen;
				myReturn=StrBufLen;
			}
			else
			{
				myReturn=0;
			}
			memcpy(lpBuf,g_StringBuf2,dwBufLen);
		}
	}
	else
	{
		g_myHOOK2.HookStatus(false);
		myReturn=ImmGetCompositionStringW(hIMC,dwIndex,lpBuf,dwBufLen);
		g_myHOOK2.HookStatus(true);
	}
	return myReturn;
}
Ejemplo n.º 2
0
void CharInputFunc(GLFWwindow *, unsigned int c) {
	if (c >= 128) {
		wchar_t* pwszUnicode = new wchar_t[2];
		pwszUnicode[0] = (wchar_t)c;
		pwszUnicode[1] = '\0';
		char* pszMultiByte;
		pszMultiByte = (char*)malloc((unsigned int)4);
		pszMultiByte = (char*)realloc(pszMultiByte, WCharToMByte(pszMultiByte, pwszUnicode, 4));
		inputstr += pszMultiByte;
		free(pszMultiByte);
		delete[] pwszUnicode;
	}
	else inputstr += (char)c;
}
Ejemplo n.º 3
0
PSTR TitleWCharToMByte(PCWSTR Unicode)
{
    if (Unicode[0] == 0xFFFF)
    {
        PSTR ResourceId = (PSTR)AllocateMemoryP(4);
        if (ResourceId == NULL)
            return NULL;

        ResourceId[0] = -1;
        *(PUSHORT)&ResourceId[1] = Unicode[1];
        ResourceId[3] = 0;

        return ResourceId;
    }

    return WCharToMByte(Unicode);
}
Ejemplo n.º 4
0
PSTR ClassWCharToMByte(PCWSTR Unicode)
{
    return IS_ATOM(Unicode) ? (PSTR)Unicode : WCharToMByte(Unicode);
}
//保存Info和自定义属性
void SaveInfo(LPWSTR title, LPWSTR author, LPWSTR subject, LPWSTR keywords, List attrs)
{
	FILE *fp;
	if((fp=fopen(PDFPath,"wb"))==0)
	{
		printf("cannot open %s\n",PDFPath);
		system("pause");
		exit(0);
	}
	List writer = InitList();
	LPSTR str;
	//生成新的Info
	AddASCII(writer, IntToString(Info));
	AddASCII(writer, " 0 obj\r\n<</Title(");
	AddBigEndianUnicode(writer, title);
	AddASCII(writer, ")/Author(");
	AddBigEndianUnicode(writer, author);
	AddASCII(writer, ")/Subject(");
	AddBigEndianUnicode(writer, subject);
	AddASCII(writer, ")/Keywords(");
	AddBigEndianUnicode(writer, keywords);
	AddASCII(writer, ")/CreationDate(");
	AddASCII(writer, WCharToMByte(CreationDate));
	AddASCII(writer, ")/ModDate(");
	AddASCII(writer, WCharToMByte(ModDate));
	AddASCII(writer, ")/Creator(");
	AddBigEndianUnicode(writer, Creator);
	AddASCII(writer, ")/Producer(");
	AddBigEndianUnicode(writer, Producer);
	int i;
	Attr attr;
	for(i=0;i<attrs->length;i++)
	{
		attr=(Attr)GetNodeData(attrs,i);
		AddASCII(writer, ")/");
		AddASCII(writer, attr->Name);
		AddASCII(writer, "(");
		AddBigEndianUnicode(writer, attr->Value);
	}
	AddASCII(writer, ")>>\r\nendobj");


	int index = 0;
	int pointA = InfoAt;
	int pointB = InfoEnd;
	int gap = writer->length - pointB + pointA;
	//更新xrefs
	Xref xref;
	for (i = 0; i < xrefs->length; i++)
	{
		xref=(Xref)GetNodeData(xrefs,i);
		xref->newXrefOffset = xref->xrefOffset;
		xref->newPrev = xref->trailer->Prev;
		if (i > 0)
		{
			xref->newPrev = ((Xref)GetNodeData(xrefs,i-1))->newXrefOffset;
		}
		if (xref->xrefOffset > pointA)        //未检测位数变化
		{
			xref->newXrefOffset += gap;
		}
		if (xref->trailer->XRefStm > pointA)
		{
			xref->trailer->XRefStm += gap;
		}
	}
	int newStartxref = xref->newXrefOffset;
	List newXrefs=InitList();
	int j,min,offset=0;
	Xref minOffsetXref;
	for(i=0;i<xrefs->length;i++)//鉴于xref不会很多,暂时用n^2的低效算法
	{
		min=MAXINT;
		for(j=0;j<xrefs->length;j++)
		{
			xref=(Xref)GetNodeData(xrefs,j);
			if(xref->xrefOffset<=offset)continue;
			if(xref->xrefOffset<min){
				min=xref->xrefOffset;
				minOffsetXref=xref;
			}
		}
		offset=minOffsetXref->xrefOffset;
		AddNode(newXrefs,minOffsetXref);
	}
	xrefs=newXrefs;
	int pos = 0;
	for(i=0;i<xrefs->length;i++)   //pos确定Info在Xrefs的排位,指示在哪一个xref之前
	{
		if (((Xref)GetNodeData(xrefs,i))->xrefOffset < pointA) pos++;
		else break;
	}

	index=SaveXrefs(fp, index, gap, 0, pos, newStartxref,InfoAt);
	//写到Info之前,此处不能fwrite因为起始点不为0
	while (index < pointA)
	{
		fputc(PDFInByte[index++],fp);
	}
	//重写Info
	fwrite(CharListGetString(writer),sizeof(char),writer->length,fp);
	//写Info之后
	index = pointB;
	index=SaveXrefs(fp,index, gap, pos, xrefs->length, newStartxref,InfoAt);
	fclose(fp);
}