1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507 |
- #include "StdAfx.h"
- #include "YtDongle.h"
- #include <strsafe.h>
- namespace YtDongle
- {
- CHAR *g_pHReadPassWord = NULL;
- CHAR *g_pLReadPassWord = NULL;
- CHAR *g_pHWritePassWord = NULL;
- CHAR *g_pLWritePassWord = NULL;
- BOOL g_bUSE_NEWPASSWORD = FALSE;
- // 加密解密密钥;
- CHAR *g_szEncKey[][4] = {
- { "5A11475E", "39F530AD", "DCE97937", "6BCDB275" }, // 儿童全能版;
- { "04BBE109", "E3AFEA47", "778414D1", "16785D1F" }, // 儿童座席版;
- { "4900364D", "28E42F9C", "CBD86826", "5ACCA264" }, // 儿童企业版;
- { "BA7DA71F", "A17DB814", "C411F1AE", "A34531FD" }, // 婚纱全能版;
- { "F3A690F8", "828AD936", "667E03C0", "05674C0E" }, // 婚纱座席版;
- { "EC9FC9E1", "773E7E16", "0612A764", "A907E0F2" } // 婚纱企业版;
- };
- CHAR *g_szRom[] = {
- "9E5B96F2223FCF8CC12308DABF669CB4", // 000
- "873A748B773F7E261623B775A907F0F3", // 033
- "7C2359705B1752BEEEFB9B4816785D2F", // 066
- "4EF5EF37D1D91881B0CD5D1F44B19659", // 099
- "CA7DA7CF9951A0493845DA97DC391325", // 132
- "1CD3CD15BFB7F66F9EAB3BFD118E6326", // 165
- "3EE5DF32D1991480607D5D0E4F614658", // 198
- "4FB2FC03EEAA2592819E2EDC1072676A" // 231
- // 264 是座席数使用的地址;
- // 297 是域名值使用的地址;
- // 330 是医院系统使用的地址;
- };
- CHAR *g_szPassword[][2] = {
- //////////////////////////////////////////////////////////////////////////
- // 旧密码;
- { "7528527A", "541C5CF4" }, // 读密码 高低;
- { "E4F08542", "87E5CED0" }, // 写密码 高低;
- //////////////////////////////////////////////////////////////////////////
- // 新密码;
- { "9201B009", "26B43D72" }, // 读密码 高低;
- { "AA679BD9", "302B1952" } // 写密码 高低;
- };
- // 用户自定义密钥;
- CHAR *g_szUserKey = { "20D30D15FFB7F6AF9EAB30FD229F797B" };
- //////////////////////////////////////////////////////////////////////////
- // 锁内存数据;
- BYTE g_byShotVersion[][10] =
- {
- { 0x06, 0x00, 0xC2, 0xC7, 0xD2, 0x43, 0xB9, 0x01, 0x8A, 0xC3 }, // 儿童全能版;
- { 0x06, 0x00, 0x94, 0x0B, 0xCD, 0x32, 0x04, 0xAB, 0x20, 0x27 }, // 儿童座席版;
- { 0x06, 0x00, 0x04, 0xBB, 0x67, 0x0A, 0x3B, 0xA9, 0xF0, 0xDC }, // 儿童企业版;
- { 0x06, 0x00, 0xBC, 0x91, 0x64, 0x2F, 0x9A, 0xB1, 0x22, 0xCD }, // 婚纱全能版;
- { 0x06, 0x00, 0x04, 0x1D, 0x18, 0xF7, 0xBD, 0x5F, 0x53, 0x4C }, // 婚纱座席版;
- { 0x06, 0x00, 0x89, 0xA0, 0xE6, 0xAD, 0xCA, 0x02, 0x75, 0x8E } // 婚纱企业版;
- };
- //////////////////////////////////////////////////////////////////////////
- // 用于计算经典版加密锁加时授权码;
- BYTE g_byTimeRegCode[][58] =
- {
- { 0x31, 0x00, 0xAF, 0xD1, 0x1C, 0x68, 0x93, 0xA7, 0x92, 0x7D, 0xCE, 0x5B, 0xB9, 0x0A, 0xD7, 0xA8, 0x7F, 0x4F, 0x58, 0x3F, 0x40, 0xC8, 0xBB, 0xEA, 0xE6, 0x42, 0x74, 0xFC, 0x67,
- 0xE8, 0x54, 0x89, 0x85, 0x15, 0x4F, 0xE2, 0x96, 0x78, 0x00, 0xB7, 0x75, 0x2D, 0xC4, 0x03, 0xFB, 0x13, 0x5C, 0xD0, 0x0C, 0x77, 0xFF, 0xCA, 0x8D, 0x4F, 0xDC, 0xAC, 0x6E, 0xED }, // 儿童全能版;
- { 0x31, 0x00, 0x75, 0xE7, 0xAF, 0x0E, 0xB8, 0x60, 0x75, 0xFD, 0xE1, 0x79, 0xE3, 0x7E, 0x1F, 0x9E, 0x85, 0xD0, 0xD5, 0xB0, 0xFD, 0x94, 0xE3, 0x10, 0xC8, 0x02, 0x0C, 0xC5, 0x6B,
- 0x4E, 0x6B, 0xE7, 0xBA, 0x9E, 0x18, 0xDD, 0xE8, 0x79, 0x04, 0xB9, 0x9E, 0x4D, 0xA2, 0x32, 0xE1, 0x60, 0x13, 0x22, 0xA1, 0xA4, 0xB7, 0x68, 0xB3, 0xD6, 0x75, 0xD9, 0xAE, 0x33 }, // 儿童座席版;
- { 0x31, 0x00, 0xDB, 0x65, 0x89, 0x92, 0x8A, 0xD1, 0xFE, 0x64, 0x86, 0x45, 0x1C, 0x50, 0x0F, 0xBD, 0x06, 0x93, 0x23, 0x56, 0xC2, 0x9F, 0x8A, 0xC8, 0xEE, 0x5F, 0x3C, 0x52, 0x57,
- 0x89, 0x3B, 0x03, 0x5A, 0x30, 0x43, 0xB5, 0xE4, 0x94, 0xBC, 0xE4, 0x0C, 0xB2, 0x92, 0xD5, 0x09, 0x89, 0xE9, 0x45, 0xD7, 0x4B, 0xF8, 0x30, 0xBA, 0xE6, 0x4A, 0x13, 0x9A, 0xCB }, // 儿童企业版;
- { 0x31, 0x00, 0x81, 0x42, 0x2A, 0x16, 0x26, 0x48, 0xEE, 0x90, 0xEA, 0xDD, 0xEC, 0xCA, 0x93, 0xFF, 0x3C, 0x12, 0x06, 0x76, 0xA9, 0xE5, 0xA9, 0xDE, 0xF9, 0x69, 0x9B, 0x19, 0xB8,
- 0x1D, 0xD5, 0x05, 0x33, 0x5A, 0x59, 0x20, 0x50, 0xC9, 0x3D, 0x12, 0x61, 0xFD, 0xF0, 0x9E, 0x85, 0xAE, 0x89, 0xF8, 0x49, 0x41, 0x02, 0xA6, 0x95, 0x82, 0x3A, 0xE7, 0xC6, 0x4E }, // 婚纱全能版;
- { 0x31, 0x00, 0xE6, 0xB3, 0x38, 0x6D, 0xB3, 0x13, 0xFD, 0xF1, 0x23, 0x5F, 0x4C, 0xEA, 0xA3, 0x1D, 0xB8, 0xA2, 0x47, 0xB4, 0xAC, 0x97, 0xB1, 0xF0, 0x29, 0x38, 0x6E, 0x87, 0x44,
- 0xCA, 0x91, 0x85, 0x02, 0x0F, 0xCC, 0x59, 0x94, 0x28, 0x08, 0x76, 0x40, 0x5E, 0xD1, 0xA1, 0x75, 0x5B, 0x6B, 0xCA, 0xEE, 0x7B, 0x90, 0xE0, 0xDD, 0xFF, 0x47, 0x4A, 0xA9, 0x86 }, // 婚纱座席版;
- { 0x31, 0x00, 0x0E, 0x64, 0x83, 0x39, 0xA6, 0x51, 0x31, 0xB6, 0xF3, 0x16, 0x16, 0xB9, 0xCE, 0x78, 0x4B, 0x43, 0x85, 0xBF, 0x97, 0x47, 0x98, 0x0E, 0x5D, 0x9E, 0x3D, 0x41, 0x18,
- 0x1B, 0xF8, 0xC6, 0xBE, 0xDC, 0xF9, 0xB8, 0x18, 0x8D, 0x0D, 0x90, 0x9F, 0xB2, 0x70, 0xBE, 0x49, 0xA1, 0xAF, 0x9B, 0x6B, 0x80, 0x8C, 0xDF, 0x8F, 0x5B, 0xEC, 0xBD, 0xBE, 0xF4 } // 婚纱企业版;
- };
- // 用于解密加时授权码regcode;
- BYTE g_byDecryptRegCode[58] = { 0x31, 0x00, 0x81, 0x42, 0x2A, 0x16, 0x26, 0x48, 0xEE, 0x90, 0xEA, 0xDD, 0xEC, 0xCA, 0x93, 0xFF, 0x3C, 0x12, 0x06, 0x76, 0xA9, 0xE5, 0xA9, 0xDE, 0xF9, 0x69, 0x9B, 0x19,
- 0xB8, 0x1D, 0xD5, 0x05, 0x33, 0x5A, 0x13, 0x18, 0xB0, 0xF0, 0x77, 0xEF, 0xE9, 0x9B, 0xEA, 0x9C, 0x2D, 0xBF, 0x59, 0x53, 0x5C, 0x7B, 0x02, 0xA6, 0x95, 0x82, 0x3A, 0xE7, 0xC6, 0x4E };
- // start---------------加密表达式加密后的数组----------------------;
- CONST BYTE g_byCalExVersion[][114] =
- {
- // 儿童全能版;
- { 0x6D, 0x00, 0x1A, 0xDE, 0x00, 0xEF, 0xC7, 0xC7, 0xBC, 0xE1, 0xB4, 0xA8, 0xB2, 0xD0, 0x15, 0x4F, 0x3E, 0x5A, 0x33, 0x1F, 0x58, 0x80, 0xB4, 0x69, 0x35, 0x89, 0xE6, 0xFE, 0xF4,
- 0x32, 0xC3, 0x31, 0xA7, 0x8F, 0xA8, 0x7D, 0x82, 0x7D, 0x08, 0x49, 0xE0, 0x78, 0x50, 0x5F, 0xB2, 0x31, 0x2C, 0x9E, 0x26, 0x26, 0xF7, 0xA9, 0x3E, 0xBB, 0x77, 0xC0, 0x4D, 0xC2,
- 0x76, 0xF6, 0x85, 0xF1, 0x9D, 0x3E, 0x90, 0x18, 0x5E, 0xAD, 0x31, 0xC0, 0x2E, 0xFA, 0xF9, 0xEF, 0x52, 0x4E, 0x87, 0x03, 0x56, 0x9A, 0x08, 0x87, 0xB4, 0xA8, 0xB2, 0xD0, 0x15,
- 0x4F, 0x3E, 0x5A, 0x33, 0x1F, 0x58, 0x80, 0xB4, 0x69, 0x35, 0x89, 0xE6, 0xFE, 0xF4, 0x32, 0xC3, 0x31, 0xA7, 0x8F, 0xF1, 0xD6, 0x26, 0xB4, 0xC6, 0x03, 0x9E, 0xA5 },
- // 儿童座席版;
- { 0x6D, 0x00, 0x5A, 0x0F, 0x6C, 0x8A, 0x25, 0xBE, 0x52, 0x08, 0x14, 0xFC, 0x20, 0xA2, 0x07, 0x08, 0xFE, 0xFF, 0x38, 0xF5, 0xC2, 0x04, 0x2E, 0x78, 0x31, 0x78, 0x9C, 0x1B, 0x11,
- 0xA4, 0xD9, 0x4F, 0xA7, 0x92, 0xC5, 0x45, 0x37, 0x75, 0xC5, 0x95, 0x2A, 0xD9, 0x97, 0xC3, 0xFE, 0x91, 0xBB, 0xC5, 0xE8, 0xBC, 0x72, 0xDF, 0x28, 0xE5, 0x97, 0xF5, 0x74, 0xB1,
- 0x8D, 0x5E, 0x86, 0x0E, 0x0D, 0xA9, 0xA5, 0x5E, 0x05, 0xD8, 0xEB, 0x3C, 0xB0, 0x26, 0xAE, 0x79, 0xBB, 0xAE, 0x10, 0x1E, 0x11, 0x14, 0xF6, 0x22, 0x14, 0xFC, 0x20, 0xA2, 0x07,
- 0x08, 0xFE, 0xFF, 0x38, 0xF5, 0xC2, 0x04, 0x2E, 0x78, 0x31, 0x78, 0x9C, 0x1B, 0x11, 0xA4, 0xD9, 0x4F, 0xA7, 0x92, 0x8F, 0x84, 0xDB, 0xAD, 0xD3, 0x02, 0x63, 0xB4 },
- // 儿童企业版;
- { 0x6D, 0x00, 0xE5, 0x24, 0xDF, 0xDE, 0xD5, 0x2E, 0x46, 0x37, 0xF0, 0xCF, 0xED, 0x4B, 0xE2, 0x44, 0x85, 0x64, 0x2A, 0x77, 0x59, 0x83, 0x4F, 0x68, 0x9E, 0x11, 0xAC, 0xEF, 0x04,
- 0x9E, 0xC9, 0x33, 0x3E, 0x33, 0x5E, 0xE8, 0x0E, 0x7C, 0x51, 0x40, 0x64, 0x8D, 0xBB, 0x55, 0x9C, 0x3B, 0xCD, 0x74, 0xC8, 0x18, 0x6C, 0xDA, 0x91, 0x16, 0x07, 0x24, 0x2D, 0x07,
- 0x9C, 0xFF, 0xAA, 0x82, 0xA5, 0x8C, 0x63, 0xD8, 0x78, 0x48, 0xAB, 0xC4, 0x1B, 0x31, 0x8A, 0xC7, 0x89, 0xF6, 0xD6, 0xF7, 0x79, 0x72, 0xD7, 0xC7, 0xF0, 0xCF, 0xED, 0x4B, 0xE2,
- 0x44, 0x85, 0x64, 0x2A, 0x77, 0x59, 0x83, 0x4F, 0x68, 0x9E, 0x11, 0xAC, 0xEF, 0x04, 0x9E, 0xC9, 0x33, 0x3E, 0x33, 0xF8, 0xD6, 0x1B, 0xFE, 0xDD, 0xD0, 0xB5, 0xD1 },
- // 婚纱全能版;
- { 0x6D, 0x00, 0x8B, 0x91, 0xA3, 0xB0, 0x42, 0x12, 0xCF, 0x4F, 0xAC, 0xC8, 0x0C, 0x7C, 0x59, 0x97, 0xF8, 0xEE, 0x1A, 0x55, 0x89, 0x92, 0x77, 0x3A, 0x4C, 0xC2, 0x97, 0xEF, 0xCC,
- 0x68, 0x12, 0xA6, 0xD0, 0x36, 0x25, 0x55, 0x03, 0xAE, 0x1C, 0x4A, 0x9A, 0x9C, 0x78, 0xC2, 0x08, 0x70, 0x4F, 0x2A, 0x1B, 0x59, 0x51, 0x5F, 0xEE, 0x4A, 0x3B, 0xC7, 0xA0, 0x65,
- 0x75, 0xB3, 0x33, 0x8A, 0x46, 0xB0, 0xEF, 0xB6, 0xA0, 0xD4, 0x0B, 0x21, 0xE0, 0x4A, 0x9B, 0x8F, 0xD8, 0x0A, 0xDC, 0x47, 0x08, 0xA8, 0x12, 0xAF, 0xAC, 0xC8, 0x0C, 0x7C, 0x59,
- 0x97, 0xF8, 0xEE, 0x1A, 0x55, 0x89, 0x92, 0x77, 0x3A, 0x4C, 0xC2, 0x97, 0xEF, 0xCC, 0x68, 0x12, 0xA6, 0xD0, 0x36, 0x72, 0x76, 0xB5, 0x18, 0xFC, 0x29, 0xF6, 0x58 },
- // 婚纱座席版;
- { 0x6D, 0x00, 0x80, 0x0D, 0xA4, 0x8F, 0xFC, 0x57, 0x1E, 0x30, 0x14, 0x15, 0x91, 0x72, 0xA0, 0x60, 0x31, 0x7F, 0xB5, 0x20, 0x90, 0xD5, 0x6D, 0x63, 0x8E, 0xDB, 0x47, 0x1A, 0x16,
- 0xDC, 0xB1, 0xB3, 0xBF, 0x52, 0x8A, 0x2D, 0xAD, 0xA0, 0x09, 0x53, 0xA2, 0x6A, 0xB6, 0xAF, 0x2F, 0x5C, 0xD6, 0x4E, 0x5D, 0x15, 0xCA, 0xA5, 0xA7, 0xC8, 0xC6, 0xAC, 0xDA, 0x4A,
- 0xEC, 0xC2, 0xC2, 0xE4, 0x28, 0x1B, 0x5F, 0x3C, 0xA0, 0xAD, 0x42, 0xB9, 0xB2, 0x07, 0x9F, 0xDC, 0x3A, 0x47, 0x8C, 0x13, 0x14, 0x25, 0x42, 0x54, 0x14, 0x15, 0x91, 0x72, 0xA0,
- 0x60, 0x31, 0x7F, 0xB5, 0x20, 0x90, 0xD5, 0x6D, 0x63, 0x8E, 0xDB, 0x47, 0x1A, 0x16, 0xDC, 0xB1, 0xB3, 0xBF, 0x52, 0xE8, 0xB6, 0x2D, 0x1B, 0x0D, 0xC3, 0xE1, 0xCC },
- // 婚纱企业版;
- { 0x6D, 0x00, 0x5E, 0xDC, 0x28, 0xB6, 0x1E, 0x78, 0x38, 0xC1, 0x4E, 0x65, 0x01, 0x90, 0x44, 0xCE, 0xC0, 0x34, 0x43, 0x09, 0xF3, 0x14, 0x09, 0xC3, 0x99, 0x0F, 0x16, 0xD9, 0xF3,
- 0x4F, 0xB1, 0x16, 0x18, 0xAB, 0xB9, 0x9D, 0xAC, 0x43, 0x75, 0x7C, 0x99, 0xA5, 0x03, 0x29, 0xDA, 0x2F, 0x95, 0x96, 0x30, 0x98, 0x4B, 0xFA, 0xCC, 0xFD, 0x5C, 0x35, 0x79, 0x93,
- 0xF2, 0x8C, 0x50, 0x42, 0x22, 0xC2, 0x10, 0x6D, 0xED, 0x11, 0xDE, 0xA1, 0x60, 0x08, 0x0B, 0xC2, 0x3A, 0x2D, 0x56, 0x0F, 0xCF, 0x79, 0xF7, 0x68, 0x4E, 0x65, 0x01, 0x90, 0x44,
- 0xCE, 0xC0, 0x34, 0x43, 0x09, 0xF3, 0x14, 0x09, 0xC3, 0x99, 0x0F, 0x16, 0xD9, 0xF3, 0x4F, 0xB1, 0x16, 0x18, 0xAB, 0x7A, 0xF3, 0xBE, 0x92, 0x4D, 0xDE, 0xD0, 0x81 }
- };
- // endof---------------加密表达式加密后的数组----------------------;
- CONST YtError g_YtError[] = {
- { -1, _T("未找到返回结果变量\n") },
- { -2, _T("未找到 = 符号\n") },
- { -3, _T("代表没有找到相应常数\n") },
- //{-4, _T("未找到返回结果变量\n")},
- { -5, _T("代表找不到字符串的第一个双引号\n") },
- { -6, _T("代表找不到字符串的第二个双引号\n") },
- { -7, _T("IF语句没有找到goto字符\n") },
- { -8, _T("IF语句没有找到第一个比较字符\n") },
- { -9, _T("IF语句没有找到比较符号\n") },
- { -10, _T("两边变量类型不相符\n") },
- { -11, _T("没有找到NOT符号\n") },
- { -12, _T("不是整形变量\n") },
- { -13, _T("代表没有找到相应整形常数\n") },
- { -14, _T("代表没有找到相应字符串常数\n") },
- { -15, _T("代表没有找到相应浮点常数\n") },
- { -16, _T("代表不支持这个运算\n") },
- { -17, _T("代表没有左边括号\n") },
- { -18, _T("代表没有变量\n") },
- { -19, _T("代表没“,”\n") },
- { -20, _T("代表没有右边括号\n") },
- { -21, _T("代表常数超过指这定的范围\n") },
- { -22, _T("代表储存器的地址超过指定的范围,整数不能超过EEPROM_LEN-4,浮点不能超过EEPROM_LEN-8\n") },
- { -23, _T("代表储存器的地址超过指定的范围,字符串不能超过EEPROM_LEN-LEN,其中LEN为字符串的长度\n") },
- { -24, _T("除法中,被除数不能为0\n") },
- { -25, _T("未知错误\n") },
- { -26, _T("第二个变量不在指定的位置\n") },
- { -27, _T("字符串常量超过指定的长度\n") },
- { -28, _T("不是字符串变量\n") },
- { -29, _T("没有第三个变量\n") },
- { -30, _T("GOTO的标识语句不能全为数字\n") },
- { -31, _T("不能打开ENC文件\n") },
- { -32, _T("不能读ENC文件\n") },
- { -33, _T("GOTO CALL不能找到指定的跳转位置\n") },
- { -34, _T("智能卡运算中,未知数据类型\n") },
- { -35, _T("智能卡运算中,未知代码类型\n") },
- { -36, _T("字符串长度超出50\n") },
- { -37, _T("操作时超长,负长\n") },
- { -38, _T("标识重复\n") },
- { -39, _T("程序堆栈溢出\n") },
- { -40, _T("堆栈溢出\n") },
- { -41, _T("不能建立编译文件,请查看文件是否有只读属性,或被其它文件打开\n") },
- { -42, _T("不能写文件,请查看文件是否有只读属性,或被其它文件打开\n") },
- { -43, _T("程序被中途使用END语句结束\n") },
- { -44, _T("程序跳转到外部的空间\n") },
- { -45, _T("传送数据失败\n") },
- { -46, _T("程序超出运算次数,可能是死循环\n") },
- { -47, _T("写密码不正确\n") },
- { -48, _T("读密码不正确\n") },
- { -49, _T("读写EEPROM时,地址溢出\n") },
- { -50, _T("USB操作失败,可能是没有找到相关的指令\n") },
- { -51, _T("打开USB文件句柄失败\n") },
- { -52, _T("使用加密锁加密自定义表达式,生成加密代码时生产错误\n") },
- { -53, _T("无法打开usb设备,可能驱动程序没有安装或没有插入加密锁\n") },
- //{-54, _T("未找到返回结果变量\n")},
- { -55, _T("要加密的数据少于8个字节\n") },
- { -56, _T("返回结果变量错误\n") },
- { -57, _T("初始化密钥错误\n") },
- { -58, _T("e密钥或n模不能为0\n") },
- { -59, _T("初始化MD5错误\n") },
- { -60, _T("MD5运算错误\n") },
- { -61, _T("计算MD5结果时错误\n") },
- { -62, _T("授权次数溢出,不能再进行授权\n") },
- { -63, _T("不能打开指定的文件\n") },
- { -64, _T("不能建立指定的文件\n") },
- { -65, _T("验证码错误,可能是输入解密密钥错误,或注册授权码错误\n") },
- { -66, _T("执行TIMEOUT函数时,输入的ID与锁ID不相符\n") },
- { -67, _T("执行TIMEOUT函数时,智能卡运行函数已到期\n") },
- { -68, _T("操作浮点运算时,输入的参数将会导致返回值是一个无穷值\n") },
- { -69, _T("代表没足够的变量参数\n") },
- { -70, _T("返回变量与函数不相符\n") },
- { -71, _T("浮点数转换字符串时,要转换的数据太大\n") },
- { -72, _T("初始化服务器错误\n") },
- { -73, _T("对缓冲区进行MD5运算时错误\n") },
- { -74, _T("MD5验证IPVAR错误\n") },
- { -75, _T("MD5验证IPCount错误\n") },
- { -76, _T("没有找到对应的SOCKET连接\n") },
- { -77, _T("没有找到要删除的对应的SOCKET连接\n") },
- { -78, _T("没有找到要删除的对应的功能模块号连接\n") },
- { -79, _T("没有找到要增加的对应的功能模块号连接\n") },
- { -80, _T("用户数已超过限制的授权数量\n") },
- { -81, _T("找不到对应的INI文件条目\n") },
- { -82, _T("没有进行初始化服务工作\n") },
- { -83, _T("ref不能应用于常数\n") },
- { -84, _T("代表使用scall,ccall等指令时,传递的参数太多\n") },
- { -85, _T("表示调用scall,ccall,sloadlib,cloadlib等指令时,不能返回运行代码\n") },
- { -86, _T("表示调用scall,ccall,sloadlib,cloadlib等指令时,不能将结果变量返回\n") },
- { -87, _T("表示调用外部DLL时,不能读取指定的DLL\n") },
- { -88, _T("表示调用外部DLL时,不能获取对应函数所在的地址\n") },
- //{-89, _T("未找到返回结果变量\n")},
- //////////////////////////////////////////////////////////////////////////
- { -252, _T("密码不正确\n") },
- { -253, _T("打开加密锁时PIN码错误\n") },
- { -254, _T("设置PIN码错误\n") },
- { -255, _T("操作加密锁时没有进行PIN操作\n") },
- //////////////////////////////////////////////////////////////////////////
- { -1052, _T("可能是输入的授权号不正确\n") },
- { -1053, _T("系统上没有任何智能锁\n") },
- { -1088, _T("发送数据错误\n") },
- { -1089, _T("获取数据错误\n") },
- { -1092, _T("找不到对应的服务端操作码\n") },
- { -1093, _T("表示连接服务时错误\n") },
- { -1095, _T("获取主机名称失败\n") },
- { -1097, _T("建立套字接错误\n") },
- { -1098, _T("绑定套字节端口错误\n") },
- { -1099, _T("表示无效连接,不能进行相关的操作\n") },
- { -2002, _T("表示监听时产生错误\n") },
- { -2003, _T("表示发送的数据长度与接收的数据长度不相符\n") },
- { -2005, _T("表示当前服务不存在任何连接\n") },
- { -2006, _T("表示当前查询节点超出集合范范围\n") },
- { -2009, _T("表示关闭连接错误\n") },
- //////////////////////////////////////////////////////////////////////////
- { -10000, _T("未知错误代码\n") }
- };
- CHAR g_szKeyPath[MAX_PATH] = { 0 };
- //////////////////////////////////////////////////////////////////////////
- /************************************************************************/
- /* 函数:[7/20/2017 IT];
- /* 描述:将ascii字符串转为unicode字符串;
- /* 参数:;
- /* [IN] pszascii ascii字符串:;
- /* [OUT] :;
- /* [IN/OUT] :;
- /* 返回:unicode字符串;
- /* 注意:返回的指针需要手动释放其所指的内存;
- /* 示例:;
- /*
- /* 修改:;
- /* 日期:;
- /* 内容:;
- /************************************************************************/
- WCHAR* ascii2unicode(IN const CHAR* pszascii)
- {
- INT wSize = MultiByteToWideChar(CP_ACP, 0, pszascii, -1, NULL, 0);
- if (wSize == ERROR_NO_UNICODE_TRANSLATION)
- {
- return NULL;
- }
- if (wSize == 0)
- {
- return NULL;
- }
- WCHAR *punicode = new WCHAR[wSize];
- int convresult = MultiByteToWideChar(CP_ACP, 0, pszascii, -1, punicode, wSize);
- if (convresult != wSize)
- {
- if (punicode) delete[]punicode;
- return NULL;
- }
- return punicode;
- }
- void ReSetPassWord(BOOL bClassicPsw /* = FALSE */)
- {
- g_bUSE_NEWPASSWORD = bClassicPsw;
- if (!g_bUSE_NEWPASSWORD)
- {
- g_pHReadPassWord = g_szPassword[0][0];
- g_pLReadPassWord = g_szPassword[0][1];
- g_pHWritePassWord = g_szPassword[1][0];
- g_pLWritePassWord = g_szPassword[1][1];
- }
- else
- {
- g_pHReadPassWord = g_szPassword[2][0];
- g_pLReadPassWord = g_szPassword[2][1];
- g_pHWritePassWord = g_szPassword[3][0];
- g_pLWritePassWord = g_szPassword[3][1];
- }
- }
- void ReadAllClassicYtInfo(IN std::vector<YtUsbInfo*> &vtYtInfo)
- {
- ReSetPassWord(FALSE);
- INT nRetval = 0;
- INT nVal[8] = { 0 };
- DOUBLE fVal[8] = { 0.0 };
- CHAR s0[50] = "", s1[50] = "", s2[50] = "", s3[50] = "", s4[50] = "", s5[50] = "", s6[50] = "", s7[50] = "";
- BOOL bFind = FALSE;
- CHAR szKeyPath[MAX_PATH] = "";
- for (INT nIndex = 0; nIndex < 256; nIndex++)
- {
- memset(szKeyPath, 0, sizeof(szKeyPath));
- nRetval = FindPort(nIndex, szKeyPath);
- if (nRetval != 0 && nIndex == 0) continue;
- if (nRetval != 0) continue;
- for (int i = 0; i < 6; i++)
- {
- // 使用该设备路径锁进行运算;
- nRetval = CalEx(g_byShotVersion[i], 10,
- &nVal[0], &nVal[1], &nVal[2], &nVal[3], &nVal[4], &nVal[5], &nVal[6], &nVal[7],
- &fVal[0], &fVal[1], &fVal[2], &fVal[3], &fVal[4], &fVal[5], &fVal[6], &fVal[7],
- s0, s1, s2, s3, s4, s5, s6, s7, szKeyPath, 20000);
- //如果正确,则返回该设备路径供以后使用;
- if (nRetval == -63) continue;
- if ((nRetval == 0) && (nVal[0] == 123))
- {
- YtUsbInfo *pYtInfo = new YtUsbInfo;
- pYtInfo->nUSBPort = nIndex;
- sprintf_s(pYtInfo->szKeyPath, MAX_PATH, "%s", szKeyPath);
- // 返回锁的短ID及版本号;
- INT nVersion = 0;
- if ((nRetval = GetIDVersion(&pYtInfo->verInfo.dwShortKey, &nVersion, szKeyPath)) != 0)
- {
- // 返回非0表示失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRetval));
- if (pYtInfo)
- delete pYtInfo;
- continue;
- }
- if (pYtInfo->verInfo.dwShortKey == -1)
- {
- // 不是域天智能锁;
- if (pYtInfo)
- delete pYtInfo;
- continue;
- }
- bFind = TRUE;
- pYtInfo->verInfo.nSoftVer = i;
- // 获取加密锁座席数量;
- if ((nRetval = YtReadString(pYtInfo->verInfo.szCCount, 264, ENCRYPT_BLOCK_LEN, g_pHReadPassWord, g_pLReadPassWord, szKeyPath)) != 0)
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRetval));
- // 获取加密锁域名值;
- if ((nRetval = YtReadString(pYtInfo->verInfo.szBranchId, 297, ENCRYPT_BLOCK_LEN, g_pHReadPassWord, g_pLReadPassWord, szKeyPath)) != 0)
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRetval));
- // 获取医院跟踪系统;
- if ((nRetval = YtReadString(pYtInfo->verInfo.szHospital, 330, ENCRYPT_BLOCK_LEN, g_pHReadPassWord, g_pLReadPassWord, szKeyPath)) != 0)
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRetval));
- // 返回加密锁已运行时间;
- if ((nRetval = GetRunTimer(pYtInfo->verInfo.szHasRunyears, pYtInfo->verInfo.szHasRunmonths, pYtInfo->verInfo.szHasRundays, pYtInfo->verInfo.szHasRunhours, pYtInfo->verInfo.szHasRunminutes, pYtInfo->verInfo.szHasRunseconds, szKeyPath)) != 0)
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRetval));
- // 返回加密锁可运行时间;
- DWORD dwShortID = 0; // 锁短ID;
- CHAR szOutString[100] = { 0 };
- CHAR HKey[50] = { 0 }, LKey[50] = { 0 };
- // 30000以后的储存空间为公共区域;
- if ((nRetval = ReadTimeAuthFromEprom(HKey, LKey, szOutString, &dwShortID, 30128, "FFFFFFFF", "FFFFFFFF", szKeyPath)) != 0)
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRetval));
- std::string str = szOutString;
- int nStrPos = str.find("年");
- if (nStrPos != std::string::npos)
- {
- sprintf_s(pYtInfo->verInfo.szCanRunyears, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("年"));
- nStrPos = str.find("月");
- sprintf_s(pYtInfo->verInfo.szCanRunmonths, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("月"));
- nStrPos = str.find("日");
- sprintf_s(pYtInfo->verInfo.szCanRundays, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("日"));
- nStrPos = str.find("小时");
- sprintf_s(pYtInfo->verInfo.szCanRunhours, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("小时"));
- nStrPos = str.find("分钟");
- sprintf_s(pYtInfo->verInfo.szCanRunminutes, "%s", str.substr(0, nStrPos).c_str());
- //str = str.substr(nStrPos + strlen("分钟"));
- }
- vtYtInfo.push_back(pYtInfo);
- }
- }
- }
- }
- BOOL ReadYtInfoVer1(IN CONST INT &nUSBStartPos, OUT YtInfoVer1 &Infover1, OUT INT &nUSBPort, OUT CHAR* pszKeyPath, IN CONST INT &nKeypath)
- {
- INT nRetval = 0;
- INT nVal[8] = { 0 };
- DOUBLE fVal[8] = { 0.0 };
- CHAR s0[50] = "", s1[50] = "", s2[50] = "", s3[50] = "", s4[50] = "", s5[50] = "", s6[50] = "", s7[50] = "";
- BOOL bFind = FALSE;
- CHAR szKeyPath[MAX_PATH] = "";
- for (INT nIndex = nUSBStartPos; nIndex < 256; nIndex++)
- {
- memset(szKeyPath, 0, sizeof(szKeyPath));
- nRetval = FindPort(nIndex, szKeyPath);
- if (nRetval != 0 && nIndex == 0) continue;
- if (nRetval != 0) continue;
- for (int i = 0; i < 6; i++)
- {
- // 使用该设备路径锁进行运算;
- nRetval = CalEx(g_byShotVersion[i], 10,
- &nVal[0], &nVal[1], &nVal[2], &nVal[3], &nVal[4], &nVal[5], &nVal[6], &nVal[7],
- &fVal[0], &fVal[1], &fVal[2], &fVal[3], &fVal[4], &fVal[5], &fVal[6], &fVal[7],
- s0, s1, s2, s3, s4, s5, s6, s7, szKeyPath, 20000);
- //如果正确,则返回该设备路径供以后使用;
- if (nRetval == -63) continue;
- if ((nRetval == 0) && (nVal[0] == 123))
- {
- nUSBPort = nIndex;
- if (pszKeyPath)
- sprintf_s(pszKeyPath, nKeypath, "%s", szKeyPath);
- // 返回锁的短ID及版本号;
- INT nVersion = 0;
- if ((nRetval = GetIDVersion(&Infover1.dwShortKey, &nVersion, szKeyPath)) != 0)
- {
- // 返回非0表示失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRetval));
- return FALSE;
- }
- if (Infover1.dwShortKey == -1)
- {
- // 不是域天智能锁;
- return FALSE;
- }
- bFind = TRUE;
- Infover1.nSoftVer = i;
- // 获取加密锁座席数量;
- if ((nRetval = YtReadString(Infover1.szCCount, 264, ENCRYPT_BLOCK_LEN, g_pHReadPassWord, g_pLReadPassWord, szKeyPath)) != 0)
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRetval));
- // 获取加密锁域名值;
- if ((nRetval = YtReadString(Infover1.szBranchId, 297, ENCRYPT_BLOCK_LEN, g_pHReadPassWord, g_pLReadPassWord, szKeyPath)) != 0)
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRetval));
- // 获取医院跟踪系统;
- if ((nRetval = YtReadString(Infover1.szHospital, 330, ENCRYPT_BLOCK_LEN, g_pHReadPassWord, g_pLReadPassWord, szKeyPath)) != 0)
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRetval));
- // 返回加密锁已运行时间;
- if ((nRetval = GetRunTimer(Infover1.szHasRunyears, Infover1.szHasRunmonths, Infover1.szHasRundays, Infover1.szHasRunhours, Infover1.szHasRunminutes, Infover1.szHasRunseconds, szKeyPath)) != 0)
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRetval));
- // 返回加密锁可运行时间;
- DWORD dwShortID = 0; // 锁短ID;
- CHAR szOutString[100] = { 0 };
- CHAR HKey[50] = { 0 }, LKey[50] = { 0 };
- // 30000以后的储存空间为公共区域;
- if ((nRetval = ReadTimeAuthFromEprom(HKey, LKey, szOutString, &dwShortID, 30128, "FFFFFFFF", "FFFFFFFF", szKeyPath)) != 0)
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRetval));
- std::string str = szOutString;
- int nStrPos = str.find("年");
- if (nStrPos != std::string::npos)
- {
- sprintf_s(Infover1.szCanRunyears, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("年"));
- nStrPos = str.find("月");
- sprintf_s(Infover1.szCanRunmonths, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("月"));
- nStrPos = str.find("日");
- sprintf_s(Infover1.szCanRundays, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("日"));
- nStrPos = str.find("小时");
- sprintf_s(Infover1.szCanRunhours, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("小时"));
- nStrPos = str.find("分钟");
- sprintf_s(Infover1.szCanRunminutes, "%s", str.substr(0, nStrPos).c_str());
- }
- break;
- }
- }
- if (bFind) break;
- }
- return bFind;
- }
- BOOL ModifyYtVer1Info(IN CHAR* pszKeypath, IN YtInfoVer1 &Infover1, IN CONST INT &nModifyType)
- {
- // 修改类型有:加减运行时间、加减座席数量、开通或关闭医院功能。
- switch (nModifyType)
- {
- case VER1_ADDCCOUNT:
- break;
- case VER1_MINUSCCOUNT:
- break;
- case VER1_HOSPITAL:
- break;
- case VER1_ADDTIME:
- break;
- case VER1_MINUSTIME:
- break;
- default:
- break;
- }
- return TRUE;
- }
- BOOL ChangeConnectCount(IN CHAR* pszKeypath, IN CONST INT& nCCount)
- {
- if (pszKeypath == NULL)
- {
- OutputDebugString(_T("usb路径无效!\n"));
- return FALSE;
- }
- // 264是座席数量;
- if (nCCount >= 0)
- {
- CHAR szCCount[ENCRYPT_BLOCK_LEN] = { 0 }; // 包含结束符;
- sprintf_s(szCCount, "%d", nCCount);
- INT nRet = YtWriteString(szCCount, 264, g_pHWritePassWord, g_pLWritePassWord, pszKeypath);
- if (nRet <= 0)
- {
- // 设置座席数失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- }
- return TRUE;
- }
- BOOL ChangeBranchId(IN CHAR* pszKeypath, IN CONST CHAR* pszBranchId, IN CONST INT& dwShortKey)
- {
- if (pszKeypath == NULL)
- {
- OutputDebugString(_T("usb路径无效!\n"));
- return FALSE;
- }
- // 297是域名值;
- // 生成域名串 = 日期 + 短ID;
- CHAR szDomain[ENCRYPT_BLOCK_LEN] = { 0 }; // 包含结束符;
- sprintf_s(szDomain, "%s%d.ly.com", pszBranchId, dwShortKey);
- INT nRet = YtWriteString(szDomain, 297, g_pHWritePassWord, g_pLWritePassWord, pszKeypath);
- if (nRet <= 0)
- {
- // 生成域名错误;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- return TRUE;
- }
- BOOL ChangeHospital(IN CHAR* pszKeypath, IN BOOL bEnableHospital)
- {
- if (pszKeypath == NULL)
- {
- OutputDebugString(_T("usb路径无效!\n"));
- return FALSE;
- }
- // 330是医院跟踪系统;
- CHAR szHospital[ENCRYPT_BLOCK_LEN] = { 0 }; // 包含结束符;
- sprintf_s(szHospital, "%d", bEnableHospital);
- INT nRet = YtWriteString(szHospital, 330, g_pHWritePassWord, g_pLWritePassWord, pszKeypath);
- if (nRet <= 0)
- {
- // 设置医院跟踪系统失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- return TRUE;
- }
- BOOL ChangeRunTime(IN CHAR* pszKeypath, IN CONST DWORD& dwShortKey, IN BOOL bAppend, IN CONST INT& nRunYears, IN CONST INT& nRunMonth, IN CONST INT& nRunDays, IN CONST INT& nRunHours, IN CONST INT& nRunMinutes)
- {
- if (pszKeypath == NULL)
- {
- OutputDebugString(_T("usb路径无效!\n"));
- return FALSE;
- }
- //////////////////////////////////////////////////////////////////////////
- // 获取加密锁已运行时间GetRunTimer;
- CHAR szHasRunyears[TIMELEN] = { 0 };
- CHAR szHasRunmonths[TIMELEN] = { 0 };
- CHAR szHasRundays[TIMELEN] = { 0 };
- CHAR szHasRunhours[TIMELEN] = { 0 };
- CHAR szHasRunminutes[TIMELEN] = { 0 };
- CHAR szHasRunseconds[TIMELEN] = { 0 };
- INT nRet = GetRunTimer(szHasRunyears, szHasRunmonths, szHasRundays, szHasRunhours, szHasRunminutes, szHasRunseconds, pszKeypath);
- if (nRet != 0)
- {
- // 获取运行时间失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- //////////////////////////////////////////////////////////////////////////
- CHAR szCanRunyears[TIMELEN] = { 0 };
- CHAR szCanRunmonths[TIMELEN] = { 0 };
- CHAR szCanRundays[TIMELEN] = { 0 };
- CHAR szCanRunhours[TIMELEN] = { 0 };
- CHAR szCanRunminutes[TIMELEN] = { 0 };
- if (bAppend) // 追加时间;
- {
- // 获取加密锁可运行时间ReadTimeAuthFromEprom;
- CHAR szOutString[100] = { 0 };// 返回的时间授权码;
- CHAR HKey[50] = { 0 }, LKey[50] = { 0 };
- // 30000以后的储存空间为公共区域;
- DWORD dwShortID = dwShortKey;
- if ((nRet = ReadTimeAuthFromEprom(HKey, LKey, szOutString, &dwShortID, 30128, "FFFFFFFF", "FFFFFFFF", pszKeypath)) != 0)
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- std::string str = szOutString;
- int nStrPos = str.find("年");
- if (nStrPos != std::string::npos)
- {
- sprintf_s(szCanRunyears, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("年"));
- nStrPos = str.find("月");
- sprintf_s(szCanRunmonths, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("月"));
- nStrPos = str.find("日");
- sprintf_s(szCanRundays, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("日"));
- nStrPos = str.find("小时");
- sprintf_s(szCanRunhours, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("小时"));
- nStrPos = str.find("分钟");
- sprintf_s(szCanRunminutes, "%s", str.substr(0, nStrPos).c_str());
- }
- sprintf_s(szCanRunyears, "%d", nRunYears + atoi(szCanRunyears));
- sprintf_s(szCanRunmonths, "%d", nRunMonth + atoi(szCanRunmonths));
- sprintf_s(szCanRundays, "%d", nRunDays + atoi(szCanRundays));
- sprintf_s(szCanRunhours, "%d", nRunHours + atoi(szCanRunhours));
- sprintf_s(szCanRunminutes, "%d", nRunMinutes + atoi(szCanRunminutes));
- }
- else
- {
- sprintf_s(szCanRunyears, "%d", nRunYears);
- sprintf_s(szCanRunmonths, "%d", nRunMonth);
- sprintf_s(szCanRundays, "%d", nRunDays);
- sprintf_s(szCanRunhours, "%d", nRunHours);
- sprintf_s(szCanRunminutes, "%d", nRunMinutes);
- }
- // 生成时间授权码;
- CHAR szOutString[100] = { 0 };// 返回的时间授权码;
- if ((nRet = MakeTimerAuth(g_szUserKey, dwShortKey, szCanRunyears, szCanRunmonths, szCanRundays, szCanRunhours, szCanRunminutes, szOutString, pszKeypath)) != 0)
- {
- // 生成时间授权码失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- CHAR wHKey[9] = "FFFFFFFF", wLKey[9] = "FFFFFFFF";
- CHAR Key1[41] = "0", Key2[41] = "0";
- memcpy(Key1, szOutString, 40);
- memcpy(Key2, &szOutString[40], 40);
- // 写授权时间到加密锁中;
- if ((nRet = WriteTimeAuthToEprom(30128, wHKey, wLKey, Key1, Key2, dwShortKey, szCanRunyears, szCanRunmonths, szCanRundays, szCanRunhours, szCanRunminutes, pszKeypath)) != 0)
- {
- // 写授权时间失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- return TRUE;
- }
- BOOL ChangeVersion(IN CHAR* pszKeypath, IN CONST INT& nOldVersion, IN CONST INT& nNewVersion)
- {
- if (pszKeypath == NULL)
- {
- OutputDebugString(_T("usb路径无效!\n"));
- return FALSE;
- }
- // 清空所有版本锁的加密解密的密钥;
- INT nRet = WriteEncKey(g_szEncKey[nOldVersion][0], g_szEncKey[nOldVersion][1], g_szEncKey[nOldVersion][2], g_szEncKey[nOldVersion][3],
- g_szEncKey[nNewVersion][0], g_szEncKey[nNewVersion][1], g_szEncKey[nNewVersion][2], g_szEncKey[nNewVersion][3], pszKeypath);
- if (nRet != 0)
- {
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- // 从地址0~231+32,是所有加密锁共同内容;
- for (int i = 0; i < 8; i++)
- {
- if ((nRet = YtWriteString(g_szRom[i], i * 33, g_pHWritePassWord, g_pLWritePassWord, pszKeypath)) <= 0)
- {
- // 写区域错误;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- }
- }
- // 判断新版是否属于座席版,如果不是,清除坐席数;
- if (nNewVersion != 1 && nNewVersion != 4)
- {
- ChangeConnectCount(pszKeypath, 0);
- }
- return TRUE;
- }
- /************************************************************************/
- /*
- 函数:GetRemainderRunTime
- 描述:获取经典版加密锁剩余的可运行时间;
- 参数:
- [IN] pszKeypath 加密锁物理位置;
- [OUT] dwRemainderRunTime 返回剩余可运行时间;
- 返回:
- */
- /************************************************************************/
- BOOL GetRemainderRunTime(IN CHAR* pszKeypath, IN DWORD dwShortKey, OUT DWORD& dwHasRunTime, OUT DWORD& dwCanRunTime)
- {
- if (pszKeypath == NULL)
- {
- OutputDebugString(_T("usb路径无效!\n"));
- return FALSE;
- }
- //////////////////////////////////////////////////////////////////////////
- // 获取加密锁已运行时间GetRunTimer;
- CHAR szHasRunyears[TIMELEN] = { 0 };
- CHAR szHasRunmonths[TIMELEN] = { 0 };
- CHAR szHasRundays[TIMELEN] = { 0 };
- CHAR szHasRunhours[TIMELEN] = { 0 };
- CHAR szHasRunminutes[TIMELEN] = { 0 };
- CHAR szHasRunseconds[TIMELEN] = { 0 };
- INT nRet = GetRunTimer(szHasRunyears, szHasRunmonths, szHasRundays, szHasRunhours, szHasRunminutes, szHasRunseconds, pszKeypath);
- if (nRet != 0)
- {
- // 获取运行时间失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- //////////////////////////////////////////////////////////////////////////
- // 获取加密锁可运行时间;
- CHAR szCanRunyears[TIMELEN] = { 0 };
- CHAR szCanRunmonths[TIMELEN] = { 0 };
- CHAR szCanRundays[TIMELEN] = { 0 };
- CHAR szCanRunhours[TIMELEN] = { 0 };
- CHAR szCanRunminutes[TIMELEN] = { 0 };
- // 获取加密锁可运行时间ReadTimeAuthFromEprom;
- CHAR szOutString[100] = { 0 };// 返回的时间授权码;
- CHAR HKey[50] = { 0 }, LKey[50] = { 0 };
- // 30000以后的储存空间为公共区域;
- if ((nRet = ReadTimeAuthFromEprom(HKey, LKey, szOutString, &dwShortKey, 30128, "FFFFFFFF", "FFFFFFFF", pszKeypath)) != 0)
- {
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- std::string str = szOutString;
- int nStrPos = str.find("年");
- if (nStrPos != std::string::npos)
- {
- sprintf_s(szCanRunyears, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("年"));
- nStrPos = str.find("月");
- if (nStrPos != std::string::npos)
- {
- sprintf_s(szCanRunmonths, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("月"));
- }
- nStrPos = str.find("日");
- if (nStrPos != std::string::npos)
- {
- sprintf_s(szCanRundays, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("日"));
- }
- nStrPos = str.find("小时");
- if (nStrPos != std::string::npos)
- {
- sprintf_s(szCanRunhours, "%s", str.substr(0, nStrPos).c_str());
- str = str.substr(nStrPos + strlen("小时"));
- }
- nStrPos = str.find("分钟");
- if (nStrPos != std::string::npos)
- {
- sprintf_s(szCanRunminutes, "%s", str.substr(0, nStrPos).c_str());
- }
- }
- // 转化为整数秒;
- CHAR szSecondes[10] = "0";
- dwHasRunTime = ConvertStringToTimerReal(szHasRunyears, szHasRunmonths, szHasRundays, szHasRunhours, szHasRunminutes, szSecondes);
- dwCanRunTime = ConvertStringToTimerReal(szCanRunyears, szCanRunmonths, szCanRundays, szCanRunhours, szCanRunminutes, szSecondes);
- return TRUE;
- }
- /************************************************************************/
- /* 函数:GenerateRunTimeRegCode[4/17/2016 IT];
- /* 描述:生成加时授权码,一般先判断加密锁是否过时,如果过时进行运算,获取加时授权码;
- /* 参数:;
- /* [IN] pszKeypath:;
- /* [IN] nShortKey:;
- /* [IN] nSoftVer:;
- /* [OUT] lpRegCode:返回加时授权码;
- /* [IN] nBufLen:lpRegCode缓冲区大小;
- /* 返回:void;
- /* 注意:;
- /* 示例:;
- /*
- /* 修改:;
- /* 日期:;
- /* 内容:;
- /************************************************************************/
- BOOL GenerateRunTimeRegCode(IN CHAR* pszKeypath, IN INT nShortKey, IN CONST INT& nSoftVer, OUT LPTSTR lpRegCode, IN CONST INT& nBufLen)
- {
- if (pszKeypath == NULL)
- {
- OutputDebugString(_T("usb路径无效!\n"));
- return FALSE;
- }
- INT nHasRunTime = 0, nCanRunTime = 0;
- INT nVal[4] = { 0 };
- CHAR szVal[8][50] = { 0 };
- double flVal[8] = { 0.0 };
- INT nRet = 0, nKeyCode = 123456;
- if (GetRemainderRunTime(pszKeypath, nShortKey, (DWORD&)nHasRunTime, (DWORD&)nCanRunTime))
- {
- nRet = CalEx(g_byTimeRegCode[nSoftVer], 58, &nShortKey, &nKeyCode, &nHasRunTime, &nCanRunTime, &nVal[0], &nVal[1], &nVal[2], &nVal[3],
- &flVal[0], &flVal[1], &flVal[2], &flVal[3], &flVal[4], &flVal[5], &flVal[6], &flVal[7],
- szVal[0], szVal[1], szVal[2], szVal[3], szVal[4], szVal[5], szVal[6], szVal[7], pszKeypath, 20000);
- if (nRet != 0 && nRet != -43)
- {
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- }
- CString strTimeRegCode = _T("");
- CString temp, temp2;
- /////////////////////////////////////////
- temp.Format(_T("%d"), abs(nShortKey));
- int leng = temp.GetLength();
- if (nShortKey < 0)
- temp2 = _T("1");
- else
- temp2 = _T("0");
- temp = temp2 + temp;
- temp2.Format(_T("%02d"), leng);
- temp = temp2 + temp;
- strTimeRegCode += temp;
- //////////////////////////////////两位长度, 1为负, 0为正, 数据区
- temp.Format(_T("%d"), abs(nHasRunTime));
- leng = temp.GetLength();
- if (nHasRunTime < 0)
- temp2 = _T("1");
- else
- temp2 = _T("0");
- temp = temp2 + temp;
- temp2.Format(_T("%02d"), leng);
- temp = temp2 + temp;
- strTimeRegCode += temp;
- //////////////////////////////////两位长度, 1为负, 0为正, 数据区
- temp.Format(_T("%d"), abs(nCanRunTime));
- leng = temp.GetLength();
- if (nCanRunTime < 0)
- temp2 = _T("1");
- else
- temp2 = _T("0");
- temp = temp2 + temp;
- temp2.Format(_T("%02d"), leng);
- temp = temp2 + temp;
- strTimeRegCode += temp;
- //////////////////////////////////两位长度, 1为负, 0为正, 数据区
- temp.Format(_T("%d"), abs(nKeyCode));
- leng = temp.GetLength();
- if (nKeyCode < 0)
- temp2 = _T("1");
- else
- temp2 = _T("0");
- temp = temp2 + temp;
- temp2.Format(_T("%02d"), leng);
- temp = temp2 + temp;
- strTimeRegCode += temp;
- StringCchPrintf(lpRegCode, nBufLen, _T("%s"), strTimeRegCode.GetString());
- return TRUE;
- }
- /************************************************************************/
- /* 函数:GetRunTimeByRegCode[3/4/2016 IT];
- /* 描述:获取指定加时授权码的加密锁的运行时间;
- /* 参数:;
- /* [IN] pszKeypath:加密锁物理位置;
- /* [IN] dwShortKey:加密锁短id;
- /* [IN] nSoftVer:加密锁版本;
- /* [IN] lpRegCode:加时授权码;
- /* [OUT] :;
- /* [IN/OUT] :;
- /* 返回:成功返回TRUE;
- /* 注意:运算的加密锁必须是婚纱全能版,否则是计算不出授权码里的内容;
- /* 示例:;
- /*
- /* 修改:;
- /* 日期:;
- /* 内容:;
- /************************************************************************/
- BOOL GetRunTimeByRegCode(IN CHAR* pszKeypath, IN DWORD dwShortKey, IN CONST INT& nSoftVer, IN LPCTSTR lpRegCode, IN CString& strResult)
- {
- if (pszKeypath == NULL)
- {
- OutputDebugString(_T("usb路径无效!\n"));
- return FALSE;
- }
- if (nSoftVer != EN_OWDDING)
- return FALSE;
- CString requestcode = lpRegCode;
- requestcode.TrimLeft();
- requestcode.TrimRight();
- requestcode.Replace(_T("\n"), _T(""));
- requestcode.Replace(_T("\r"), _T(""));
- if (requestcode.IsEmpty())
- {
- return FALSE;
- }
- CString str, temp, temp2;
- INT id, time1, time2, idtemp;
- int leng;
- str = requestcode;
- temp = str.Left(3);
- str = str.Right(str.GetLength() - 3);
- leng = _tstoi(temp.Left(2).GetString());
- temp2 = str.Left(leng);
- str = str.Right(str.GetLength() - leng);
- id = _tstoi(temp2);
- if (temp.Right(1) == _T("1"))id = -id;
- //////////////////////////////////////////////////
- temp = str.Left(3);
- str = str.Right(str.GetLength() - 3);
- leng = _tstoi(temp.Left(2));
- temp2 = str.Left(leng);
- str = str.Right(str.GetLength() - leng);
- time1 = _tstoi(temp2);
- if (temp.Right(1) == _T("1"))time1 = -time1;
- //////////////////////////////////////////////////
- temp = str.Left(3);
- str = str.Right(str.GetLength() - 3);
- leng = _tstoi(temp.Left(2));
- temp2 = str.Left(leng);
- str = str.Right(str.GetLength() - leng);
- time2 = _tstoi(temp2);
- if (temp.Right(1) == _T("1"))time2 = -time2;
- //////////////////////////////////////////////////////
- temp = str.Left(3);
- str = str.Right(str.GetLength() - 3);
- leng = _tstoi(temp.Left(2));
- temp2 = str.Left(leng);
- str = str.Right(str.GetLength() - leng);
- idtemp = _tstoi(temp2);
- if (temp.Right(1) == _T("1"))idtemp = -idtemp;
- //////////////////////////////////////////////////////
- INT d[8]; double f[8];
- char s0[50] = "", s1[50] = "", s2[50] = "", s3[50] = "", s4[50] = "", s5[50] = "", s6[50] = "", s7[50] = "";
- // 运行自定义函数;
- INT nRet = CalEx(g_byDecryptRegCode, 58, &id, &idtemp, &time1, &time2, &d[4], &d[5], &d[6], &d[7],
- &f[0], &f[1], &f[2], &f[3], &f[4], &f[5], &f[6], &f[7], s0, s1, s2, s3, s4, s5, s6, s7, pszKeypath, 2000);
- if (nRet != 0 && nRet != -43)
- {
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- CHAR year[10], month[10], day[10], hour[10], minute[10], second[10];
- ConvertTimerToStringReal(time2, year, month, day, hour, minute, second);
- temp.Format(_T("%d 已运行:%02d年%02d月%02d日%02d时%02d分%02d秒 "), id, atoi(year), atoi(month), atoi(day), atoi(hour), atoi(minute), atoi(second));
- strResult += temp;
- if (time1 > 0)
- ConvertTimerToStringReal(time1, year, month, day, hour, minute, second);
- else
- {
- StringCchPrintfA(year, 10, "%s", "0");
- StringCchPrintfA(month, 10, "%s", "0");
- StringCchPrintfA(day, 10, "%s", "0");
- StringCchPrintfA(hour, 10, "%s", "0");
- StringCchPrintfA(minute, 10, "%s", "0");
- }
- temp.Format(_T("能运行:%02d年%02d月%02d日%02d时%02d分%02d秒---%d"), atoi(year), atoi(month), atoi(day), atoi(hour), atoi(minute), atoi(second), time2);
- strResult += temp;
- return FALSE;
- }
- /************************************************************************/
- /* 函数:InitEncryptlock[3/4/2016 IT];
- /* 描述:初始化加密锁,完全清空;
- /* 参数:;
- /* [IN] nStartUSBPort:加密狗起始USB搜索位置;
- /* 返回:清除成功返回TRUE;
- /* 注意:;
- /* 示例:;
- /*
- /* 修改:;
- /* 日期:;
- /* 内容:;
- /************************************************************************/
- BOOL InitEncryptlock(IN const int &nStartUSBPort)
- {
- int nRet = 0;
- int nVersion = -1; // 锁版本;
- DWORD dwShortKey = 0; // 锁短ID;
- CHAR szKeyPath[MAX_PATH] = { 0 }; // USB锁物理位置;
- // 从nStartUSBPort的USB的位置开始查找加密锁;
- if ((nRet = FindPort(nStartUSBPort, szKeyPath)) != 0)
- {
- // 返回非0表示失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- // 返回锁的短ID及版本号;
- if ((nRet = GetIDVersion(&dwShortKey, &nVersion, szKeyPath)) != 0)
- {
- // 返回非0表示失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- if (dwShortKey == -1)
- {
- // 不是域天智能锁;
- return FALSE;
- }
- if ((nRet = ReSet(szKeyPath)) != 0)
- {
- // 返回非0表示失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- return TRUE;
- }
- /************************************************************************/
- /* 函数:ClearEncryptlockInfo[3/4/2016 IT];
- /* 描述:清空加密所有加密信息;
- /* 参数:;
- /* [IN] nStartUSBPort:加密狗起始USB搜索位置;
- /* 返回:清除成功返回TRUE;
- /* 注意:;
- /* 示例:;
- /*
- /* 修改:;
- /* 日期:;
- /* 内容:;
- /************************************************************************/
- BOOL ClearEncryptlockInfo(IN const int &nStartUSBPort)
- {
- int nRet = 0;
- int nVersion = -1; // 锁版本;
- DWORD dwShortKey = 0; // 锁短ID;
- CHAR szKeyPath[MAX_PATH] = { 0 }; // USB锁物理位置;
- // 从nStartUSBPort的USB的位置开始查找加密锁;
- if ((nRet = FindPort(nStartUSBPort, szKeyPath)) != 0)
- {
- // 返回非0表示失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- // 返回锁的短ID及版本号;
- if ((nRet = GetIDVersion(&dwShortKey, &nVersion, szKeyPath)) != 0)
- {
- // 返回非0表示失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- if (dwShortKey == -1)
- {
- // 不是域天智能锁;
- return FALSE;
- }
- // 清空所有版本锁的rom空间地内容;
- CHAR szRom[ENCRYPT_BLOCK_LEN] = { 0 }; // 包含结束符;
- for (int i = 0; i < 11; i++)
- {
- nRet = YtWriteString(szRom, i * 33, g_pHWritePassWord, g_pLWritePassWord, szKeyPath);
- if (nRet <= 0)
- {
- // 执行失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- GetYtUSBKey32ErrInfo(nRet);
- }
- }
- // 清除写密码;
- nRet = SetWritePassword(g_pHWritePassWord, g_pLWritePassWord, "FFFFFFFF", "FFFFFFFF", szKeyPath);
- if (nRet != 0)
- {
- // 执行失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- //return FALSE;
- }
- // 清除读密码;//设置读密码,必须用写密码;
- if ((nRet = SetReadPassword("FFFFFFFF", "FFFFFFFF", "FFFFFFFF", "FFFFFFFF", szKeyPath)) != 0)
- {
- // 执行失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- //return FALSE;
- }
- // 清空所有版本锁的加密解密的密钥;
- BOOL bErased = FALSE;
- for (int i = 0; i < 6; i++)
- {
- if (0 == (nRet = WriteEncKey(g_szEncKey[i][0], g_szEncKey[i][1], g_szEncKey[i][2], g_szEncKey[i][3], "FFFFFFFF", "FFFFFFFF", "FFFFFFFF", "FFFFFFFF", szKeyPath)))
- {
- bErased = TRUE;
- break;
- }
- else
- {
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- }
- }
- if (!bErased)
- {
- AfxMessageBox(_T("清除加密锁失败,该锁可能已经清除过~"));
- }
- return TRUE;
- }
- BOOL FindYtUSB(OUT DWORD &dwShortKey, OUT INT &nVersion, OUT CHAR *pszKeyPath, IN CONST INT &nStartPort)
- {
- INT nResult = 0;
- // 从nStartPort的USB的位置开始查找加密锁;
- if ((nResult = FindPort(nStartPort, pszKeyPath)) != 0)
- {
- AfxMessageBox(GetYtUSBKey32ErrInfo(nResult));
- return FALSE;
- }
- // 返回锁的短ID及版本号;
- if ((nResult = GetIDVersion(&dwShortKey, &nVersion, pszKeyPath)) != 0)
- {
- AfxMessageBox(GetYtUSBKey32ErrInfo(nResult));
- return FALSE;
- }
- return TRUE;
- }
- /************************************************************************/
- /* 函数:CreateEncryptlockInfo[3/4/2016 IT];
- /* 描述:生成指定版本的加密锁;
- /* 参数:;
- /* [IN] nStartPort:起始USB搜索位置;
- /* [IN] nSoftVer:指定生成的加密狗版本信息;
- /* [IN] nCCount:座席版连接数量;
- /* [IN] bHospital:是否注册医院跟踪系统功能;
- /* [IN] bAdddate:授权时间是否追加生成;
- /* [IN] szRunyears:;
- /* [IN] szRunmonths:;
- /* [IN] szRundays:;
- /* [IN] szRunhours:;
- /* [IN] szRunminutes:;
- /* [OUT] lpHasRundate:返回锁已运行时间;
- /* [OUT] lpCouldRundate:返回锁授权时间;
- /* 返回:成功返回TRUE;
- /* 注意:;
- /* 示例:;
- /*
- /* 修改:;
- /* 日期:;
- /* 内容:;
- /************************************************************************/
- BOOL CreateEncryptlockInfo(IN CONST INT &nStartPort, IN EncryptlockInfo &linfo, OUT LPTSTR lpHasRundate, IN CONST size_t &sizeOfhasrundate, OUT LPTSTR lpCouldRundate, IN CONST size_t &sizeOfcouldrundate, IN BOOL bfixedId /*= FALSE*/, IN CHAR* pszBranchId /* = NULL*/)
- {
- int nRet = -1;
- DWORD dwShortKey = 0;
- int nVersion = -1;
- CHAR szKeyPath[MAX_PATH] = { 0 };
- if (!FindYtUSB(dwShortKey, nVersion, szKeyPath, nStartPort))
- return FALSE;
- if (dwShortKey == -1)
- {
- // 不是域天智能锁;
- return FALSE;
- }
- nRet = SetReadPassword("FFFFFFFF", "FFFFFFFF", g_pHReadPassWord, g_pLReadPassWord, szKeyPath);
- if (nRet != 0) {
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- }
- nRet = SetWritePassword("FFFFFFFF", "FFFFFFFF", g_pHWritePassWord, g_pLWritePassWord, szKeyPath);
- if (nRet != 0) {
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- }
- // 从地址0~231+32,是所有加密锁共同内容;
- for (int i = 0; i < 8; i++)
- {
- if ((nRet = YtWriteString(g_szRom[i], i * 33, g_pHWritePassWord, g_pLWritePassWord, szKeyPath)) <= 0)
- {
- // 写区域错误;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- }
- }
- // 264是座席数量;
- if (linfo.nCCount > 0)
- {
- CHAR szCCount[ENCRYPT_BLOCK_LEN] = { 0 }; // 包含结束符;
- sprintf_s(szCCount, "%d", linfo.nCCount);
- if ((nRet = YtWriteString(szCCount, 264, g_pHWritePassWord, g_pLWritePassWord, szKeyPath)) <= 0)
- {
- // 设置座席数失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- }
- // 297是域名值;
- // 生成域名串 = 日期 + 短ID;
- CHAR szDomain[ENCRYPT_BLOCK_LEN] = { 0 }; // 包含结束符;
- if (bfixedId && pszBranchId && pszBranchId[0] != '\0')
- {
- //sprintf_s(szDomain, "20151208000000%d.ly.com", dwShortKey);
- sprintf_s(szDomain, pszBranchId);
- }
- else
- {
- CTime tt = CTime::GetCurrentTime();
- sprintf_s(szDomain, "%04d%02d%02d%02d%02d%02d%d.ly.com", tt.GetYear(), tt.GetMonth(), tt.GetDay(), tt.GetHour(), tt.GetMinute(), tt.GetSecond(), dwShortKey);
- }
- if ((nRet = YtWriteString(szDomain, 297, g_pHWritePassWord, g_pLWritePassWord, szKeyPath)) <= 0)
- {
- // 生成域名错误;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- // 330是医院跟踪系统;
- if (linfo.bHospital)
- {
- CHAR szHospital[ENCRYPT_BLOCK_LEN] = { 0 }; // 包含结束符;
- sprintf_s(szHospital, "%d", linfo.bHospital);
- if ((nRet = YtWriteString(szHospital, 330, g_pHWritePassWord, g_pLWritePassWord, szKeyPath)) <= 0)
- {
- // 设置医院跟踪系统失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- }
- // 生成指定软件版本加密解密密钥;
- switch (linfo.nSoftVer)
- {
- case EN_OCHILD:
- nRet = WriteEncKey("FFFFFFFF", "FFFFFFFF", "FFFFFFFF", "FFFFFFFF", g_szEncKey[EN_OCHILD][0], g_szEncKey[EN_OCHILD][1], g_szEncKey[EN_OCHILD][2], g_szEncKey[EN_OCHILD][3], szKeyPath);
- break;
- case EN_LCHILD:
- nRet = WriteEncKey("FFFFFFFF", "FFFFFFFF", "FFFFFFFF", "FFFFFFFF", g_szEncKey[EN_LCHILD][0], g_szEncKey[EN_LCHILD][1], g_szEncKey[EN_LCHILD][2], g_szEncKey[EN_LCHILD][3], szKeyPath);
- break;
- case EN_ECHILD:
- nRet = WriteEncKey("FFFFFFFF", "FFFFFFFF", "FFFFFFFF", "FFFFFFFF", g_szEncKey[EN_ECHILD][0], g_szEncKey[EN_ECHILD][1], g_szEncKey[EN_ECHILD][2], g_szEncKey[EN_ECHILD][3], szKeyPath);
- break;
- case EN_OWDDING:
- nRet = WriteEncKey("FFFFFFFF", "FFFFFFFF", "FFFFFFFF", "FFFFFFFF", g_szEncKey[EN_OWDDING][0], g_szEncKey[EN_OWDDING][1], g_szEncKey[EN_OWDDING][2], g_szEncKey[EN_OWDDING][3], szKeyPath);
- break;
- case EN_LWDDING:
- nRet = WriteEncKey("FFFFFFFF", "FFFFFFFF", "FFFFFFFF", "FFFFFFFF", g_szEncKey[EN_LWDDING][0], g_szEncKey[EN_LWDDING][1], g_szEncKey[EN_LWDDING][2], g_szEncKey[EN_LWDDING][3], szKeyPath);
- break;
- case EN_EWDDING:
- nRet = WriteEncKey("FFFFFFFF", "FFFFFFFF", "FFFFFFFF", "FFFFFFFF", g_szEncKey[EN_EWDDING][0], g_szEncKey[EN_EWDDING][1], g_szEncKey[EN_EWDDING][2], g_szEncKey[EN_EWDDING][3], szKeyPath);
- break;
- }
- if (nRet != 0)
- {
- // 生成密钥失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- //////////////////////////////////////////////////////////////////////////
- // 授权时间码;
- CHAR szyear[10] = { 0 }, szmonth[10] = { 0 }, szday[10] = { 0 }, szhour[10] = { 0 }, szminute[10] = { 0 }, szsecond[10] = { 0 };
- if ((nRet = GetRunTimer(szyear, szmonth, szday, szhour, szminute, szsecond, szKeyPath)) != 0)
- {
- // 获取运行时间失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- _stprintf_s(lpHasRundate, sizeOfhasrundate, _T("已运行 %s年%s月%s天%s时%s分"), szyear, szmonth, szday, szhour, szminute);
- if (linfo.bAdddate) // 追加时间;
- {
- sprintf_s(szyear, "%d", atoi(linfo.szRunyears) + atoi(szyear));
- sprintf_s(szmonth, "%d", atoi(linfo.szRunmonths) + atoi(szmonth));
- sprintf_s(szday, "%d", atoi(linfo.szRundays) + atoi(szday));
- sprintf_s(szhour, "%d", atoi(linfo.szRunhours) + atoi(szday));
- sprintf_s(szminute, "%d", atoi(linfo.szRunminutes) + atoi(szminute));
- }
- else
- {
- sprintf_s(szyear, "%s", linfo.szRunyears);
- sprintf_s(szmonth, "%s", linfo.szRunmonths);
- sprintf_s(szday, "%s", linfo.szRundays);
- sprintf_s(szhour, "%s", linfo.szRunhours);
- sprintf_s(szminute, "%s", linfo.szRunminutes);
- }
- // 生成时间授权码;
- CHAR szOutString[100] = { 0 }; // 返回的时间授权码;
- if ((nRet = MakeTimerAuth(g_szUserKey, dwShortKey, szyear, szmonth, szday, szhour, szminute, szOutString, szKeyPath)) != 0)
- {
- // 生成时间授权码失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- CHAR HKey[9] = "FFFFFFFF", LKey[9] = "FFFFFFFF";
- CHAR WHKey[41] = "0", WLKey[41] = "0";
- memcpy(WHKey, szOutString, 40);
- memcpy(WLKey, &szOutString[40], 40);
- // 写授权时间到加密锁中;
- if ((nRet = WriteTimeAuthToEprom(30128, HKey, LKey, WHKey, WLKey, dwShortKey, szyear, szmonth, szday, szhour, szminute, szKeyPath)) != 0)
- {
- // 写授权时间失败;
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- return FALSE;
- }
- DWORD dwID;
- // 30000以后的储存空间为公共区域;
- if ((nRet = ReadTimeAuthFromEprom(WHKey, WLKey, szOutString, &dwID, 30128, "FFFFFFFF", "FFFFFFFF", szKeyPath)) == 0)
- {
- #ifdef UNICODE
- WCHAR *pOutString = ascii2unicode(szOutString);
- _stprintf_s(lpCouldRundate, sizeOfcouldrundate, _T("%s"), pOutString);
- delete pOutString;
- pOutString = NULL;
- #else
- _stprintf_s(lpCouldRundate, sizeOfcouldrundate, _T("%s"), szOutString);
- #endif
- }
- else
- {
- AfxMessageBox(GetYtUSBKey32ErrInfo(nRet));
- }
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////
- // 应用接口;
- BOOL GetFirstYtUSBSoftVer(IN INT &nSoftVer, IN CHAR *pBranchIdBuffer, IN size_t sizeOfBranchIdBuffer, IN CONST INT &nUSBStartPos /* = 0 */)
- {
- INT nRetval = 0;
- INT nVal[8] = { 0 };
- DOUBLE fVal[8] = { 0.0 };
- CHAR s0[50] = "", s1[50] = "", s2[50] = "", s3[50] = "", s4[50] = "", s5[50] = "", s6[50] = "", s7[50] = "";
- BOOL bFind = FALSE;
- CHAR szKeyPath[MAX_PATH] = "";
- for (INT nIndex = nUSBStartPos; nIndex < 256; nIndex++)
- {
- memset(szKeyPath, 0, sizeof(szKeyPath));
- nRetval = FindPort(nIndex, szKeyPath);
- if (nRetval != 0 && nIndex == 0) continue;
- if (nRetval != 0) continue;
- for (int i = 0; i < 6; i++)
- {
- // 使用该设备路径锁进行运算;
- nRetval = CalEx(g_byShotVersion[i], 10,
- &nVal[0], &nVal[1], &nVal[2], &nVal[3], &nVal[4], &nVal[5], &nVal[6], &nVal[7],
- &fVal[0], &fVal[1], &fVal[2], &fVal[3], &fVal[4], &fVal[5], &fVal[6], &fVal[7],
- s0, s1, s2, s3, s4, s5, s6, s7, szKeyPath, 20000);
- //如果正确,则返回该设备路径供以后使用;
- if (nRetval == -63) continue;
- if ((nRetval == 0) && (nVal[0] == 123))
- {
- bFind = TRUE;
- nSoftVer = i;
- sprintf_s(pBranchIdBuffer, sizeOfBranchIdBuffer, "%s", s0);
- break;
- }
- }
- if (bFind) break;
- }
- return bFind;
- }
- CONST TCHAR* GetYtUSBKey32ErrInfo(IN const long lError)
- {
- INT nIndex = -1;
- TCHAR *pErrorDescription = NULL;
- while (g_YtError[++nIndex].nErrorCode != -10000)
- {
- if (lError == g_YtError[nIndex].nErrorCode)
- {
- pErrorDescription = g_YtError[nIndex].pErrorDescription;
- break;
- }
- }
- if (pErrorDescription == NULL)
- pErrorDescription = _T("未知错误!\n");
- OutputDebugString(pErrorDescription);
- return pErrorDescription;
- }
- };
|