我不小心发了不完整的问题,找不到编辑方法。
我想问一下,在file60.dll中搜索.cnf文件的策略是什么 - 是硬编码的路径,还是它们相对于dll文件,还是可以以某种方式设置它们的路径?
我附上以下尝试的完整源代码:
#include'stdafx.h'
#include< windows.h>
#include< conio.h>
#ifndef MAX_PATH
#define MAX_PATH 260
#endif // MAX_PATH
使用命名空间std;
#define WARN(msg,...)fprintf(stderr,msg' n',## __ VA_ARGS__)
#define WWARN(wmsg,...)fwprintf(stderr,wmsg L' n',## __ VA_ARGS__)
typedef int(* EAllAccess_t)(DWORD dwAreaId);
typedef int(* EAreaAccess_t)(DWORD dwAreaId,long FirstAddr,long LastAddr);
int(* ESelectDevice)(const char * szDevice);
int(* ESelectHard)(const char * szCard,const char * szProtocol,BOOL bDemo);
int(* ESelectPort)(const char * szPort);
int(* ESetPreferences)(int iPreference,BOOL bState);
int(* ESetProtection)(const char * szProtectMode,BOOL bState);
int(* ECheckSum)(DWORD dwAreaId,long * FileCheckSum,long * MemoryCheckSum);
int(* EGetId)(const char * szName,DWORD * pdwId);
char *(* EGetImagePtr)(DWORD dwAreaId,long * MemSize);
INT(* ECloseComm)();
char *(* CGetLastError)()= NULL;
char * LastErrorMessage()
{
if(CGetLastError)
{
return CGetLastError();
}
返回'未知错误';
}
#define TRY(action)if(!(action)){WARN(#action'failed:%s',LastErrorMessage());返回; }
EAllAccess_t EBlankAll;
EAreaAccess_t EBlankArea;
EAllAccess_t EEraseAll;
EAreaAccess_t EEraseArea;
EAllAccess_t EProgAll;
EAreaAccess_t EProgArea;
// EAllAccess_t EReadAll;
EAreaAccess_t EReadArea;
EAllAccess_t EVerifyAll;
EAreaAccess_t EVerifyArea;
void LoadLibraries()
{
HINSTANCE eprcore,dbca,lef,file;
TRY(eprcore = LoadLibrary(L'eprcore60.dll'));
TRY(dbca = LoadLibrary(L'dbca60.dll'));
TRY(lef = LoadLibrary(L'lef60.dll'));
TRY(file = LoadLibrary(L'file60.dll'));
TRY(CGetLastError =(char *(*)())GetProcAddress(dbca,'CGetLastError'));
TRY(ESelectPort =(int(*)(const char *))GetProcAddress(eprcore,'ESelectPort'));
// TRY(EReadAll =(EAllAccess_t)GetProcAddress(eprcore,'EReadAll'));
TRY(ESelectHard =(int(*)(const char *,const char *,BOOL))GetProcAddress(eprcore,'ESelectHard'));
TRY(EReadArea =(EAreaAccess_t)GetProcAddress(eprcore,'EReadArea'));
TRY(EVerifyAll =(EAllAccess_t)GetProcAddress(eprcore,'EVerifyAll'));
TRY(EVerifyArea =(EAreaAccess_t)GetProcAddress(eprcore,'EVerifyArea'));
TRY(EProgAll =(EAllAccess_t)GetProcAddress(eprcore,'EProgAll'));
TRY(EProgArea =(EAreaAccess_t)GetProcAddress(eprcore,'EProgArea'));
TRY(EEraseAll =(EAllAccess_t)GetProcAddress(eprcore,'EEraseAll'));
TRY(EEraseArea =(EAreaAccess_t)GetProcAddress(eprcore,'EEraseArea'));
TRY(EBlankAll =(EAllAccess_t)GetProcAddress(eprcore,'EBlankAll'));
TRY(EBlankArea =(EAreaAccess_t)GetProcAddress(eprcore,'EBlankArea'));
}
void ReadMemory()
{
DWORD PROGRAM_MEMORY,DATA_MEMORY;
尝试(ESelectHard('ST-LINK','游泳',假));
TRY(ESelectDevice( 'STM8L15xC6'));
TRY(ESelectPort( 'USB'));
TRY(EGetId('PROGRAM MEMORY',& PROGRAM_MEMORY));
TRY(EGetId('DATA MEMORY',& DATA_MEMORY));
WARN('程序存储器=%d,数据存储器=%d',PROGRAM_MEMORY,DATA_MEMORY);
}
int main()
{
TCHAR pwd [MAX_PATH];
_wgetcwd(pwd,MAX_PATH);
WWARN(当前工作目录:%s n',pwd);
SetDllDirectory会(L'C:\ st_toolset \ STVP');
LoadLibraries();
ReadMemory();
的getchar();
返回0;
}
以上来自于谷歌翻译
以下为原文
I accidentally sent the incomplete question and can't find a way to edit it.
I wanted to ask, what is the policy of searching for the .cnf files in the file60.dll -- are the paths hard coded, or are they relative to the dll files, or can their path be set somehow?
I enclose the complete source code of my attempts below:
#include 'stdafx.h'
#include
#include
#ifndef MAX_PATH
#define MAX_PATH 260
#endif // MAX_PATH
using namespace std;
#define WARN(msg, ...) fprintf(stderr, msg 'n', ## __VA_ARGS__)
#define WWARN(wmsg, ...) fwprintf(stderr, wmsg L'n', ## __VA_ARGS__)
typedef int(*EAllAccess_t)(DWORD dwAreaId);
typedef int(*EAreaAccess_t)(DWORD dwAreaId, long FirstAddr, long LastAddr);
int(*ESelectDevice)(const char *szDevice);
int (*ESelectHard)(const char *szCard, const char *szProtocol, BOOL bDemo);
int(*ESelectPort)(const char *szPort);
int(*ESetPreferences)(int iPreference, BOOL bState);
int(*ESetProtection)(const char *szProtectMode, BOOL bState);
int(*ECheckSum)(DWORD dwAreaId, long *FileCheckSum, long *MemoryCheckSum);
int (*EGetId)(const char *szName, DWORD *pdwId);
char *(*EGetImagePtr)(DWORD dwAreaId, long *MemSize);
int(*ECloseComm)();
char *(*CGetLastError)() = NULL;
char *LastErrorMessage()
{
if (CGetLastError)
{
return CGetLastError();
}
return 'unknown error';
}
#define TRY(action) if(!(action)) { WARN(# action ' failed: %s', LastErrorMessage()); return; }
EAllAccess_t EBlankAll;
EAreaAccess_t EBlankArea;
EAllAccess_t EEraseAll;
EAreaAccess_t EEraseArea;
EAllAccess_t EProgAll;
EAreaAccess_t EProgArea;
//EAllAccess_t EReadAll;
EAreaAccess_t EReadArea;
EAllAccess_t EVerifyAll;
EAreaAccess_t EVerifyArea;
void LoadLibraries()
{
HINSTANCE eprcore, dbca, lef, file;
TRY(eprcore = LoadLibrary(L'eprcore60.dll'));
TRY(dbca = LoadLibrary(L'dbca60.dll'));
TRY(lef = LoadLibrary(L'lef60.dll'));
TRY(file = LoadLibrary(L'file60.dll'));
TRY(CGetLastError = (char *(*)()) GetProcAddress(dbca, 'CGetLastError'));
TRY(ESelectPort = (int(*)(const char *))GetProcAddress(eprcore, 'ESelectPort'));
//TRY(EReadAll = (EAllAccess_t)GetProcAddress(eprcore, 'EReadAll'));
TRY(ESelectHard = (int(*)(const char *, const char *, BOOL)) GetProcAddress(eprcore, 'ESelectHard'));
TRY(EReadArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EReadArea'));
TRY(EVerifyAll = (EAllAccess_t)GetProcAddress(eprcore, 'EVerifyAll'));
TRY(EVerifyArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EVerifyArea'));
TRY(EProgAll = (EAllAccess_t)GetProcAddress(eprcore, 'EProgAll'));
TRY(EProgArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EProgArea'));
TRY(EEraseAll = (EAllAccess_t)GetProcAddress(eprcore, 'EEraseAll'));
TRY(EEraseArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EEraseArea'));
TRY(EBlankAll = (EAllAccess_t)GetProcAddress(eprcore, 'EBlankAll'));
TRY(EBlankArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EBlankArea'));
}
void ReadMemory()
{
DWORD PROGRAM_MEMORY, DATA_MEMORY;
TRY(ESelectHard('ST-LINK', 'SWIM', FALSE));
TRY(ESelectDevice('STM8L15xC6'));
TRY(ESelectPort('USB'));
TRY(EGetId('PROGRAM MEMORY', &PROGRAM_MEMORY));
TRY(EGetId('DATA MEMORY', &DATA_MEMORY));
WARN('PROGRAM MEMORY = %d, DATA MEMORY = %d', PROGRAM_MEMORY, DATA_MEMORY);
}
int main()
{
TCHAR pwd[MAX_PATH];
_wgetcwd(pwd, MAX_PATH);
WWARN(L'Current Working Directory: %sn', pwd);
SetDllDirectory(L'C:\st_toolset\stvp');
LoadLibraries();
ReadMemory();
getchar();
return 0;
}
我不小心发了不完整的问题,找不到编辑方法。
我想问一下,在file60.dll中搜索.cnf文件的策略是什么 - 是硬编码的路径,还是它们相对于dll文件,还是可以以某种方式设置它们的路径?
我附上以下尝试的完整源代码:
#include'stdafx.h'
#include< windows.h>
#include< conio.h>
#ifndef MAX_PATH
#define MAX_PATH 260
#endif // MAX_PATH
使用命名空间std;
#define WARN(msg,...)fprintf(stderr,msg' n',## __ VA_ARGS__)
#define WWARN(wmsg,...)fwprintf(stderr,wmsg L' n',## __ VA_ARGS__)
typedef int(* EAllAccess_t)(DWORD dwAreaId);
typedef int(* EAreaAccess_t)(DWORD dwAreaId,long FirstAddr,long LastAddr);
int(* ESelectDevice)(const char * szDevice);
int(* ESelectHard)(const char * szCard,const char * szProtocol,BOOL bDemo);
int(* ESelectPort)(const char * szPort);
int(* ESetPreferences)(int iPreference,BOOL bState);
int(* ESetProtection)(const char * szProtectMode,BOOL bState);
int(* ECheckSum)(DWORD dwAreaId,long * FileCheckSum,long * MemoryCheckSum);
int(* EGetId)(const char * szName,DWORD * pdwId);
char *(* EGetImagePtr)(DWORD dwAreaId,long * MemSize);
INT(* ECloseComm)();
char *(* CGetLastError)()= NULL;
char * LastErrorMessage()
{
if(CGetLastError)
{
return CGetLastError();
}
返回'未知错误';
}
#define TRY(action)if(!(action)){WARN(#action'failed:%s',LastErrorMessage());返回; }
EAllAccess_t EBlankAll;
EAreaAccess_t EBlankArea;
EAllAccess_t EEraseAll;
EAreaAccess_t EEraseArea;
EAllAccess_t EProgAll;
EAreaAccess_t EProgArea;
// EAllAccess_t EReadAll;
EAreaAccess_t EReadArea;
EAllAccess_t EVerifyAll;
EAreaAccess_t EVerifyArea;
void LoadLibraries()
{
HINSTANCE eprcore,dbca,lef,file;
TRY(eprcore = LoadLibrary(L'eprcore60.dll'));
TRY(dbca = LoadLibrary(L'dbca60.dll'));
TRY(lef = LoadLibrary(L'lef60.dll'));
TRY(file = LoadLibrary(L'file60.dll'));
TRY(CGetLastError =(char *(*)())GetProcAddress(dbca,'CGetLastError'));
TRY(ESelectPort =(int(*)(const char *))GetProcAddress(eprcore,'ESelectPort'));
// TRY(EReadAll =(EAllAccess_t)GetProcAddress(eprcore,'EReadAll'));
TRY(ESelectHard =(int(*)(const char *,const char *,BOOL))GetProcAddress(eprcore,'ESelectHard'));
TRY(EReadArea =(EAreaAccess_t)GetProcAddress(eprcore,'EReadArea'));
TRY(EVerifyAll =(EAllAccess_t)GetProcAddress(eprcore,'EVerifyAll'));
TRY(EVerifyArea =(EAreaAccess_t)GetProcAddress(eprcore,'EVerifyArea'));
TRY(EProgAll =(EAllAccess_t)GetProcAddress(eprcore,'EProgAll'));
TRY(EProgArea =(EAreaAccess_t)GetProcAddress(eprcore,'EProgArea'));
TRY(EEraseAll =(EAllAccess_t)GetProcAddress(eprcore,'EEraseAll'));
TRY(EEraseArea =(EAreaAccess_t)GetProcAddress(eprcore,'EEraseArea'));
TRY(EBlankAll =(EAllAccess_t)GetProcAddress(eprcore,'EBlankAll'));
TRY(EBlankArea =(EAreaAccess_t)GetProcAddress(eprcore,'EBlankArea'));
}
void ReadMemory()
{
DWORD PROGRAM_MEMORY,DATA_MEMORY;
尝试(ESelectHard('ST-LINK','游泳',假));
TRY(ESelectDevice( 'STM8L15xC6'));
TRY(ESelectPort( 'USB'));
TRY(EGetId('PROGRAM MEMORY',& PROGRAM_MEMORY));
TRY(EGetId('DATA MEMORY',& DATA_MEMORY));
WARN('程序存储器=%d,数据存储器=%d',PROGRAM_MEMORY,DATA_MEMORY);
}
int main()
{
TCHAR pwd [MAX_PATH];
_wgetcwd(pwd,MAX_PATH);
WWARN(当前工作目录:%s n',pwd);
SetDllDirectory会(L'C:\ st_toolset \ STVP');
LoadLibraries();
ReadMemory();
的getchar();
返回0;
}
以上来自于谷歌翻译
以下为原文
I accidentally sent the incomplete question and can't find a way to edit it.
I wanted to ask, what is the policy of searching for the .cnf files in the file60.dll -- are the paths hard coded, or are they relative to the dll files, or can their path be set somehow?
I enclose the complete source code of my attempts below:
#include 'stdafx.h'
#include
#include
#ifndef MAX_PATH
#define MAX_PATH 260
#endif // MAX_PATH
using namespace std;
#define WARN(msg, ...) fprintf(stderr, msg 'n', ## __VA_ARGS__)
#define WWARN(wmsg, ...) fwprintf(stderr, wmsg L'n', ## __VA_ARGS__)
typedef int(*EAllAccess_t)(DWORD dwAreaId);
typedef int(*EAreaAccess_t)(DWORD dwAreaId, long FirstAddr, long LastAddr);
int(*ESelectDevice)(const char *szDevice);
int (*ESelectHard)(const char *szCard, const char *szProtocol, BOOL bDemo);
int(*ESelectPort)(const char *szPort);
int(*ESetPreferences)(int iPreference, BOOL bState);
int(*ESetProtection)(const char *szProtectMode, BOOL bState);
int(*ECheckSum)(DWORD dwAreaId, long *FileCheckSum, long *MemoryCheckSum);
int (*EGetId)(const char *szName, DWORD *pdwId);
char *(*EGetImagePtr)(DWORD dwAreaId, long *MemSize);
int(*ECloseComm)();
char *(*CGetLastError)() = NULL;
char *LastErrorMessage()
{
if (CGetLastError)
{
return CGetLastError();
}
return 'unknown error';
}
#define TRY(action) if(!(action)) { WARN(# action ' failed: %s', LastErrorMessage()); return; }
EAllAccess_t EBlankAll;
EAreaAccess_t EBlankArea;
EAllAccess_t EEraseAll;
EAreaAccess_t EEraseArea;
EAllAccess_t EProgAll;
EAreaAccess_t EProgArea;
//EAllAccess_t EReadAll;
EAreaAccess_t EReadArea;
EAllAccess_t EVerifyAll;
EAreaAccess_t EVerifyArea;
void LoadLibraries()
{
HINSTANCE eprcore, dbca, lef, file;
TRY(eprcore = LoadLibrary(L'eprcore60.dll'));
TRY(dbca = LoadLibrary(L'dbca60.dll'));
TRY(lef = LoadLibrary(L'lef60.dll'));
TRY(file = LoadLibrary(L'file60.dll'));
TRY(CGetLastError = (char *(*)()) GetProcAddress(dbca, 'CGetLastError'));
TRY(ESelectPort = (int(*)(const char *))GetProcAddress(eprcore, 'ESelectPort'));
//TRY(EReadAll = (EAllAccess_t)GetProcAddress(eprcore, 'EReadAll'));
TRY(ESelectHard = (int(*)(const char *, const char *, BOOL)) GetProcAddress(eprcore, 'ESelectHard'));
TRY(EReadArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EReadArea'));
TRY(EVerifyAll = (EAllAccess_t)GetProcAddress(eprcore, 'EVerifyAll'));
TRY(EVerifyArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EVerifyArea'));
TRY(EProgAll = (EAllAccess_t)GetProcAddress(eprcore, 'EProgAll'));
TRY(EProgArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EProgArea'));
TRY(EEraseAll = (EAllAccess_t)GetProcAddress(eprcore, 'EEraseAll'));
TRY(EEraseArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EEraseArea'));
TRY(EBlankAll = (EAllAccess_t)GetProcAddress(eprcore, 'EBlankAll'));
TRY(EBlankArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EBlankArea'));
}
void ReadMemory()
{
DWORD PROGRAM_MEMORY, DATA_MEMORY;
TRY(ESelectHard('ST-LINK', 'SWIM', FALSE));
TRY(ESelectDevice('STM8L15xC6'));
TRY(ESelectPort('USB'));
TRY(EGetId('PROGRAM MEMORY', &PROGRAM_MEMORY));
TRY(EGetId('DATA MEMORY', &DATA_MEMORY));
WARN('PROGRAM MEMORY = %d, DATA MEMORY = %d', PROGRAM_MEMORY, DATA_MEMORY);
}
int main()
{
TCHAR pwd[MAX_PATH];
_wgetcwd(pwd, MAX_PATH);
WWARN(L'Current Working Directory: %sn', pwd);
SetDllDirectory(L'C:\st_toolset\stvp');
LoadLibraries();
ReadMemory();
getchar();
return 0;
}
举报